1c2cedf7bSEduardo Habkost #ifndef __SVM_H 2c2cedf7bSEduardo Habkost #define __SVM_H 3c2cedf7bSEduardo Habkost 4*26bf264eSXiao Guangrong #define SVM_EXIT_READ_CR0 0x000 5*26bf264eSXiao Guangrong #define SVM_EXIT_READ_CR3 0x003 6*26bf264eSXiao Guangrong #define SVM_EXIT_READ_CR4 0x004 7*26bf264eSXiao Guangrong #define SVM_EXIT_READ_CR8 0x008 8*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_CR0 0x010 9*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_CR3 0x013 10*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_CR4 0x014 11*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_CR8 0x018 12*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR0 0x020 13*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR1 0x021 14*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR2 0x022 15*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR3 0x023 16*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR4 0x024 17*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR5 0x025 18*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR6 0x026 19*26bf264eSXiao Guangrong #define SVM_EXIT_READ_DR7 0x027 20*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR0 0x030 21*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR1 0x031 22*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR2 0x032 23*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR3 0x033 24*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR4 0x034 25*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR5 0x035 26*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR6 0x036 27*26bf264eSXiao Guangrong #define SVM_EXIT_WRITE_DR7 0x037 28*26bf264eSXiao Guangrong #define SVM_EXIT_EXCP_BASE 0x040 29*26bf264eSXiao Guangrong #define SVM_EXIT_INTR 0x060 30*26bf264eSXiao Guangrong #define SVM_EXIT_NMI 0x061 31*26bf264eSXiao Guangrong #define SVM_EXIT_SMI 0x062 32*26bf264eSXiao Guangrong #define SVM_EXIT_INIT 0x063 33*26bf264eSXiao Guangrong #define SVM_EXIT_VINTR 0x064 34*26bf264eSXiao Guangrong #define SVM_EXIT_CR0_SEL_WRITE 0x065 35*26bf264eSXiao Guangrong #define SVM_EXIT_IDTR_READ 0x066 36*26bf264eSXiao Guangrong #define SVM_EXIT_GDTR_READ 0x067 37*26bf264eSXiao Guangrong #define SVM_EXIT_LDTR_READ 0x068 38*26bf264eSXiao Guangrong #define SVM_EXIT_TR_READ 0x069 39*26bf264eSXiao Guangrong #define SVM_EXIT_IDTR_WRITE 0x06a 40*26bf264eSXiao Guangrong #define SVM_EXIT_GDTR_WRITE 0x06b 41*26bf264eSXiao Guangrong #define SVM_EXIT_LDTR_WRITE 0x06c 42*26bf264eSXiao Guangrong #define SVM_EXIT_TR_WRITE 0x06d 43*26bf264eSXiao Guangrong #define SVM_EXIT_RDTSC 0x06e 44*26bf264eSXiao Guangrong #define SVM_EXIT_RDPMC 0x06f 45*26bf264eSXiao Guangrong #define SVM_EXIT_PUSHF 0x070 46*26bf264eSXiao Guangrong #define SVM_EXIT_POPF 0x071 47*26bf264eSXiao Guangrong #define SVM_EXIT_CPUID 0x072 48*26bf264eSXiao Guangrong #define SVM_EXIT_RSM 0x073 49*26bf264eSXiao Guangrong #define SVM_EXIT_IRET 0x074 50*26bf264eSXiao Guangrong #define SVM_EXIT_SWINT 0x075 51*26bf264eSXiao Guangrong #define SVM_EXIT_INVD 0x076 52*26bf264eSXiao Guangrong #define SVM_EXIT_PAUSE 0x077 53*26bf264eSXiao Guangrong #define SVM_EXIT_HLT 0x078 54*26bf264eSXiao Guangrong #define SVM_EXIT_INVLPG 0x079 55*26bf264eSXiao Guangrong #define SVM_EXIT_INVLPGA 0x07a 56*26bf264eSXiao Guangrong #define SVM_EXIT_IOIO 0x07b 57*26bf264eSXiao Guangrong #define SVM_EXIT_MSR 0x07c 58*26bf264eSXiao Guangrong #define SVM_EXIT_TASK_SWITCH 0x07d 59*26bf264eSXiao Guangrong #define SVM_EXIT_FERR_FREEZE 0x07e 60*26bf264eSXiao Guangrong #define SVM_EXIT_SHUTDOWN 0x07f 61*26bf264eSXiao Guangrong #define SVM_EXIT_VMRUN 0x080 62*26bf264eSXiao Guangrong #define SVM_EXIT_VMMCALL 0x081 63*26bf264eSXiao Guangrong #define SVM_EXIT_VMLOAD 0x082 64*26bf264eSXiao Guangrong #define SVM_EXIT_VMSAVE 0x083 65*26bf264eSXiao Guangrong #define SVM_EXIT_STGI 0x084 66*26bf264eSXiao Guangrong #define SVM_EXIT_CLGI 0x085 67*26bf264eSXiao Guangrong #define SVM_EXIT_SKINIT 0x086 68*26bf264eSXiao Guangrong #define SVM_EXIT_RDTSCP 0x087 69*26bf264eSXiao Guangrong #define SVM_EXIT_ICEBP 0x088 70*26bf264eSXiao Guangrong #define SVM_EXIT_WBINVD 0x089 71*26bf264eSXiao Guangrong #define SVM_EXIT_MONITOR 0x08a 72*26bf264eSXiao Guangrong #define SVM_EXIT_MWAIT 0x08b 73*26bf264eSXiao Guangrong #define SVM_EXIT_MWAIT_COND 0x08c 74*26bf264eSXiao Guangrong #define SVM_EXIT_XSETBV 0x08d 75*26bf264eSXiao Guangrong #define SVM_EXIT_NPF 0x400 76*26bf264eSXiao Guangrong 77*26bf264eSXiao Guangrong #define SVM_EXIT_ERR -1 78*26bf264eSXiao Guangrong 79*26bf264eSXiao Guangrong #define SVM_EXIT_REASONS \ 80*26bf264eSXiao Guangrong { SVM_EXIT_READ_CR0, "read_cr0" }, \ 81*26bf264eSXiao Guangrong { SVM_EXIT_READ_CR3, "read_cr3" }, \ 82*26bf264eSXiao Guangrong { SVM_EXIT_READ_CR4, "read_cr4" }, \ 83*26bf264eSXiao Guangrong { SVM_EXIT_READ_CR8, "read_cr8" }, \ 84*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_CR0, "write_cr0" }, \ 85*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_CR3, "write_cr3" }, \ 86*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_CR4, "write_cr4" }, \ 87*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_CR8, "write_cr8" }, \ 88*26bf264eSXiao Guangrong { SVM_EXIT_READ_DR0, "read_dr0" }, \ 89*26bf264eSXiao Guangrong { SVM_EXIT_READ_DR1, "read_dr1" }, \ 90*26bf264eSXiao Guangrong { SVM_EXIT_READ_DR2, "read_dr2" }, \ 91*26bf264eSXiao Guangrong { SVM_EXIT_READ_DR3, "read_dr3" }, \ 92*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR0, "write_dr0" }, \ 93*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR1, "write_dr1" }, \ 94*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR2, "write_dr2" }, \ 95*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR3, "write_dr3" }, \ 96*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR5, "write_dr5" }, \ 97*26bf264eSXiao Guangrong { SVM_EXIT_WRITE_DR7, "write_dr7" }, \ 98*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + DB_VECTOR, "DB excp" }, \ 99*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + BP_VECTOR, "BP excp" }, \ 100*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + UD_VECTOR, "UD excp" }, \ 101*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + PF_VECTOR, "PF excp" }, \ 102*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + NM_VECTOR, "NM excp" }, \ 103*26bf264eSXiao Guangrong { SVM_EXIT_EXCP_BASE + MC_VECTOR, "MC excp" }, \ 104*26bf264eSXiao Guangrong { SVM_EXIT_INTR, "interrupt" }, \ 105*26bf264eSXiao Guangrong { SVM_EXIT_NMI, "nmi" }, \ 106*26bf264eSXiao Guangrong { SVM_EXIT_SMI, "smi" }, \ 107*26bf264eSXiao Guangrong { SVM_EXIT_INIT, "init" }, \ 108*26bf264eSXiao Guangrong { SVM_EXIT_VINTR, "vintr" }, \ 109*26bf264eSXiao Guangrong { SVM_EXIT_CPUID, "cpuid" }, \ 110*26bf264eSXiao Guangrong { SVM_EXIT_INVD, "invd" }, \ 111*26bf264eSXiao Guangrong { SVM_EXIT_HLT, "hlt" }, \ 112*26bf264eSXiao Guangrong { SVM_EXIT_INVLPG, "invlpg" }, \ 113*26bf264eSXiao Guangrong { SVM_EXIT_INVLPGA, "invlpga" }, \ 114*26bf264eSXiao Guangrong { SVM_EXIT_IOIO, "io" }, \ 115*26bf264eSXiao Guangrong { SVM_EXIT_MSR, "msr" }, \ 116*26bf264eSXiao Guangrong { SVM_EXIT_TASK_SWITCH, "task_switch" }, \ 117*26bf264eSXiao Guangrong { SVM_EXIT_SHUTDOWN, "shutdown" }, \ 118*26bf264eSXiao Guangrong { SVM_EXIT_VMRUN, "vmrun" }, \ 119*26bf264eSXiao Guangrong { SVM_EXIT_VMMCALL, "hypercall" }, \ 120*26bf264eSXiao Guangrong { SVM_EXIT_VMLOAD, "vmload" }, \ 121*26bf264eSXiao Guangrong { SVM_EXIT_VMSAVE, "vmsave" }, \ 122*26bf264eSXiao Guangrong { SVM_EXIT_STGI, "stgi" }, \ 123*26bf264eSXiao Guangrong { SVM_EXIT_CLGI, "clgi" }, \ 124*26bf264eSXiao Guangrong { SVM_EXIT_SKINIT, "skinit" }, \ 125*26bf264eSXiao Guangrong { SVM_EXIT_WBINVD, "wbinvd" }, \ 126*26bf264eSXiao Guangrong { SVM_EXIT_MONITOR, "monitor" }, \ 127*26bf264eSXiao Guangrong { SVM_EXIT_MWAIT, "mwait" }, \ 128*26bf264eSXiao Guangrong { SVM_EXIT_XSETBV, "xsetbv" }, \ 129*26bf264eSXiao Guangrong { SVM_EXIT_NPF, "npf" } 130*26bf264eSXiao Guangrong 131*26bf264eSXiao Guangrong #ifdef __KERNEL__ 132*26bf264eSXiao Guangrong 133c2cedf7bSEduardo Habkost enum { 134c2cedf7bSEduardo Habkost INTERCEPT_INTR, 135c2cedf7bSEduardo Habkost INTERCEPT_NMI, 136c2cedf7bSEduardo Habkost INTERCEPT_SMI, 137c2cedf7bSEduardo Habkost INTERCEPT_INIT, 138c2cedf7bSEduardo Habkost INTERCEPT_VINTR, 139c2cedf7bSEduardo Habkost INTERCEPT_SELECTIVE_CR0, 140c2cedf7bSEduardo Habkost INTERCEPT_STORE_IDTR, 141c2cedf7bSEduardo Habkost INTERCEPT_STORE_GDTR, 142c2cedf7bSEduardo Habkost INTERCEPT_STORE_LDTR, 143c2cedf7bSEduardo Habkost INTERCEPT_STORE_TR, 144c2cedf7bSEduardo Habkost INTERCEPT_LOAD_IDTR, 145c2cedf7bSEduardo Habkost INTERCEPT_LOAD_GDTR, 146c2cedf7bSEduardo Habkost INTERCEPT_LOAD_LDTR, 147c2cedf7bSEduardo Habkost INTERCEPT_LOAD_TR, 148c2cedf7bSEduardo Habkost INTERCEPT_RDTSC, 149c2cedf7bSEduardo Habkost INTERCEPT_RDPMC, 150c2cedf7bSEduardo Habkost INTERCEPT_PUSHF, 151c2cedf7bSEduardo Habkost INTERCEPT_POPF, 152c2cedf7bSEduardo Habkost INTERCEPT_CPUID, 153c2cedf7bSEduardo Habkost INTERCEPT_RSM, 154c2cedf7bSEduardo Habkost INTERCEPT_IRET, 155c2cedf7bSEduardo Habkost INTERCEPT_INTn, 156c2cedf7bSEduardo Habkost INTERCEPT_INVD, 157c2cedf7bSEduardo Habkost INTERCEPT_PAUSE, 158c2cedf7bSEduardo Habkost INTERCEPT_HLT, 159c2cedf7bSEduardo Habkost INTERCEPT_INVLPG, 160c2cedf7bSEduardo Habkost INTERCEPT_INVLPGA, 161c2cedf7bSEduardo Habkost INTERCEPT_IOIO_PROT, 162c2cedf7bSEduardo Habkost INTERCEPT_MSR_PROT, 163c2cedf7bSEduardo Habkost INTERCEPT_TASK_SWITCH, 164c2cedf7bSEduardo Habkost INTERCEPT_FERR_FREEZE, 165c2cedf7bSEduardo Habkost INTERCEPT_SHUTDOWN, 166c2cedf7bSEduardo Habkost INTERCEPT_VMRUN, 167c2cedf7bSEduardo Habkost INTERCEPT_VMMCALL, 168c2cedf7bSEduardo Habkost INTERCEPT_VMLOAD, 169c2cedf7bSEduardo Habkost INTERCEPT_VMSAVE, 170c2cedf7bSEduardo Habkost INTERCEPT_STGI, 171c2cedf7bSEduardo Habkost INTERCEPT_CLGI, 172c2cedf7bSEduardo Habkost INTERCEPT_SKINIT, 173c2cedf7bSEduardo Habkost INTERCEPT_RDTSCP, 174c2cedf7bSEduardo Habkost INTERCEPT_ICEBP, 175c2cedf7bSEduardo Habkost INTERCEPT_WBINVD, 176c2cedf7bSEduardo Habkost INTERCEPT_MONITOR, 177c2cedf7bSEduardo Habkost INTERCEPT_MWAIT, 178c2cedf7bSEduardo Habkost INTERCEPT_MWAIT_COND, 17981dd35d4SJoerg Roedel INTERCEPT_XSETBV, 180c2cedf7bSEduardo Habkost }; 181c2cedf7bSEduardo Habkost 182c2cedf7bSEduardo Habkost 183c2cedf7bSEduardo Habkost struct __attribute__ ((__packed__)) vmcb_control_area { 1844ee546b4SRoedel, Joerg u32 intercept_cr; 1853aed041aSJoerg Roedel u32 intercept_dr; 186c2cedf7bSEduardo Habkost u32 intercept_exceptions; 187c2cedf7bSEduardo Habkost u64 intercept; 188565d0998SMark Langsdorf u8 reserved_1[42]; 189565d0998SMark Langsdorf u16 pause_filter_count; 190c2cedf7bSEduardo Habkost u64 iopm_base_pa; 191c2cedf7bSEduardo Habkost u64 msrpm_base_pa; 192c2cedf7bSEduardo Habkost u64 tsc_offset; 193c2cedf7bSEduardo Habkost u32 asid; 194c2cedf7bSEduardo Habkost u8 tlb_ctl; 195c2cedf7bSEduardo Habkost u8 reserved_2[3]; 196c2cedf7bSEduardo Habkost u32 int_ctl; 197c2cedf7bSEduardo Habkost u32 int_vector; 198c2cedf7bSEduardo Habkost u32 int_state; 199c2cedf7bSEduardo Habkost u8 reserved_3[4]; 200c2cedf7bSEduardo Habkost u32 exit_code; 201c2cedf7bSEduardo Habkost u32 exit_code_hi; 202c2cedf7bSEduardo Habkost u64 exit_info_1; 203c2cedf7bSEduardo Habkost u64 exit_info_2; 204c2cedf7bSEduardo Habkost u32 exit_int_info; 205c2cedf7bSEduardo Habkost u32 exit_int_info_err; 206c2cedf7bSEduardo Habkost u64 nested_ctl; 207c2cedf7bSEduardo Habkost u8 reserved_4[16]; 208c2cedf7bSEduardo Habkost u32 event_inj; 209c2cedf7bSEduardo Habkost u32 event_inj_err; 210c2cedf7bSEduardo Habkost u64 nested_cr3; 211c2cedf7bSEduardo Habkost u64 lbr_ctl; 2128d28fec4SRoedel, Joerg u32 clean; 2138d28fec4SRoedel, Joerg u32 reserved_5; 2146bc31bdcSAndre Przywara u64 next_rip; 215dc25e89eSAndre Przywara u8 insn_len; 216dc25e89eSAndre Przywara u8 insn_bytes[15]; 217dc25e89eSAndre Przywara u8 reserved_6[800]; 218c2cedf7bSEduardo Habkost }; 219c2cedf7bSEduardo Habkost 220c2cedf7bSEduardo Habkost 221c2cedf7bSEduardo Habkost #define TLB_CONTROL_DO_NOTHING 0 222c2cedf7bSEduardo Habkost #define TLB_CONTROL_FLUSH_ALL_ASID 1 22338e5e92fSJoerg Roedel #define TLB_CONTROL_FLUSH_ASID 3 22438e5e92fSJoerg Roedel #define TLB_CONTROL_FLUSH_ASID_LOCAL 7 225c2cedf7bSEduardo Habkost 226c2cedf7bSEduardo Habkost #define V_TPR_MASK 0x0f 227c2cedf7bSEduardo Habkost 228c2cedf7bSEduardo Habkost #define V_IRQ_SHIFT 8 229c2cedf7bSEduardo Habkost #define V_IRQ_MASK (1 << V_IRQ_SHIFT) 230c2cedf7bSEduardo Habkost 231c2cedf7bSEduardo Habkost #define V_INTR_PRIO_SHIFT 16 232c2cedf7bSEduardo Habkost #define V_INTR_PRIO_MASK (0x0f << V_INTR_PRIO_SHIFT) 233c2cedf7bSEduardo Habkost 234c2cedf7bSEduardo Habkost #define V_IGN_TPR_SHIFT 20 235c2cedf7bSEduardo Habkost #define V_IGN_TPR_MASK (1 << V_IGN_TPR_SHIFT) 236c2cedf7bSEduardo Habkost 237c2cedf7bSEduardo Habkost #define V_INTR_MASKING_SHIFT 24 238c2cedf7bSEduardo Habkost #define V_INTR_MASKING_MASK (1 << V_INTR_MASKING_SHIFT) 239c2cedf7bSEduardo Habkost 240c2cedf7bSEduardo Habkost #define SVM_INTERRUPT_SHADOW_MASK 1 241c2cedf7bSEduardo Habkost 242c2cedf7bSEduardo Habkost #define SVM_IOIO_STR_SHIFT 2 243c2cedf7bSEduardo Habkost #define SVM_IOIO_REP_SHIFT 3 244c2cedf7bSEduardo Habkost #define SVM_IOIO_SIZE_SHIFT 4 245c2cedf7bSEduardo Habkost #define SVM_IOIO_ASIZE_SHIFT 7 246c2cedf7bSEduardo Habkost 247c2cedf7bSEduardo Habkost #define SVM_IOIO_TYPE_MASK 1 248c2cedf7bSEduardo Habkost #define SVM_IOIO_STR_MASK (1 << SVM_IOIO_STR_SHIFT) 249c2cedf7bSEduardo Habkost #define SVM_IOIO_REP_MASK (1 << SVM_IOIO_REP_SHIFT) 250c2cedf7bSEduardo Habkost #define SVM_IOIO_SIZE_MASK (7 << SVM_IOIO_SIZE_SHIFT) 251c2cedf7bSEduardo Habkost #define SVM_IOIO_ASIZE_MASK (7 << SVM_IOIO_ASIZE_SHIFT) 252c2cedf7bSEduardo Habkost 2534a810181SJoerg Roedel #define SVM_VM_CR_VALID_MASK 0x001fULL 2544a810181SJoerg Roedel #define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL 2554a810181SJoerg Roedel #define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL 2564a810181SJoerg Roedel 257c2cedf7bSEduardo Habkost struct __attribute__ ((__packed__)) vmcb_seg { 258c2cedf7bSEduardo Habkost u16 selector; 259c2cedf7bSEduardo Habkost u16 attrib; 260c2cedf7bSEduardo Habkost u32 limit; 261c2cedf7bSEduardo Habkost u64 base; 262c2cedf7bSEduardo Habkost }; 263c2cedf7bSEduardo Habkost 264c2cedf7bSEduardo Habkost struct __attribute__ ((__packed__)) vmcb_save_area { 265c2cedf7bSEduardo Habkost struct vmcb_seg es; 266c2cedf7bSEduardo Habkost struct vmcb_seg cs; 267c2cedf7bSEduardo Habkost struct vmcb_seg ss; 268c2cedf7bSEduardo Habkost struct vmcb_seg ds; 269c2cedf7bSEduardo Habkost struct vmcb_seg fs; 270c2cedf7bSEduardo Habkost struct vmcb_seg gs; 271c2cedf7bSEduardo Habkost struct vmcb_seg gdtr; 272c2cedf7bSEduardo Habkost struct vmcb_seg ldtr; 273c2cedf7bSEduardo Habkost struct vmcb_seg idtr; 274c2cedf7bSEduardo Habkost struct vmcb_seg tr; 275c2cedf7bSEduardo Habkost u8 reserved_1[43]; 276c2cedf7bSEduardo Habkost u8 cpl; 277c2cedf7bSEduardo Habkost u8 reserved_2[4]; 278c2cedf7bSEduardo Habkost u64 efer; 279c2cedf7bSEduardo Habkost u8 reserved_3[112]; 280c2cedf7bSEduardo Habkost u64 cr4; 281c2cedf7bSEduardo Habkost u64 cr3; 282c2cedf7bSEduardo Habkost u64 cr0; 283c2cedf7bSEduardo Habkost u64 dr7; 284c2cedf7bSEduardo Habkost u64 dr6; 285c2cedf7bSEduardo Habkost u64 rflags; 286c2cedf7bSEduardo Habkost u64 rip; 287c2cedf7bSEduardo Habkost u8 reserved_4[88]; 288c2cedf7bSEduardo Habkost u64 rsp; 289c2cedf7bSEduardo Habkost u8 reserved_5[24]; 290c2cedf7bSEduardo Habkost u64 rax; 291c2cedf7bSEduardo Habkost u64 star; 292c2cedf7bSEduardo Habkost u64 lstar; 293c2cedf7bSEduardo Habkost u64 cstar; 294c2cedf7bSEduardo Habkost u64 sfmask; 295c2cedf7bSEduardo Habkost u64 kernel_gs_base; 296c2cedf7bSEduardo Habkost u64 sysenter_cs; 297c2cedf7bSEduardo Habkost u64 sysenter_esp; 298c2cedf7bSEduardo Habkost u64 sysenter_eip; 299c2cedf7bSEduardo Habkost u64 cr2; 300c2cedf7bSEduardo Habkost u8 reserved_6[32]; 301c2cedf7bSEduardo Habkost u64 g_pat; 302c2cedf7bSEduardo Habkost u64 dbgctl; 303c2cedf7bSEduardo Habkost u64 br_from; 304c2cedf7bSEduardo Habkost u64 br_to; 305c2cedf7bSEduardo Habkost u64 last_excp_from; 306c2cedf7bSEduardo Habkost u64 last_excp_to; 307c2cedf7bSEduardo Habkost }; 308c2cedf7bSEduardo Habkost 309c2cedf7bSEduardo Habkost struct __attribute__ ((__packed__)) vmcb { 310c2cedf7bSEduardo Habkost struct vmcb_control_area control; 311c2cedf7bSEduardo Habkost struct vmcb_save_area save; 312c2cedf7bSEduardo Habkost }; 313c2cedf7bSEduardo Habkost 314c2cedf7bSEduardo Habkost #define SVM_CPUID_FEATURE_SHIFT 2 315c2cedf7bSEduardo Habkost #define SVM_CPUID_FUNC 0x8000000a 316c2cedf7bSEduardo Habkost 317c2cedf7bSEduardo Habkost #define SVM_VM_CR_SVM_DISABLE 4 318c2cedf7bSEduardo Habkost 319c2cedf7bSEduardo Habkost #define SVM_SELECTOR_S_SHIFT 4 320c2cedf7bSEduardo Habkost #define SVM_SELECTOR_DPL_SHIFT 5 321c2cedf7bSEduardo Habkost #define SVM_SELECTOR_P_SHIFT 7 322c2cedf7bSEduardo Habkost #define SVM_SELECTOR_AVL_SHIFT 8 323c2cedf7bSEduardo Habkost #define SVM_SELECTOR_L_SHIFT 9 324c2cedf7bSEduardo Habkost #define SVM_SELECTOR_DB_SHIFT 10 325c2cedf7bSEduardo Habkost #define SVM_SELECTOR_G_SHIFT 11 326c2cedf7bSEduardo Habkost 327c2cedf7bSEduardo Habkost #define SVM_SELECTOR_TYPE_MASK (0xf) 328c2cedf7bSEduardo Habkost #define SVM_SELECTOR_S_MASK (1 << SVM_SELECTOR_S_SHIFT) 329c2cedf7bSEduardo Habkost #define SVM_SELECTOR_DPL_MASK (3 << SVM_SELECTOR_DPL_SHIFT) 330c2cedf7bSEduardo Habkost #define SVM_SELECTOR_P_MASK (1 << SVM_SELECTOR_P_SHIFT) 331c2cedf7bSEduardo Habkost #define SVM_SELECTOR_AVL_MASK (1 << SVM_SELECTOR_AVL_SHIFT) 332c2cedf7bSEduardo Habkost #define SVM_SELECTOR_L_MASK (1 << SVM_SELECTOR_L_SHIFT) 333c2cedf7bSEduardo Habkost #define SVM_SELECTOR_DB_MASK (1 << SVM_SELECTOR_DB_SHIFT) 334c2cedf7bSEduardo Habkost #define SVM_SELECTOR_G_MASK (1 << SVM_SELECTOR_G_SHIFT) 335c2cedf7bSEduardo Habkost 336c2cedf7bSEduardo Habkost #define SVM_SELECTOR_WRITE_MASK (1 << 1) 337c2cedf7bSEduardo Habkost #define SVM_SELECTOR_READ_MASK SVM_SELECTOR_WRITE_MASK 338c2cedf7bSEduardo Habkost #define SVM_SELECTOR_CODE_MASK (1 << 3) 339c2cedf7bSEduardo Habkost 3404ee546b4SRoedel, Joerg #define INTERCEPT_CR0_READ 0 3414ee546b4SRoedel, Joerg #define INTERCEPT_CR3_READ 3 3424ee546b4SRoedel, Joerg #define INTERCEPT_CR4_READ 4 3434ee546b4SRoedel, Joerg #define INTERCEPT_CR8_READ 8 3444ee546b4SRoedel, Joerg #define INTERCEPT_CR0_WRITE (16 + 0) 3454ee546b4SRoedel, Joerg #define INTERCEPT_CR3_WRITE (16 + 3) 3464ee546b4SRoedel, Joerg #define INTERCEPT_CR4_WRITE (16 + 4) 3474ee546b4SRoedel, Joerg #define INTERCEPT_CR8_WRITE (16 + 8) 348c2cedf7bSEduardo Habkost 3493aed041aSJoerg Roedel #define INTERCEPT_DR0_READ 0 3503aed041aSJoerg Roedel #define INTERCEPT_DR1_READ 1 3513aed041aSJoerg Roedel #define INTERCEPT_DR2_READ 2 3523aed041aSJoerg Roedel #define INTERCEPT_DR3_READ 3 3533aed041aSJoerg Roedel #define INTERCEPT_DR4_READ 4 3543aed041aSJoerg Roedel #define INTERCEPT_DR5_READ 5 3553aed041aSJoerg Roedel #define INTERCEPT_DR6_READ 6 3563aed041aSJoerg Roedel #define INTERCEPT_DR7_READ 7 3573aed041aSJoerg Roedel #define INTERCEPT_DR0_WRITE (16 + 0) 3583aed041aSJoerg Roedel #define INTERCEPT_DR1_WRITE (16 + 1) 3593aed041aSJoerg Roedel #define INTERCEPT_DR2_WRITE (16 + 2) 3603aed041aSJoerg Roedel #define INTERCEPT_DR3_WRITE (16 + 3) 3613aed041aSJoerg Roedel #define INTERCEPT_DR4_WRITE (16 + 4) 3623aed041aSJoerg Roedel #define INTERCEPT_DR5_WRITE (16 + 5) 3633aed041aSJoerg Roedel #define INTERCEPT_DR6_WRITE (16 + 6) 3643aed041aSJoerg Roedel #define INTERCEPT_DR7_WRITE (16 + 7) 365c2cedf7bSEduardo Habkost 366c2cedf7bSEduardo Habkost #define SVM_EVTINJ_VEC_MASK 0xff 367c2cedf7bSEduardo Habkost 368c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_SHIFT 8 369c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_MASK (7 << SVM_EVTINJ_TYPE_SHIFT) 370c2cedf7bSEduardo Habkost 371c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_INTR (0 << SVM_EVTINJ_TYPE_SHIFT) 372c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_NMI (2 << SVM_EVTINJ_TYPE_SHIFT) 373c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_EXEPT (3 << SVM_EVTINJ_TYPE_SHIFT) 374c2cedf7bSEduardo Habkost #define SVM_EVTINJ_TYPE_SOFT (4 << SVM_EVTINJ_TYPE_SHIFT) 375c2cedf7bSEduardo Habkost 376c2cedf7bSEduardo Habkost #define SVM_EVTINJ_VALID (1 << 31) 377c2cedf7bSEduardo Habkost #define SVM_EVTINJ_VALID_ERR (1 << 11) 378c2cedf7bSEduardo Habkost 379c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_VEC_MASK SVM_EVTINJ_VEC_MASK 38064a7ec06SGleb Natapov #define SVM_EXITINTINFO_TYPE_MASK SVM_EVTINJ_TYPE_MASK 381c2cedf7bSEduardo Habkost 382c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_TYPE_INTR SVM_EVTINJ_TYPE_INTR 383c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_TYPE_NMI SVM_EVTINJ_TYPE_NMI 384c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_TYPE_EXEPT SVM_EVTINJ_TYPE_EXEPT 385c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_TYPE_SOFT SVM_EVTINJ_TYPE_SOFT 386c2cedf7bSEduardo Habkost 387c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_VALID SVM_EVTINJ_VALID 388c2cedf7bSEduardo Habkost #define SVM_EXITINTINFO_VALID_ERR SVM_EVTINJ_VALID_ERR 389c2cedf7bSEduardo Habkost 390c2cedf7bSEduardo Habkost #define SVM_EXITINFOSHIFT_TS_REASON_IRET 36 391c2cedf7bSEduardo Habkost #define SVM_EXITINFOSHIFT_TS_REASON_JMP 38 392e269fb21SJan Kiszka #define SVM_EXITINFOSHIFT_TS_HAS_ERROR_CODE 44 393c2cedf7bSEduardo Habkost 3947ff76d58SAndre Przywara #define SVM_EXITINFO_REG_MASK 0x0F 3957ff76d58SAndre Przywara 396dc77270fSAvi Kivity #define SVM_CR0_SELECTIVE_MASK (X86_CR0_TS | X86_CR0_MP) 397c2cedf7bSEduardo Habkost 398c2cedf7bSEduardo Habkost #define SVM_VMLOAD ".byte 0x0f, 0x01, 0xda" 399c2cedf7bSEduardo Habkost #define SVM_VMRUN ".byte 0x0f, 0x01, 0xd8" 400c2cedf7bSEduardo Habkost #define SVM_VMSAVE ".byte 0x0f, 0x01, 0xdb" 401c2cedf7bSEduardo Habkost #define SVM_CLGI ".byte 0x0f, 0x01, 0xdd" 402c2cedf7bSEduardo Habkost #define SVM_STGI ".byte 0x0f, 0x01, 0xdc" 403c2cedf7bSEduardo Habkost #define SVM_INVLPGA ".byte 0x0f, 0x01, 0xdf" 404c2cedf7bSEduardo Habkost 405c2cedf7bSEduardo Habkost #endif 406c2cedf7bSEduardo Habkost 407*26bf264eSXiao Guangrong #endif 408