1 /* (c) 2008, Peter Dinda <pdinda@northwestern.edu> */
2 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
3 /* (c) 2008, The V3VEE Project <http://www.v3vee.org> */
10 #include <palacios/vmm_types.h>
11 #include <palacios/vmcs.h>
13 #define IA32_FEATURE_CONTROL_MSR ((unsigned int)0x3a)
14 #define IA32_VMX_BASIC_MSR ((unsigned int)0x480)
15 #define IA32_VMX_PINBASED_CTLS_MSR ((unsigned int)0x481)
16 #define IA32_VMX_PROCBASED_CTLS_MSR ((unsigned int)0x482)
17 #define IA32_VMX_EXIT_CTLS_MSR ((unsigned int)0x483)
18 #define IA32_VMX_ENTRY_CTLS_MSR ((unsigned int)0x484)
19 #define IA32_VMX_MISC_MSR ((unsigned int)0x485)
20 #define IA32_VMX_CR0_FIXED0_MSR ((unsigned int)0x486)
21 #define IA32_VMX_CR0_FIXED1_MSR ((unsigned int)0x487)
22 #define IA32_VMX_CR4_FIXED0_MSR ((unsigned int)0x488)
23 #define IA32_VMX_CR4_FIXED1_MSR ((unsigned int)0x489)
24 #define IA32_VMX_VMCS_ENUM_MSR ((unsigned ing)0x48A)
27 #define VMX_FAIL_INVALID 1
28 #define VMX_FAIL_VALID 2
31 #define FEATURE_CONTROL_LOCK (1)
32 #define FEATURE_CONTROL_VMXON (1<<2)
33 #define FEATURE_CONTROL_VALID ( FEATURE_CONTROL_LOCK | FEATURE_CONTROL_VMXON)
36 #define CPUID_1_ECX_VTXFLAG (1<<5)
42 typedef void VmxOnRegion;
47 #define PACKED __attribute__((packed))
57 uint_t revision PACKED ;
58 uint_t regionSize : 13 PACKED ;
59 uint_t rsvd1 : 4 PACKED ; // Always 0
60 uint_t physWidth : 1 PACKED ;
61 uint_t smm : 1 PACKED ; // Always 1
62 uint_t memType : 4 PACKED ;
63 uint_t rsvd2 : 10 PACKED ; // Always 0
67 struct MSR_REGS regs PACKED;
68 struct VMX_BASIC vmxBasic PACKED;
79 enum VMState { VM_VMXASSIST_STARTUP, VM_VMXASSIST_V8086_BIOS, VM_VMXASSIST_V8086, VM_NORMAL };
83 struct VMXRegs registers;
84 struct VMDescriptor descriptor;
86 struct VMCS *vmcsregion;
87 struct VmxOnRegion *vmxonregion;
91 enum InstructionType { VM_UNKNOWN_INST, VM_MOV_TO_CR0 } ;
94 enum InstructionType type;
103 void DecodeCurrentInstruction(struct VM *vm, struct Instruction *out);
106 int is_vmx_capable();
108 VmxOnRegion * Init_VMX();
109 VmxOnRegion * CreateVmxOnRegion();
111 int VMLaunch(struct VMDescriptor *vm);
114 int Do_VMM(struct VMXRegs regs);
117 #endif // ! __V3VEE__