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.


vmx updates
[palacios.git] / palacios / include / palacios / vmx.h
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Peter Dinda <pdinda@northwestern.edu> 
11  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
12  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
13  * All rights reserved.
14  *
15  * Author: Peter Dinda <pdinda@northwestern.edu>
16  * Author: Jack Lange <jarusl@cs.northwestern.edu>
17  *
18  * This is free software.  You are permitted to use,
19  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20  */
21
22
23 #ifndef __VMX_H__
24 #define __VMX_H__
25
26 #ifdef __V3VEE__
27
28 #include <palacios/vmm_types.h>
29 #include <palacios/vmcs.h>
30 #include <palacios/vmm.h>
31 #include <palacios/vm_guest.h>
32
33
34 #define VMX_SUCCESS        0
35 #define VMX_FAIL_INVALID   1
36 #define VMX_FAIL_VALID     2
37 #define VMM_ERROR          3
38
39
40
41
42
43 struct vmx_pin_ctrls {
44     union {
45         uint32_t value;
46         struct {
47             uint_t ext_int_exit            : 1;
48             uint_t rsvd1                   : 2; 
49             uint_t nmi_exit                : 1;
50             uint_t rsvd2                   : 1;
51             uint_t virt_nmi                : 1;
52             uint_t active_preempt_timer    : 1;
53             uint_t rsvd3                   : 25;
54         } __attribute__((packed));
55     } __attribute__((packed));
56 } __attribute__((packed));
57
58
59 struct vmx_pri_proc_ctrls {
60     union {
61         uint32_t value;
62         struct {
63             uint_t rsvd1           : 2;
64             uint_t int_wndw_exit   : 1;
65             uint_t tsc_offset      : 1;
66             uint_t rsvd2           : 3;
67             uint_t hlt_exit        : 1;
68             uint_t rsvd3           : 1;
69             uint_t invlpg_exit     : 1;
70             uint_t mwait_exit      : 1;
71             uint_t rdpmc_exit      : 1;
72             uint_t rdtsc_exit      : 1;
73             uint_t rsvd4           : 2;
74             uint_t cr3_ld_exit     : 1;
75             uint_t cr3_str_exit    : 1;
76             uint_t rsvd5           : 2;
77             uint_t cr8_ld_exit     : 1;
78             uint_t cr8_str_exit    : 1;
79             uint_t tpr_shdw        : 1;
80             uint_t nmi_wndw_exit   : 1;
81             uint_t mov_dr_exit     : 1;
82             uint_t uncon_io_exit   : 1;
83             uint_t use_io_bitmap   : 1;
84             uint_t rsvd6           : 1;
85             uint_t monitor_trap    : 1;
86             uint_t use_msr_bitmap  : 1;
87             uint_t monitor_exit    : 1;
88             uint_t pause_exit      : 1;
89             uint_t sec_ctrls       : 1;
90         } __attribute__((packed));
91     } __attribute__((packed));
92 } __attribute__((packed));
93
94 struct vmx_sec_proc_ctrls {
95     union {
96         uint32_t value;
97         struct {
98             uint_t virt_apic_acc   : 1;
99             uint_t enable_ept      : 1;
100             uint_t desc_table_exit : 1;
101             uint_t enable_rdtscp   : 1;
102             uint_t virt_x2apic     : 1;
103             uint_t enable_vpid     : 1;
104             uint_t unrstrct_guest  : 1;
105             uint_t rsvd1           : 2;
106             uint_t pause_loop_exit : 1;
107             uint_t rsvd2           : 21;
108         } __attribute__((packed));
109     } __attribute__((packed));
110 } __attribute__((packed));
111
112 struct vmx_exit_ctrls {
113     union {
114         uint32_t value;
115         struct {
116             uint_t rsvd1                : 2;
117             uint_t save_dbg_ctrls       : 1;
118             uint_t rsvd2                : 6;
119             uint_t host_64_on           : 1;
120             uint_t rsvd3                : 2;
121             uint_t ld_perf_glbl_ctrl    : 1;
122             uint_t rsvd4                : 2;
123             uint_t ack_int_on_exit      : 1;
124             uint_t rsvd5                : 2;
125             uint_t save_pat             : 1;
126             uint_t ld_pat               : 1;
127             uint_t save_efer            : 1;
128             uint_t ld_efer              : 1;
129             uint_t save_preempt_timer   : 1;
130             uint_t rsvd6                : 9;
131         } __attribute__((packed));
132     } __attribute__((packed));
133 } __attribute__((packed));
134
135 struct vmx_entry_ctrls {
136     union {
137         uint32_t value;
138         struct {
139             uint_t rsvd1                : 2;
140             uint_t ld_dbg_ctrls         : 1;
141             uint_t rsvd2                : 6;
142             uint_t guest_ia32e          : 1;
143             uint_t smm_entry            : 1;
144             uint_t no_dual_monitor      : 1;
145             uint_t rsvd3                : 1;
146             uint_t ld_perf_glbl_ctrl    : 1;
147             uint_t ld_pat               : 1;
148             uint_t ld_efer              : 1;
149             uint_t rsvd4                : 16;
150         } __attribute__((packed));
151     } __attribute__((packed));
152 } __attribute__((packed));
153
154
155 typedef enum { 
156     VMXASSIST_DISABLED,
157     VMXASSIST_ENABLED
158 } vmxassist_state_t;
159
160 typedef enum {
161     VMX_UNLAUNCHED,
162     VMX_LAUNCHED
163 } vmx_state_t;
164
165 struct tss_descriptor {
166     uint16_t    limit1;
167     uint16_t    base1;
168     uint_t      base2       : 8;
169     /* In IA32, type follows the form 10B1b, where B is the busy flag */
170     uint_t      type        : 4; 
171     uint_t      zero1       : 1;
172     uint_t      dpl         : 2;
173     uint_t      present     : 1;
174     uint_t      limit2      : 4;
175     uint_t      available   : 1;
176     uint_t      zero2       : 1;
177     uint_t      zero3       : 1;
178     uint_t      granularity : 1;
179     uint_t      base3       : 8;
180 #ifdef __V3_64BIT__
181     uint32_t    base4;
182     uint_t      rsvd1       : 8;
183     uint_t      zero4       : 5;
184     uint_t      rsvd2       : 19;
185 #endif
186 }__attribute__((packed));
187
188 struct vmcs_host_state {
189     struct v3_segment  gdtr;
190     struct v3_segment  idtr;
191     struct v3_segment  tr;
192 };
193
194
195
196
197
198 struct vmx_data {
199     vmx_state_t state;
200     vmxassist_state_t assist_state;
201     struct vmcs_host_state host_state;
202
203     addr_t vmcs_ptr_phys;
204
205     uint8_t ia32e_avail;
206
207     v3_reg_t guest_cr4; /// corresponds to the CR4 Read shadow
208
209
210     /* VMX Control Fields */
211     struct vmx_pin_ctrls pin_ctrls;
212     struct vmx_pri_proc_ctrls pri_proc_ctrls;
213     struct vmx_sec_proc_ctrls sec_proc_ctrls;
214     struct vmx_exit_ctrls exit_ctrls;
215     struct vmx_entry_ctrls entry_ctrls;
216
217     struct vmx_exception_bitmap excp_bmap;
218 };
219
220 int v3_is_vmx_capable();
221
222 void v3_init_vmx_cpu(int cpu_id);
223 void v3_deinit_vmx_cpu(int cpu_id);
224
225 int v3_start_vmx_guest(struct guest_info* info);
226 int v3_vmx_enter(struct guest_info * info);
227
228 int v3_init_vmx_vmcs(struct guest_info * info, v3_vm_class_t vm_class);
229 int v3_deinit_vmx_vmcs(struct guest_info * core);
230
231 #endif // ! __V3VEE__
232
233 #endif 
234
235