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> */
8 #include <palacios/vmm_types.h>
9 #include <palacios/vmcs.h>
11 #define IA32_FEATURE_CONTROL_MSR ((unsigned int)0x3a)
12 #define IA32_VMX_BASIC_MSR ((unsigned int)0x480)
13 #define IA32_VMX_PINBASED_CTLS_MSR ((unsigned int)0x481)
14 #define IA32_VMX_PROCBASED_CTLS_MSR ((unsigned int)0x482)
15 #define IA32_VMX_EXIT_CTLS_MSR ((unsigned int)0x483)
16 #define IA32_VMX_ENTRY_CTLS_MSR ((unsigned int)0x484)
17 #define IA32_VMX_MISC_MSR ((unsigned int)0x485)
18 #define IA32_VMX_CR0_FIXED0_MSR ((unsigned int)0x486)
19 #define IA32_VMX_CR0_FIXED1_MSR ((unsigned int)0x487)
20 #define IA32_VMX_CR4_FIXED0_MSR ((unsigned int)0x488)
21 #define IA32_VMX_CR4_FIXED1_MSR ((unsigned int)0x489)
22 #define IA32_VMX_VMCS_ENUM_MSR ((unsigned ing)0x48A)
25 #define VMX_FAIL_INVALID 1
26 #define VMX_FAIL_VALID 2
29 #define FEATURE_CONTROL_LOCK (1)
30 #define FEATURE_CONTROL_VMXON (1<<2)
31 #define FEATURE_CONTROL_VALID ( FEATURE_CONTROL_LOCK | FEATURE_CONTROL_VMXON)
34 #define CPUID_1_ECX_VTXFLAG (1<<5)
40 typedef void VmxOnRegion;
45 #define PACKED __attribute__((packed))
55 uint_t revision PACKED ;
56 uint_t regionSize : 13 PACKED ;
57 uint_t rsvd1 : 4 PACKED ; // Always 0
58 uint_t physWidth : 1 PACKED ;
59 uint_t smm : 1 PACKED ; // Always 1
60 uint_t memType : 4 PACKED ;
61 uint_t rsvd2 : 10 PACKED ; // Always 0
65 struct MSR_REGS regs PACKED;
66 struct VMX_BASIC vmxBasic PACKED;
77 enum VMState { VM_VMXASSIST_STARTUP, VM_VMXASSIST_V8086_BIOS, VM_VMXASSIST_V8086, VM_NORMAL };
81 struct VMXRegs registers;
82 struct VMDescriptor descriptor;
84 struct VMCS *vmcsregion;
85 struct VmxOnRegion *vmxonregion;
89 enum InstructionType { VM_UNKNOWN_INST, VM_MOV_TO_CR0 } ;
92 enum InstructionType type;
101 void DecodeCurrentInstruction(struct VM *vm, struct Instruction *out);
104 int is_vmx_capable();
106 VmxOnRegion * Init_VMX();
107 VmxOnRegion * CreateVmxOnRegion();
109 int VMLaunch(struct VMDescriptor *vm);
112 int Do_VMM(struct VMXRegs regs);