svm_x86.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef __SVM_H
  3. #define __SVM_H
  4. #define SVM_EXIT_READ_CR0 0x000
  5. #define SVM_EXIT_READ_CR2 0x002
  6. #define SVM_EXIT_READ_CR3 0x003
  7. #define SVM_EXIT_READ_CR4 0x004
  8. #define SVM_EXIT_READ_CR8 0x008
  9. #define SVM_EXIT_WRITE_CR0 0x010
  10. #define SVM_EXIT_WRITE_CR2 0x012
  11. #define SVM_EXIT_WRITE_CR3 0x013
  12. #define SVM_EXIT_WRITE_CR4 0x014
  13. #define SVM_EXIT_WRITE_CR8 0x018
  14. #define SVM_EXIT_READ_DR0 0x020
  15. #define SVM_EXIT_READ_DR1 0x021
  16. #define SVM_EXIT_READ_DR2 0x022
  17. #define SVM_EXIT_READ_DR3 0x023
  18. #define SVM_EXIT_READ_DR4 0x024
  19. #define SVM_EXIT_READ_DR5 0x025
  20. #define SVM_EXIT_READ_DR6 0x026
  21. #define SVM_EXIT_READ_DR7 0x027
  22. #define SVM_EXIT_WRITE_DR0 0x030
  23. #define SVM_EXIT_WRITE_DR1 0x031
  24. #define SVM_EXIT_WRITE_DR2 0x032
  25. #define SVM_EXIT_WRITE_DR3 0x033
  26. #define SVM_EXIT_WRITE_DR4 0x034
  27. #define SVM_EXIT_WRITE_DR5 0x035
  28. #define SVM_EXIT_WRITE_DR6 0x036
  29. #define SVM_EXIT_WRITE_DR7 0x037
  30. #define SVM_EXIT_EXCP_BASE 0x040
  31. #define SVM_EXIT_LAST_EXCP 0x05f
  32. #define SVM_EXIT_INTR 0x060
  33. #define SVM_EXIT_NMI 0x061
  34. #define SVM_EXIT_SMI 0x062
  35. #define SVM_EXIT_INIT 0x063
  36. #define SVM_EXIT_VINTR 0x064
  37. #define SVM_EXIT_CR0_SEL_WRITE 0x065
  38. #define SVM_EXIT_IDTR_READ 0x066
  39. #define SVM_EXIT_GDTR_READ 0x067
  40. #define SVM_EXIT_LDTR_READ 0x068
  41. #define SVM_EXIT_TR_READ 0x069
  42. #define SVM_EXIT_IDTR_WRITE 0x06a
  43. #define SVM_EXIT_GDTR_WRITE 0x06b
  44. #define SVM_EXIT_LDTR_WRITE 0x06c
  45. #define SVM_EXIT_TR_WRITE 0x06d
  46. #define SVM_EXIT_RDTSC 0x06e
  47. #define SVM_EXIT_RDPMC 0x06f
  48. #define SVM_EXIT_PUSHF 0x070
  49. #define SVM_EXIT_POPF 0x071
  50. #define SVM_EXIT_CPUID 0x072
  51. #define SVM_EXIT_RSM 0x073
  52. #define SVM_EXIT_IRET 0x074
  53. #define SVM_EXIT_SWINT 0x075
  54. #define SVM_EXIT_INVD 0x076
  55. #define SVM_EXIT_PAUSE 0x077
  56. #define SVM_EXIT_HLT 0x078
  57. #define SVM_EXIT_INVLPG 0x079
  58. #define SVM_EXIT_INVLPGA 0x07a
  59. #define SVM_EXIT_IOIO 0x07b
  60. #define SVM_EXIT_MSR 0x07c
  61. #define SVM_EXIT_TASK_SWITCH 0x07d
  62. #define SVM_EXIT_FERR_FREEZE 0x07e
  63. #define SVM_EXIT_SHUTDOWN 0x07f
  64. #define SVM_EXIT_VMRUN 0x080
  65. #define SVM_EXIT_VMMCALL 0x081
  66. #define SVM_EXIT_VMLOAD 0x082
  67. #define SVM_EXIT_VMSAVE 0x083
  68. #define SVM_EXIT_STGI 0x084
  69. #define SVM_EXIT_CLGI 0x085
  70. #define SVM_EXIT_SKINIT 0x086
  71. #define SVM_EXIT_RDTSCP 0x087
  72. #define SVM_EXIT_ICEBP 0x088
  73. #define SVM_EXIT_WBINVD 0x089
  74. #define SVM_EXIT_MONITOR 0x08a
  75. #define SVM_EXIT_MWAIT 0x08b
  76. #define SVM_EXIT_MWAIT_COND 0x08c
  77. #define SVM_EXIT_XSETBV 0x08d
  78. #define SVM_EXIT_RDPRU 0x08e
  79. #define SVM_EXIT_EFER_WRITE_TRAP 0x08f
  80. #define SVM_EXIT_CR0_WRITE_TRAP 0x090
  81. #define SVM_EXIT_CR1_WRITE_TRAP 0x091
  82. #define SVM_EXIT_CR2_WRITE_TRAP 0x092
  83. #define SVM_EXIT_CR3_WRITE_TRAP 0x093
  84. #define SVM_EXIT_CR4_WRITE_TRAP 0x094
  85. #define SVM_EXIT_CR5_WRITE_TRAP 0x095
  86. #define SVM_EXIT_CR6_WRITE_TRAP 0x096
  87. #define SVM_EXIT_CR7_WRITE_TRAP 0x097
  88. #define SVM_EXIT_CR8_WRITE_TRAP 0x098
  89. #define SVM_EXIT_CR9_WRITE_TRAP 0x099
  90. #define SVM_EXIT_CR10_WRITE_TRAP 0x09a
  91. #define SVM_EXIT_CR11_WRITE_TRAP 0x09b
  92. #define SVM_EXIT_CR12_WRITE_TRAP 0x09c
  93. #define SVM_EXIT_CR13_WRITE_TRAP 0x09d
  94. #define SVM_EXIT_CR14_WRITE_TRAP 0x09e
  95. #define SVM_EXIT_CR15_WRITE_TRAP 0x09f
  96. #define SVM_EXIT_INVPCID 0x0a2
  97. #define SVM_EXIT_NPF 0x400
  98. #define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
  99. #define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
  100. #define SVM_EXIT_VMGEXIT 0x403
  101. /* SEV-ES software-defined VMGEXIT events */
  102. #define SVM_VMGEXIT_MMIO_READ 0x80000001
  103. #define SVM_VMGEXIT_MMIO_WRITE 0x80000002
  104. #define SVM_VMGEXIT_NMI_COMPLETE 0x80000003
  105. #define SVM_VMGEXIT_AP_HLT_LOOP 0x80000004
  106. #define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005
  107. #define SVM_VMGEXIT_SET_AP_JUMP_TABLE 0
  108. #define SVM_VMGEXIT_GET_AP_JUMP_TABLE 1
  109. #define SVM_VMGEXIT_PSC 0x80000010
  110. #define SVM_VMGEXIT_GUEST_REQUEST 0x80000011
  111. #define SVM_VMGEXIT_EXT_GUEST_REQUEST 0x80000012
  112. #define SVM_VMGEXIT_AP_CREATION 0x80000013
  113. #define SVM_VMGEXIT_AP_CREATE_ON_INIT 0
  114. #define SVM_VMGEXIT_AP_CREATE 1
  115. #define SVM_VMGEXIT_AP_DESTROY 2
  116. #define SVM_VMGEXIT_HV_FEATURES 0x8000fffd
  117. #define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe
  118. #define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \
  119. /* SW_EXITINFO1[3:0] */ \
  120. (((((u64)reason_set) & 0xf)) | \
  121. /* SW_EXITINFO1[11:4] */ \
  122. ((((u64)reason_code) & 0xff) << 4))
  123. #define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff
  124. /* Exit code reserved for hypervisor/software use */
  125. #define SVM_EXIT_SW 0xf0000000
  126. #define SVM_EXIT_ERR -1
  127. #define SVM_EXIT_REASONS \
  128. { SVM_EXIT_READ_CR0, "read_cr0" }, \
  129. { SVM_EXIT_READ_CR2, "read_cr2" }, \
  130. { SVM_EXIT_READ_CR3, "read_cr3" }, \
  131. { SVM_EXIT_READ_CR4, "read_cr4" }, \
  132. { SVM_EXIT_READ_CR8, "read_cr8" }, \
  133. { SVM_EXIT_WRITE_CR0, "write_cr0" }, \
  134. { SVM_EXIT_WRITE_CR2, "write_cr2" }, \
  135. { SVM_EXIT_WRITE_CR3, "write_cr3" }, \
  136. { SVM_EXIT_WRITE_CR4, "write_cr4" }, \
  137. { SVM_EXIT_WRITE_CR8, "write_cr8" }, \
  138. { SVM_EXIT_READ_DR0, "read_dr0" }, \
  139. { SVM_EXIT_READ_DR1, "read_dr1" }, \
  140. { SVM_EXIT_READ_DR2, "read_dr2" }, \
  141. { SVM_EXIT_READ_DR3, "read_dr3" }, \
  142. { SVM_EXIT_READ_DR4, "read_dr4" }, \
  143. { SVM_EXIT_READ_DR5, "read_dr5" }, \
  144. { SVM_EXIT_READ_DR6, "read_dr6" }, \
  145. { SVM_EXIT_READ_DR7, "read_dr7" }, \
  146. { SVM_EXIT_WRITE_DR0, "write_dr0" }, \
  147. { SVM_EXIT_WRITE_DR1, "write_dr1" }, \
  148. { SVM_EXIT_WRITE_DR2, "write_dr2" }, \
  149. { SVM_EXIT_WRITE_DR3, "write_dr3" }, \
  150. { SVM_EXIT_WRITE_DR4, "write_dr4" }, \
  151. { SVM_EXIT_WRITE_DR5, "write_dr5" }, \
  152. { SVM_EXIT_WRITE_DR6, "write_dr6" }, \
  153. { SVM_EXIT_WRITE_DR7, "write_dr7" }, \
  154. { SVM_EXIT_EXCP_BASE + DE_VECTOR, "DE excp" }, \
  155. { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, \
  156. { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, \
  157. { SVM_EXIT_EXCP_BASE + OF_VECTOR, "OF excp" }, \
  158. { SVM_EXIT_EXCP_BASE + BR_VECTOR, "BR excp" }, \
  159. { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, \
  160. { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, \
  161. { SVM_EXIT_EXCP_BASE + DF_VECTOR, "DF excp" }, \
  162. { SVM_EXIT_EXCP_BASE + TS_VECTOR, "TS excp" }, \
  163. { SVM_EXIT_EXCP_BASE + NP_VECTOR, "NP excp" }, \
  164. { SVM_EXIT_EXCP_BASE + SS_VECTOR, "SS excp" }, \
  165. { SVM_EXIT_EXCP_BASE + GP_VECTOR, "GP excp" }, \
  166. { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, \
  167. { SVM_EXIT_EXCP_BASE + MF_VECTOR, "MF excp" }, \
  168. { SVM_EXIT_EXCP_BASE + AC_VECTOR, "AC excp" }, \
  169. { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, \
  170. { SVM_EXIT_EXCP_BASE + XM_VECTOR, "XF excp" }, \
  171. { SVM_EXIT_INTR, "interrupt" }, \
  172. { SVM_EXIT_NMI, "nmi" }, \
  173. { SVM_EXIT_SMI, "smi" }, \
  174. { SVM_EXIT_INIT, "init" }, \
  175. { SVM_EXIT_VINTR, "vintr" }, \
  176. { SVM_EXIT_CR0_SEL_WRITE, "cr0_sel_write" }, \
  177. { SVM_EXIT_IDTR_READ, "read_idtr" }, \
  178. { SVM_EXIT_GDTR_READ, "read_gdtr" }, \
  179. { SVM_EXIT_LDTR_READ, "read_ldtr" }, \
  180. { SVM_EXIT_TR_READ, "read_rt" }, \
  181. { SVM_EXIT_IDTR_WRITE, "write_idtr" }, \
  182. { SVM_EXIT_GDTR_WRITE, "write_gdtr" }, \
  183. { SVM_EXIT_LDTR_WRITE, "write_ldtr" }, \
  184. { SVM_EXIT_TR_WRITE, "write_rt" }, \
  185. { SVM_EXIT_RDTSC, "rdtsc" }, \
  186. { SVM_EXIT_RDPMC, "rdpmc" }, \
  187. { SVM_EXIT_PUSHF, "pushf" }, \
  188. { SVM_EXIT_POPF, "popf" }, \
  189. { SVM_EXIT_CPUID, "cpuid" }, \
  190. { SVM_EXIT_RSM, "rsm" }, \
  191. { SVM_EXIT_IRET, "iret" }, \
  192. { SVM_EXIT_SWINT, "swint" }, \
  193. { SVM_EXIT_INVD, "invd" }, \
  194. { SVM_EXIT_PAUSE, "pause" }, \
  195. { SVM_EXIT_HLT, "hlt" }, \
  196. { SVM_EXIT_INVLPG, "invlpg" }, \
  197. { SVM_EXIT_INVLPGA, "invlpga" }, \
  198. { SVM_EXIT_IOIO, "io" }, \
  199. { SVM_EXIT_MSR, "msr" }, \
  200. { SVM_EXIT_TASK_SWITCH, "task_switch" }, \
  201. { SVM_EXIT_FERR_FREEZE, "ferr_freeze" }, \
  202. { SVM_EXIT_SHUTDOWN, "shutdown" }, \
  203. { SVM_EXIT_VMRUN, "vmrun" }, \
  204. { SVM_EXIT_VMMCALL, "hypercall" }, \
  205. { SVM_EXIT_VMLOAD, "vmload" }, \
  206. { SVM_EXIT_VMSAVE, "vmsave" }, \
  207. { SVM_EXIT_STGI, "stgi" }, \
  208. { SVM_EXIT_CLGI, "clgi" }, \
  209. { SVM_EXIT_SKINIT, "skinit" }, \
  210. { SVM_EXIT_RDTSCP, "rdtscp" }, \
  211. { SVM_EXIT_ICEBP, "icebp" }, \
  212. { SVM_EXIT_WBINVD, "wbinvd" }, \
  213. { SVM_EXIT_MONITOR, "monitor" }, \
  214. { SVM_EXIT_MWAIT, "mwait" }, \
  215. { SVM_EXIT_XSETBV, "xsetbv" }, \
  216. { SVM_EXIT_EFER_WRITE_TRAP, "write_efer_trap" }, \
  217. { SVM_EXIT_CR0_WRITE_TRAP, "write_cr0_trap" }, \
  218. { SVM_EXIT_CR4_WRITE_TRAP, "write_cr4_trap" }, \
  219. { SVM_EXIT_CR8_WRITE_TRAP, "write_cr8_trap" }, \
  220. { SVM_EXIT_INVPCID, "invpcid" }, \
  221. { SVM_EXIT_NPF, "npf" }, \
  222. { SVM_EXIT_AVIC_INCOMPLETE_IPI, "avic_incomplete_ipi" }, \
  223. { SVM_EXIT_AVIC_UNACCELERATED_ACCESS, "avic_unaccelerated_access" }, \
  224. { SVM_EXIT_VMGEXIT, "vmgexit" }, \
  225. { SVM_VMGEXIT_MMIO_READ, "vmgexit_mmio_read" }, \
  226. { SVM_VMGEXIT_MMIO_WRITE, "vmgexit_mmio_write" }, \
  227. { SVM_VMGEXIT_NMI_COMPLETE, "vmgexit_nmi_complete" }, \
  228. { SVM_VMGEXIT_AP_HLT_LOOP, "vmgexit_ap_hlt_loop" }, \
  229. { SVM_VMGEXIT_AP_JUMP_TABLE, "vmgexit_ap_jump_table" }, \
  230. { SVM_VMGEXIT_PSC, "vmgexit_page_state_change" }, \
  231. { SVM_VMGEXIT_GUEST_REQUEST, "vmgexit_guest_request" }, \
  232. { SVM_VMGEXIT_EXT_GUEST_REQUEST, "vmgexit_ext_guest_request" }, \
  233. { SVM_VMGEXIT_AP_CREATION, "vmgexit_ap_creation" }, \
  234. { SVM_VMGEXIT_HV_FEATURES, "vmgexit_hypervisor_feature" }, \
  235. { SVM_EXIT_ERR, "invalid_guest_state" }
  236. #endif /* __SVM_H */