Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


almost done with the namespace protection via -D__V3VEE__ header wrappers
[palacios.git] / palacios / include / palacios / vmx.h
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> */
4
5 #ifndef __VMX_H
6 #define __VMX_H
7
8 #ifdef __V3VEE__
9
10 #include <palacios/vmm_types.h>
11 #include <palacios/vmcs.h>
12
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)
25
26 #define VMX_SUCCESS         0
27 #define VMX_FAIL_INVALID   1
28 #define VMX_FAIL_VALID     2
29 #define VMM_ERROR          3
30
31 #define FEATURE_CONTROL_LOCK (1)
32 #define FEATURE_CONTROL_VMXON (1<<2)
33 #define FEATURE_CONTROL_VALID ( FEATURE_CONTROL_LOCK | FEATURE_CONTROL_VMXON)
34
35
36 #define CPUID_1_ECX_VTXFLAG (1<<5)
37
38
39
40
41
42 typedef void VmxOnRegion;
43
44 #if __TINYC__
45 #define PACKED
46 #else
47 #define PACKED __attribute__((packed))
48 #endif
49
50
51 struct MSR_REGS {
52   uint_t low PACKED;
53   uint_t high  PACKED;
54 };
55
56 struct VMX_BASIC {
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
64 };
65
66 union VMX_MSR {
67   struct MSR_REGS regs PACKED;
68   struct VMX_BASIC vmxBasic PACKED;
69 };
70
71
72 struct VMDescriptor {
73   uint_t   entry_ip;
74   uint_t   exit_eip;
75   uint_t   guest_esp;
76 } ;
77
78
79 enum VMState { VM_VMXASSIST_STARTUP, VM_VMXASSIST_V8086_BIOS, VM_VMXASSIST_V8086, VM_NORMAL };
80
81 struct VM {
82   enum VMState        state;
83   struct VMXRegs      registers;
84   struct VMDescriptor descriptor;
85   struct VMCSData     vmcs;
86   struct VMCS         *vmcsregion;
87   struct VmxOnRegion  *vmxonregion;
88 };
89
90
91 enum InstructionType { VM_UNKNOWN_INST, VM_MOV_TO_CR0 } ;
92
93 struct Instruction {
94   enum InstructionType type;
95   uint_t          address;
96   uint_t          size;
97   uint_t          input1;
98   uint_t          input2;
99   uint_t          output;
100 };
101
102
103 void DecodeCurrentInstruction(struct VM *vm, struct Instruction *out);
104
105
106 int is_vmx_capable();
107
108 VmxOnRegion * Init_VMX();
109 VmxOnRegion * CreateVmxOnRegion();
110
111 int VMLaunch(struct VMDescriptor *vm);
112
113
114 int Do_VMM(struct VMXRegs regs);
115
116
117 #endif // ! __V3VEE__
118
119 #endif