1 /* Northwestern University */
2 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
7 #include <palacios/vmm_types.h>
8 #include <palacios/vmcs.h>
10 #define IA32_FEATURE_CONTROL_MSR ((unsigned int)0x3a)
11 #define IA32_VMX_BASIC_MSR ((unsigned int)0x480)
12 #define IA32_VMX_PINBASED_CTLS_MSR ((unsigned int)0x481)
13 #define IA32_VMX_PROCBASED_CTLS_MSR ((unsigned int)0x482)
14 #define IA32_VMX_EXIT_CTLS_MSR ((unsigned int)0x483)
15 #define IA32_VMX_ENTRY_CTLS_MSR ((unsigned int)0x484)
16 #define IA32_VMX_MISC_MSR ((unsigned int)0x485)
17 #define IA32_VMX_CR0_FIXED0_MSR ((unsigned int)0x486)
18 #define IA32_VMX_CR0_FIXED1_MSR ((unsigned int)0x487)
19 #define IA32_VMX_CR4_FIXED0_MSR ((unsigned int)0x488)
20 #define IA32_VMX_CR4_FIXED1_MSR ((unsigned int)0x489)
21 #define IA32_VMX_VMCS_ENUM_MSR ((unsigned ing)0x48A)
24 #define VMX_FAIL_INVALID 1
25 #define VMX_FAIL_VALID 2
28 #define FEATURE_CONTROL_LOCK (1)
29 #define FEATURE_CONTROL_VMXON (1<<2)
30 #define FEATURE_CONTROL_VALID ( FEATURE_CONTROL_LOCK | FEATURE_CONTROL_VMXON)
33 #define CPUID_1_ECX_VTXFLAG (1<<5)
39 typedef void VmxOnRegion;
44 #define PACKED __attribute__((packed))
54 uint_t revision PACKED ;
55 uint_t regionSize : 13 PACKED ;
56 uint_t rsvd1 : 4 PACKED ; // Always 0
57 uint_t physWidth : 1 PACKED ;
58 uint_t smm : 1 PACKED ; // Always 1
59 uint_t memType : 4 PACKED ;
60 uint_t rsvd2 : 10 PACKED ; // Always 0
64 struct MSR_REGS regs PACKED;
65 struct VMX_BASIC vmxBasic PACKED;
76 enum VMState { VM_VMXASSIST_STARTUP, VM_VMXASSIST_V8086_BIOS, VM_VMXASSIST_V8086, VM_NORMAL };
80 struct VMXRegs registers;
81 struct VMDescriptor descriptor;
83 struct VMCS *vmcsregion;
84 struct VmxOnRegion *vmxonregion;
88 enum InstructionType { VM_UNKNOWN_INST, VM_MOV_TO_CR0 } ;
91 enum InstructionType type;
100 void DecodeCurrentInstruction(struct VM *vm, struct Instruction *out);
103 int is_vmx_capable();
105 VmxOnRegion * Init_VMX();
106 VmxOnRegion * CreateVmxOnRegion();
108 int VMLaunch(struct VMDescriptor *vm);
111 int Do_VMM(struct VMXRegs regs);