Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_POWERPC_HVCALL_H
0003 #define _ASM_POWERPC_HVCALL_H
0004 #ifdef __KERNEL__
0005 
0006 #define HVSC            .long 0x44000022
0007 
0008 #define H_SUCCESS   0
0009 #define H_BUSY      1   /* Hardware busy -- retry later */
0010 #define H_CLOSED    2   /* Resource closed */
0011 #define H_NOT_AVAILABLE 3
0012 #define H_CONSTRAINED   4   /* Resource request constrained to max allowed */
0013 #define H_PARTIAL       5
0014 #define H_IN_PROGRESS   14  /* Kind of like busy */
0015 #define H_PAGE_REGISTERED 15
0016 #define H_PARTIAL_STORE   16
0017 #define H_PENDING   17  /* returned from H_POLL_PENDING */
0018 #define H_CONTINUE  18  /* Returned from H_Join on success */
0019 #define H_LONG_BUSY_START_RANGE     9900  /* Start of long busy range */
0020 #define H_LONG_BUSY_ORDER_1_MSEC    9900  /* Long busy, hint that 1msec \
0021                          is a good time to retry */
0022 #define H_LONG_BUSY_ORDER_10_MSEC   9901  /* Long busy, hint that 10msec \
0023                          is a good time to retry */
0024 #define H_LONG_BUSY_ORDER_100_MSEC  9902  /* Long busy, hint that 100msec \
0025                          is a good time to retry */
0026 #define H_LONG_BUSY_ORDER_1_SEC     9903  /* Long busy, hint that 1sec \
0027                          is a good time to retry */
0028 #define H_LONG_BUSY_ORDER_10_SEC    9904  /* Long busy, hint that 10sec \
0029                          is a good time to retry */
0030 #define H_LONG_BUSY_ORDER_100_SEC   9905  /* Long busy, hint that 100sec \
0031                          is a good time to retry */
0032 #define H_LONG_BUSY_END_RANGE       9905  /* End of long busy range */
0033 
0034 /* Internal value used in book3s_hv kvm support; not returned to guests */
0035 #define H_TOO_HARD  9999
0036 
0037 #define H_HARDWARE  -1  /* Hardware error */
0038 #define H_FUNCTION  -2  /* Function not supported */
0039 #define H_PRIVILEGE -3  /* Caller not privileged */
0040 #define H_PARAMETER -4  /* Parameter invalid, out-of-range or conflicting */
0041 #define H_BAD_MODE  -5  /* Illegal msr value */
0042 #define H_PTEG_FULL -6  /* PTEG is full */
0043 #define H_NOT_FOUND -7  /* PTE was not found" */
0044 #define H_RESERVED_DABR -8  /* DABR address is reserved by the hypervisor on this processor" */
0045 #define H_NO_MEM    -9
0046 #define H_AUTHORITY -10
0047 #define H_PERMISSION    -11
0048 #define H_DROPPED   -12
0049 #define H_SOURCE_PARM   -13
0050 #define H_DEST_PARM -14
0051 #define H_REMOTE_PARM   -15
0052 #define H_RESOURCE  -16
0053 #define H_ADAPTER_PARM  -17
0054 #define H_RH_PARM       -18
0055 #define H_RCQ_PARM      -19
0056 #define H_SCQ_PARM      -20
0057 #define H_EQ_PARM       -21
0058 #define H_RT_PARM       -22
0059 #define H_ST_PARM       -23
0060 #define H_SIGT_PARM     -24
0061 #define H_TOKEN_PARM    -25
0062 #define H_MLENGTH_PARM  -27
0063 #define H_MEM_PARM      -28
0064 #define H_MEM_ACCESS_PARM -29
0065 #define H_ATTR_PARM     -30
0066 #define H_PORT_PARM     -31
0067 #define H_MCG_PARM      -32
0068 #define H_VL_PARM       -33
0069 #define H_TSIZE_PARM    -34
0070 #define H_TRACE_PARM    -35
0071 
0072 #define H_MASK_PARM     -37
0073 #define H_MCG_FULL      -38
0074 #define H_ALIAS_EXIST   -39
0075 #define H_P_COUNTER     -40
0076 #define H_TABLE_FULL    -41
0077 #define H_ALT_TABLE     -42
0078 #define H_MR_CONDITION  -43
0079 #define H_NOT_ENOUGH_RESOURCES -44
0080 #define H_R_STATE       -45
0081 #define H_RESCINDED     -46
0082 #define H_P1        -54
0083 #define H_P2        -55
0084 #define H_P3        -56
0085 #define H_P4        -57
0086 #define H_P5        -58
0087 #define H_P6        -59
0088 #define H_P7        -60
0089 #define H_P8        -61
0090 #define H_P9        -62
0091 #define H_NOOP      -63
0092 #define H_TOO_BIG   -64
0093 #define H_UNSUPPORTED   -67
0094 #define H_OVERLAP   -68
0095 #define H_INTERRUPT -69
0096 #define H_BAD_DATA  -70
0097 #define H_NOT_ACTIVE    -71
0098 #define H_SG_LIST   -72
0099 #define H_OP_MODE   -73
0100 #define H_COP_HW    -74
0101 #define H_STATE     -75
0102 #define H_IN_USE    -77
0103 #define H_ABORTED   -78
0104 #define H_UNSUPPORTED_FLAG_START    -256
0105 #define H_UNSUPPORTED_FLAG_END      -511
0106 #define H_MULTI_THREADS_ACTIVE  -9005
0107 #define H_OUTSTANDING_COP_OPS   -9006
0108 
0109 
0110 /* Long Busy is a condition that can be returned by the firmware
0111  * when a call cannot be completed now, but the identical call
0112  * should be retried later.  This prevents calls blocking in the
0113  * firmware for long periods of time.  Annoyingly the firmware can return
0114  * a range of return codes, hinting at how long we should wait before
0115  * retrying.  If you don't care for the hint, the macro below is a good
0116  * way to check for the long_busy return codes
0117  */
0118 #define H_IS_LONG_BUSY(x)  ((x >= H_LONG_BUSY_START_RANGE) \
0119                  && (x <= H_LONG_BUSY_END_RANGE))
0120 
0121 /* Flags */
0122 #define H_LARGE_PAGE        (1UL<<(63-16))
0123 #define H_EXACT         (1UL<<(63-24))  /* Use exact PTE or return H_PTEG_FULL */
0124 #define H_R_XLATE       (1UL<<(63-25))  /* include a valid logical page num in the pte if the valid bit is set */
0125 #define H_READ_4        (1UL<<(63-26))  /* Return 4 PTEs */
0126 #define H_PAGE_STATE_CHANGE (1UL<<(63-28))
0127 #define H_PAGE_UNUSED       ((1UL<<(63-29)) | (1UL<<(63-30)))
0128 #define H_PAGE_SET_UNUSED   (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)
0129 #define H_PAGE_SET_LOANED   (H_PAGE_SET_UNUSED | (1UL<<(63-31)))
0130 #define H_PAGE_SET_ACTIVE   H_PAGE_STATE_CHANGE
0131 #define H_AVPN          (1UL<<(63-32))  /* An avpn is provided as a sanity test */
0132 #define H_ANDCOND       (1UL<<(63-33))
0133 #define H_LOCAL         (1UL<<(63-35))
0134 #define H_ICACHE_INVALIDATE (1UL<<(63-40))  /* icbi, etc.  (ignored for IO pages) */
0135 #define H_ICACHE_SYNCHRONIZE    (1UL<<(63-41))  /* dcbst, icbi, etc (ignored for IO pages */
0136 #define H_COALESCE_CAND (1UL<<(63-42))  /* page is a good candidate for coalescing */
0137 #define H_ZERO_PAGE     (1UL<<(63-48))  /* zero the page before mapping (ignored for IO pages) */
0138 #define H_COPY_PAGE     (1UL<<(63-49))
0139 #define H_N         (1UL<<(63-61))
0140 #define H_PP1           (1UL<<(63-62))
0141 #define H_PP2           (1UL<<(63-63))
0142 
0143 /* Flags for H_REGISTER_VPA subfunction field */
0144 #define H_VPA_FUNC_SHIFT    (63-18) /* Bit posn of subfunction code */
0145 #define H_VPA_FUNC_MASK     7UL
0146 #define H_VPA_REG_VPA       1UL /* Register Virtual Processor Area */
0147 #define H_VPA_REG_DTL       2UL /* Register Dispatch Trace Log */
0148 #define H_VPA_REG_SLB       3UL /* Register SLB shadow buffer */
0149 #define H_VPA_DEREG_VPA     5UL /* Deregister Virtual Processor Area */
0150 #define H_VPA_DEREG_DTL     6UL /* Deregister Dispatch Trace Log */
0151 #define H_VPA_DEREG_SLB     7UL /* Deregister SLB shadow buffer */
0152 
0153 /* VASI States */
0154 #define H_VASI_INVALID          0
0155 #define H_VASI_ENABLED          1
0156 #define H_VASI_ABORTED          2
0157 #define H_VASI_SUSPENDING       3
0158 #define H_VASI_SUSPENDED        4
0159 #define H_VASI_RESUMED          5
0160 #define H_VASI_COMPLETED        6
0161 
0162 /* VASI signal codes. Only the Cancel code is valid for H_VASI_SIGNAL. */
0163 #define H_VASI_SIGNAL_CANCEL    1
0164 #define H_VASI_SIGNAL_ABORT     2
0165 #define H_VASI_SIGNAL_SUSPEND   3
0166 #define H_VASI_SIGNAL_COMPLETE  4
0167 #define H_VASI_SIGNAL_ENABLE    5
0168 #define H_VASI_SIGNAL_FAILOVER  6
0169 
0170 /* Each control block has to be on a 4K boundary */
0171 #define H_CB_ALIGNMENT          4096
0172 
0173 /* pSeries hypervisor opcodes */
0174 #define H_REMOVE        0x04
0175 #define H_ENTER         0x08
0176 #define H_READ          0x0c
0177 #define H_CLEAR_MOD     0x10
0178 #define H_CLEAR_REF     0x14
0179 #define H_PROTECT       0x18
0180 #define H_GET_TCE       0x1c
0181 #define H_PUT_TCE       0x20
0182 #define H_SET_SPRG0     0x24
0183 #define H_SET_DABR      0x28
0184 #define H_PAGE_INIT     0x2c
0185 #define H_SET_ASR       0x30
0186 #define H_ASR_ON        0x34
0187 #define H_ASR_OFF       0x38
0188 #define H_LOGICAL_CI_LOAD   0x3c
0189 #define H_LOGICAL_CI_STORE  0x40
0190 #define H_LOGICAL_CACHE_LOAD    0x44
0191 #define H_LOGICAL_CACHE_STORE   0x48
0192 #define H_LOGICAL_ICBI      0x4c
0193 #define H_LOGICAL_DCBF      0x50
0194 #define H_GET_TERM_CHAR     0x54
0195 #define H_PUT_TERM_CHAR     0x58
0196 #define H_REAL_TO_LOGICAL   0x5c
0197 #define H_HYPERVISOR_DATA   0x60
0198 #define H_EOI           0x64
0199 #define H_CPPR          0x68
0200 #define H_IPI           0x6c
0201 #define H_IPOLL         0x70
0202 #define H_XIRR          0x74
0203 #define H_PERFMON       0x7c
0204 #define H_MIGRATE_DMA       0x78
0205 #define H_REGISTER_VPA      0xDC
0206 #define H_CEDE          0xE0
0207 #define H_CONFER        0xE4
0208 #define H_PROD          0xE8
0209 #define H_GET_PPP       0xEC
0210 #define H_SET_PPP       0xF0
0211 #define H_PURR          0xF4
0212 #define H_PIC           0xF8
0213 #define H_REG_CRQ       0xFC
0214 #define H_FREE_CRQ      0x100
0215 #define H_VIO_SIGNAL        0x104
0216 #define H_SEND_CRQ      0x108
0217 #define H_COPY_RDMA     0x110
0218 #define H_REGISTER_LOGICAL_LAN  0x114
0219 #define H_FREE_LOGICAL_LAN  0x118
0220 #define H_ADD_LOGICAL_LAN_BUFFER 0x11C
0221 #define H_SEND_LOGICAL_LAN  0x120
0222 #define H_BULK_REMOVE       0x124
0223 #define H_MULTICAST_CTRL    0x130
0224 #define H_SET_XDABR     0x134
0225 #define H_STUFF_TCE     0x138
0226 #define H_PUT_TCE_INDIRECT  0x13C
0227 #define H_CHANGE_LOGICAL_LAN_MAC 0x14C
0228 #define H_VTERM_PARTNER_INFO    0x150
0229 #define H_REGISTER_VTERM    0x154
0230 #define H_FREE_VTERM        0x158
0231 #define H_RESET_EVENTS          0x15C
0232 #define H_ALLOC_RESOURCE        0x160
0233 #define H_FREE_RESOURCE         0x164
0234 #define H_MODIFY_QP             0x168
0235 #define H_QUERY_QP              0x16C
0236 #define H_REREGISTER_PMR        0x170
0237 #define H_REGISTER_SMR          0x174
0238 #define H_QUERY_MR              0x178
0239 #define H_QUERY_MW              0x17C
0240 #define H_QUERY_HCA             0x180
0241 #define H_QUERY_PORT            0x184
0242 #define H_MODIFY_PORT           0x188
0243 #define H_DEFINE_AQP1           0x18C
0244 #define H_GET_TRACE_BUFFER      0x190
0245 #define H_DEFINE_AQP0           0x194
0246 #define H_RESIZE_MR             0x198
0247 #define H_ATTACH_MCQP           0x19C
0248 #define H_DETACH_MCQP           0x1A0
0249 #define H_CREATE_RPT            0x1A4
0250 #define H_REMOVE_RPT            0x1A8
0251 #define H_REGISTER_RPAGES       0x1AC
0252 #define H_DISABLE_AND_GET       0x1B0
0253 #define H_ERROR_DATA            0x1B4
0254 #define H_GET_HCA_INFO          0x1B8
0255 #define H_GET_PERF_COUNT        0x1BC
0256 #define H_MANAGE_TRACE          0x1C0
0257 #define H_GET_CPU_CHARACTERISTICS 0x1C8
0258 #define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
0259 #define H_QUERY_INT_STATE       0x1E4
0260 #define H_POLL_PENDING      0x1D8
0261 #define H_ILLAN_ATTRIBUTES  0x244
0262 #define H_MODIFY_HEA_QP     0x250
0263 #define H_QUERY_HEA_QP      0x254
0264 #define H_QUERY_HEA     0x258
0265 #define H_QUERY_HEA_PORT    0x25C
0266 #define H_MODIFY_HEA_PORT   0x260
0267 #define H_REG_BCMC      0x264
0268 #define H_DEREG_BCMC        0x268
0269 #define H_REGISTER_HEA_RPAGES   0x26C
0270 #define H_DISABLE_AND_GET_HEA   0x270
0271 #define H_GET_HEA_INFO      0x274
0272 #define H_ALLOC_HEA_RESOURCE    0x278
0273 #define H_ADD_CONN      0x284
0274 #define H_DEL_CONN      0x288
0275 #define H_JOIN          0x298
0276 #define H_VASI_SIGNAL           0x2A0
0277 #define H_VASI_STATE            0x2A4
0278 #define H_VIOCTL        0x2A8
0279 #define H_ENABLE_CRQ        0x2B0
0280 #define H_GET_EM_PARMS      0x2B8
0281 #define H_SET_MPP       0x2D0
0282 #define H_GET_MPP       0x2D4
0283 #define H_REG_SUB_CRQ       0x2DC
0284 #define H_HOME_NODE_ASSOCIATIVITY 0x2EC
0285 #define H_FREE_SUB_CRQ      0x2E0
0286 #define H_SEND_SUB_CRQ      0x2E4
0287 #define H_SEND_SUB_CRQ_INDIRECT 0x2E8
0288 #define H_BEST_ENERGY       0x2F4
0289 #define H_XIRR_X        0x2FC
0290 #define H_RANDOM        0x300
0291 #define H_COP           0x304
0292 #define H_GET_MPP_X     0x314
0293 #define H_SET_MODE      0x31C
0294 #define H_BLOCK_REMOVE      0x328
0295 #define H_CLEAR_HPT     0x358
0296 #define H_REQUEST_VMC       0x360
0297 #define H_RESIZE_HPT_PREPARE    0x36C
0298 #define H_RESIZE_HPT_COMMIT 0x370
0299 #define H_REGISTER_PROC_TBL 0x37C
0300 #define H_SIGNAL_SYS_RESET  0x380
0301 #define H_ALLOCATE_VAS_WINDOW   0x388
0302 #define H_MODIFY_VAS_WINDOW 0x38C
0303 #define H_DEALLOCATE_VAS_WINDOW 0x390
0304 #define H_QUERY_VAS_WINDOW  0x394
0305 #define H_QUERY_VAS_CAPABILITIES    0x398
0306 #define H_QUERY_NX_CAPABILITIES 0x39C
0307 #define H_GET_NX_FAULT      0x3A0
0308 #define H_INT_GET_SOURCE_INFO   0x3A8
0309 #define H_INT_SET_SOURCE_CONFIG 0x3AC
0310 #define H_INT_GET_SOURCE_CONFIG 0x3B0
0311 #define H_INT_GET_QUEUE_INFO    0x3B4
0312 #define H_INT_SET_QUEUE_CONFIG  0x3B8
0313 #define H_INT_GET_QUEUE_CONFIG  0x3BC
0314 #define H_INT_SET_OS_REPORTING_LINE 0x3C0
0315 #define H_INT_GET_OS_REPORTING_LINE 0x3C4
0316 #define H_INT_ESB               0x3C8
0317 #define H_INT_SYNC              0x3CC
0318 #define H_INT_RESET             0x3D0
0319 #define H_SCM_READ_METADATA     0x3E4
0320 #define H_SCM_WRITE_METADATA    0x3E8
0321 #define H_SCM_BIND_MEM          0x3EC
0322 #define H_SCM_UNBIND_MEM        0x3F0
0323 #define H_SCM_QUERY_BLOCK_MEM_BINDING 0x3F4
0324 #define H_SCM_QUERY_LOGICAL_MEM_BINDING 0x3F8
0325 #define H_SCM_UNBIND_ALL        0x3FC
0326 #define H_SCM_HEALTH            0x400
0327 #define H_SCM_PERFORMANCE_STATS 0x418
0328 #define H_PKS_GET_CONFIG    0x41C
0329 #define H_PKS_SET_PASSWORD  0x420
0330 #define H_PKS_GEN_PASSWORD  0x424
0331 #define H_PKS_WRITE_OBJECT  0x42C
0332 #define H_PKS_GEN_KEY       0x430
0333 #define H_PKS_READ_OBJECT   0x434
0334 #define H_PKS_REMOVE_OBJECT 0x438
0335 #define H_PKS_CONFIRM_OBJECT_FLUSHED    0x43C
0336 #define H_RPT_INVALIDATE    0x448
0337 #define H_SCM_FLUSH     0x44C
0338 #define H_GET_ENERGY_SCALE_INFO 0x450
0339 #define H_WATCHDOG      0x45C
0340 #define MAX_HCALL_OPCODE    H_WATCHDOG
0341 
0342 /* Scope args for H_SCM_UNBIND_ALL */
0343 #define H_UNBIND_SCOPE_ALL (0x1)
0344 #define H_UNBIND_SCOPE_DRC (0x2)
0345 
0346 /* H_VIOCTL functions */
0347 #define H_GET_VIOA_DUMP_SIZE    0x01
0348 #define H_GET_VIOA_DUMP     0x02
0349 #define H_GET_ILLAN_NUM_VLAN_IDS 0x03
0350 #define H_GET_ILLAN_VLAN_ID_LIST 0x04
0351 #define H_GET_ILLAN_SWITCH_ID   0x05
0352 #define H_DISABLE_MIGRATION 0x06
0353 #define H_ENABLE_MIGRATION  0x07
0354 #define H_GET_PARTNER_INFO  0x08
0355 #define H_GET_PARTNER_WWPN_LIST 0x09
0356 #define H_DISABLE_ALL_VIO_INTS  0x0A
0357 #define H_DISABLE_VIO_INTERRUPT 0x0B
0358 #define H_ENABLE_VIO_INTERRUPT  0x0C
0359 #define H_GET_SESSION_TOKEN 0x19
0360 #define H_SESSION_ERR_DETECTED  0x1A
0361 
0362 
0363 /* Platform specific hcalls, used by KVM */
0364 #define H_RTAS          0xf000
0365 
0366 /*
0367  * Platform specific hcalls, used by QEMU/SLOF. These are ignored by
0368  * KVM and only kept here so we can identify them during tracing.
0369  */
0370 #define H_LOGICAL_MEMOP  0xF001
0371 #define H_CAS            0XF002
0372 #define H_UPDATE_DT      0XF003
0373 
0374 /* "Platform specific hcalls", provided by PHYP */
0375 #define H_GET_24X7_CATALOG_PAGE 0xF078
0376 #define H_GET_24X7_DATA     0xF07C
0377 #define H_GET_PERF_COUNTER_INFO 0xF080
0378 
0379 /* Platform-specific hcalls used for nested HV KVM */
0380 #define H_SET_PARTITION_TABLE   0xF800
0381 #define H_ENTER_NESTED      0xF804
0382 #define H_TLB_INVALIDATE    0xF808
0383 #define H_COPY_TOFROM_GUEST 0xF80C
0384 
0385 /* Flags for H_SVM_PAGE_IN */
0386 #define H_PAGE_IN_SHARED        0x1
0387 
0388 /* Platform-specific hcalls used by the Ultravisor */
0389 #define H_SVM_PAGE_IN       0xEF00
0390 #define H_SVM_PAGE_OUT      0xEF04
0391 #define H_SVM_INIT_START    0xEF08
0392 #define H_SVM_INIT_DONE     0xEF0C
0393 #define H_SVM_INIT_ABORT    0xEF14
0394 
0395 /* Values for 2nd argument to H_SET_MODE */
0396 #define H_SET_MODE_RESOURCE_SET_CIABR       1
0397 #define H_SET_MODE_RESOURCE_SET_DAWR0       2
0398 #define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE 3
0399 #define H_SET_MODE_RESOURCE_LE          4
0400 #define H_SET_MODE_RESOURCE_SET_DAWR1       5
0401 
0402 /* Values for argument to H_SIGNAL_SYS_RESET */
0403 #define H_SIGNAL_SYS_RESET_ALL          -1
0404 #define H_SIGNAL_SYS_RESET_ALL_OTHERS       -2
0405 /* >= 0 values are CPU number */
0406 
0407 /* H_GET_CPU_CHARACTERISTICS return values */
0408 #define H_CPU_CHAR_SPEC_BAR_ORI31   (1ull << 63) // IBM bit 0
0409 #define H_CPU_CHAR_BCCTRL_SERIALISED    (1ull << 62) // IBM bit 1
0410 #define H_CPU_CHAR_L1D_FLUSH_ORI30  (1ull << 61) // IBM bit 2
0411 #define H_CPU_CHAR_L1D_FLUSH_TRIG2  (1ull << 60) // IBM bit 3
0412 #define H_CPU_CHAR_L1D_THREAD_PRIV  (1ull << 59) // IBM bit 4
0413 #define H_CPU_CHAR_BRANCH_HINTS_HONORED (1ull << 58) // IBM bit 5
0414 #define H_CPU_CHAR_THREAD_RECONFIG_CTRL (1ull << 57) // IBM bit 6
0415 #define H_CPU_CHAR_COUNT_CACHE_DISABLED (1ull << 56) // IBM bit 7
0416 #define H_CPU_CHAR_BCCTR_FLUSH_ASSIST   (1ull << 54) // IBM bit 9
0417 #define H_CPU_CHAR_BCCTR_LINK_FLUSH_ASSIST (1ull << 52) // IBM bit 11
0418 
0419 #define H_CPU_BEHAV_FAVOUR_SECURITY (1ull << 63) // IBM bit 0
0420 #define H_CPU_BEHAV_L1D_FLUSH_PR    (1ull << 62) // IBM bit 1
0421 #define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR   (1ull << 61) // IBM bit 2
0422 #define H_CPU_BEHAV_FAVOUR_SECURITY_H   (1ull << 60) // IBM bit 3
0423 #define H_CPU_BEHAV_FLUSH_COUNT_CACHE   (1ull << 58) // IBM bit 5
0424 #define H_CPU_BEHAV_FLUSH_LINK_STACK    (1ull << 57) // IBM bit 6
0425 #define H_CPU_BEHAV_NO_L1D_FLUSH_ENTRY  (1ull << 56) // IBM bit 7
0426 #define H_CPU_BEHAV_NO_L1D_FLUSH_UACCESS (1ull << 55) // IBM bit 8
0427 #define H_CPU_BEHAV_NO_STF_BARRIER  (1ull << 54) // IBM bit 9
0428 
0429 /* Flag values used in H_REGISTER_PROC_TBL hcall */
0430 #define PROC_TABLE_OP_MASK  0x18
0431 #define PROC_TABLE_DEREG    0x10
0432 #define PROC_TABLE_NEW      0x18
0433 #define PROC_TABLE_TYPE_MASK    0x06
0434 #define PROC_TABLE_HPT_SLB  0x00
0435 #define PROC_TABLE_HPT_PT   0x02
0436 #define PROC_TABLE_RADIX    0x04
0437 #define PROC_TABLE_GTSE     0x01
0438 
0439 /*
0440  * Defines for
0441  * H_RPT_INVALIDATE - Invalidate RPT translation lookaside information.
0442  */
0443 
0444 /* Type of translation to invalidate (type) */
0445 #define H_RPTI_TYPE_NESTED  0x0001  /* Invalidate nested guest partition-scope */
0446 #define H_RPTI_TYPE_TLB     0x0002  /* Invalidate TLB */
0447 #define H_RPTI_TYPE_PWC     0x0004  /* Invalidate Page Walk Cache */
0448 /* Invalidate caching of Process Table Entries if H_RPTI_TYPE_NESTED is clear */
0449 #define H_RPTI_TYPE_PRT     0x0008
0450 /* Invalidate caching of Partition Table Entries if H_RPTI_TYPE_NESTED is set */
0451 #define H_RPTI_TYPE_PAT     0x0008
0452 #define H_RPTI_TYPE_ALL     (H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | \
0453                  H_RPTI_TYPE_PRT)
0454 #define H_RPTI_TYPE_NESTED_ALL  (H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | \
0455                  H_RPTI_TYPE_PAT)
0456 
0457 /* Invalidation targets (target) */
0458 #define H_RPTI_TARGET_CMMU      0x01 /* All virtual processors in the partition */
0459 #define H_RPTI_TARGET_CMMU_LOCAL    0x02 /* Current virtual processor */
0460 /* All nest/accelerator agents in use by the partition */
0461 #define H_RPTI_TARGET_NMMU      0x04
0462 
0463 /* Page size mask (page sizes) */
0464 #define H_RPTI_PAGE_4K  0x01
0465 #define H_RPTI_PAGE_64K 0x02
0466 #define H_RPTI_PAGE_2M  0x04
0467 #define H_RPTI_PAGE_1G  0x08
0468 #define H_RPTI_PAGE_ALL (-1UL)
0469 
0470 #ifndef __ASSEMBLY__
0471 #include <linux/types.h>
0472 
0473 /**
0474  * plpar_hcall_norets: - Make a pseries hypervisor call with no return arguments
0475  * @opcode: The hypervisor call to make.
0476  *
0477  * This call supports up to 7 arguments and only returns the status of
0478  * the hcall. Use this version where possible, its slightly faster than
0479  * the other plpar_hcalls.
0480  */
0481 long plpar_hcall_norets(unsigned long opcode, ...);
0482 
0483 /* Variant which does not do hcall tracing */
0484 long plpar_hcall_norets_notrace(unsigned long opcode, ...);
0485 
0486 /**
0487  * plpar_hcall: - Make a pseries hypervisor call
0488  * @opcode: The hypervisor call to make.
0489  * @retbuf: Buffer to store up to 4 return arguments in.
0490  *
0491  * This call supports up to 6 arguments and 4 return arguments. Use
0492  * PLPAR_HCALL_BUFSIZE to size the return argument buffer.
0493  *
0494  * Used for all but the craziest of phyp interfaces (see plpar_hcall9)
0495  */
0496 #define PLPAR_HCALL_BUFSIZE 4
0497 long plpar_hcall(unsigned long opcode, unsigned long *retbuf, ...);
0498 
0499 /**
0500  * plpar_hcall_raw: - Make a hypervisor call without calculating hcall stats
0501  * @opcode: The hypervisor call to make.
0502  * @retbuf: Buffer to store up to 4 return arguments in.
0503  *
0504  * This call supports up to 6 arguments and 4 return arguments. Use
0505  * PLPAR_HCALL_BUFSIZE to size the return argument buffer.
0506  *
0507  * Used when phyp interface needs to be called in real mode. Similar to
0508  * plpar_hcall, but plpar_hcall_raw works in real mode and does not
0509  * calculate hypervisor call statistics.
0510  */
0511 long plpar_hcall_raw(unsigned long opcode, unsigned long *retbuf, ...);
0512 
0513 /**
0514  * plpar_hcall9: - Make a pseries hypervisor call with up to 9 return arguments
0515  * @opcode: The hypervisor call to make.
0516  * @retbuf: Buffer to store up to 9 return arguments in.
0517  *
0518  * This call supports up to 9 arguments and 9 return arguments. Use
0519  * PLPAR_HCALL9_BUFSIZE to size the return argument buffer.
0520  */
0521 #define PLPAR_HCALL9_BUFSIZE 9
0522 long plpar_hcall9(unsigned long opcode, unsigned long *retbuf, ...);
0523 long plpar_hcall9_raw(unsigned long opcode, unsigned long *retbuf, ...);
0524 
0525 /* pseries hcall tracing */
0526 extern struct static_key hcall_tracepoint_key;
0527 void __trace_hcall_entry(unsigned long opcode, unsigned long *args);
0528 void __trace_hcall_exit(long opcode, long retval, unsigned long *retbuf);
0529 
0530 struct hvcall_mpp_data {
0531     unsigned long entitled_mem;
0532     unsigned long mapped_mem;
0533     unsigned short group_num;
0534     unsigned short pool_num;
0535     unsigned char mem_weight;
0536     unsigned char unallocated_mem_weight;
0537     unsigned long unallocated_entitlement;  /* value in bytes */
0538     unsigned long pool_size;
0539     signed long loan_request;
0540     unsigned long backing_mem;
0541 };
0542 
0543 int h_get_mpp(struct hvcall_mpp_data *);
0544 
0545 struct hvcall_mpp_x_data {
0546     unsigned long coalesced_bytes;
0547     unsigned long pool_coalesced_bytes;
0548     unsigned long pool_purr_cycles;
0549     unsigned long pool_spurr_cycles;
0550     unsigned long reserved[3];
0551 };
0552 
0553 int h_get_mpp_x(struct hvcall_mpp_x_data *mpp_x_data);
0554 
0555 static inline unsigned int get_longbusy_msecs(int longbusy_rc)
0556 {
0557     switch (longbusy_rc) {
0558     case H_LONG_BUSY_ORDER_1_MSEC:
0559         return 1;
0560     case H_LONG_BUSY_ORDER_10_MSEC:
0561         return 10;
0562     case H_LONG_BUSY_ORDER_100_MSEC:
0563         return 100;
0564     case H_LONG_BUSY_ORDER_1_SEC:
0565         return 1000;
0566     case H_LONG_BUSY_ORDER_10_SEC:
0567         return 10000;
0568     case H_LONG_BUSY_ORDER_100_SEC:
0569         return 100000;
0570     default:
0571         return 1;
0572     }
0573 }
0574 
0575 struct h_cpu_char_result {
0576     u64 character;
0577     u64 behaviour;
0578 };
0579 
0580 /*
0581  * Register state for entering a nested guest with H_ENTER_NESTED.
0582  * New member must be added at the end.
0583  */
0584 struct hv_guest_state {
0585     u64 version;        /* version of this structure layout, must be first */
0586     u32 lpid;
0587     u32 vcpu_token;
0588     /* These registers are hypervisor privileged (at least for writing) */
0589     u64 lpcr;
0590     u64 pcr;
0591     u64 amor;
0592     u64 dpdes;
0593     u64 hfscr;
0594     s64 tb_offset;
0595     u64 dawr0;
0596     u64 dawrx0;
0597     u64 ciabr;
0598     u64 hdec_expiry;
0599     u64 purr;
0600     u64 spurr;
0601     u64 ic;
0602     u64 vtb;
0603     u64 hdar;
0604     u64 hdsisr;
0605     u64 heir;
0606     u64 asdr;
0607     /* These are OS privileged but need to be set late in guest entry */
0608     u64 srr0;
0609     u64 srr1;
0610     u64 sprg[4];
0611     u64 pidr;
0612     u64 cfar;
0613     u64 ppr;
0614     /* Version 1 ends here */
0615     u64 dawr1;
0616     u64 dawrx1;
0617     /* Version 2 ends here */
0618 };
0619 
0620 /* Latest version of hv_guest_state structure */
0621 #define HV_GUEST_STATE_VERSION  2
0622 
0623 static inline int hv_guest_state_size(unsigned int version)
0624 {
0625     switch (version) {
0626     case 1:
0627         return offsetofend(struct hv_guest_state, ppr);
0628     case 2:
0629         return offsetofend(struct hv_guest_state, dawrx1);
0630     default:
0631         return -1;
0632     }
0633 }
0634 
0635 /*
0636  * From the document "H_GetPerformanceCounterInfo Interface" v1.07
0637  *
0638  * H_GET_PERF_COUNTER_INFO argument
0639  */
0640 struct hv_get_perf_counter_info_params {
0641     __be32 counter_request; /* I */
0642     __be32 starting_index;  /* IO */
0643     __be16 secondary_index; /* IO */
0644     __be16 returned_values; /* O */
0645     __be32 detail_rc; /* O, only needed when called via *_norets() */
0646 
0647     /*
0648      * O, size each of counter_value element in bytes, only set for version
0649      * >= 0x3
0650      */
0651     __be16 cv_element_size;
0652 
0653     /* I, 0 (zero) for versions < 0x3 */
0654     __u8 counter_info_version_in;
0655 
0656     /* O, 0 (zero) if version < 0x3. Must be set to 0 when making hcall */
0657     __u8 counter_info_version_out;
0658     __u8 reserved[0xC];
0659     __u8 counter_value[];
0660 } __packed;
0661 
0662 #define HGPCI_REQ_BUFFER_SIZE   4096
0663 #define HGPCI_MAX_DATA_BYTES \
0664     (HGPCI_REQ_BUFFER_SIZE - sizeof(struct hv_get_perf_counter_info_params))
0665 
0666 struct hv_gpci_request_buffer {
0667     struct hv_get_perf_counter_info_params params;
0668     uint8_t bytes[HGPCI_MAX_DATA_BYTES];
0669 } __packed;
0670 
0671 #endif /* __ASSEMBLY__ */
0672 #endif /* __KERNEL__ */
0673 #endif /* _ASM_POWERPC_HVCALL_H */