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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2011, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
26 #include <palacios/vmm_types.h>
27 #include <palacios/vmcs.h>
28 #include <palacios/vmm.h>
29 #include <palacios/vm_guest.h>
33 #define VMX_FAIL_INVALID 1
34 #define VMX_FAIL_VALID 2
38 struct vmx_pin_ctrls {
42 uint_t ext_int_exit : 1;
47 uint_t active_preempt_timer : 1;
49 } __attribute__((packed));
50 } __attribute__((packed));
51 } __attribute__((packed));
54 struct vmx_pri_proc_ctrls {
59 uint_t int_wndw_exit : 1;
60 uint_t tsc_offset : 1;
64 uint_t invlpg_exit : 1;
65 uint_t mwait_exit : 1;
66 uint_t rdpmc_exit : 1;
67 uint_t rdtsc_exit : 1;
69 uint_t cr3_ld_exit : 1;
70 uint_t cr3_str_exit : 1;
72 uint_t cr8_ld_exit : 1;
73 uint_t cr8_str_exit : 1;
75 uint_t nmi_wndw_exit : 1;
76 uint_t mov_dr_exit : 1;
77 uint_t uncon_io_exit : 1;
78 uint_t use_io_bitmap : 1;
80 uint_t monitor_trap : 1;
81 uint_t use_msr_bitmap : 1;
82 uint_t monitor_exit : 1;
83 uint_t pause_exit : 1;
85 } __attribute__((packed));
86 } __attribute__((packed));
87 } __attribute__((packed));
89 struct vmx_sec_proc_ctrls {
93 uint_t virt_apic_acc : 1;
94 uint_t enable_ept : 1;
95 uint_t desc_table_exit : 1;
96 uint_t enable_rdtscp : 1;
97 uint_t virt_x2apic : 1;
98 uint_t enable_vpid : 1;
99 uint_t wbinvd_exit : 1;
100 uint_t unrstrct_guest : 1; /* un restricted guest (CAN RUN IN REAL MODE) */
102 uint_t pause_loop_exit : 1;
104 } __attribute__((packed));
105 } __attribute__((packed));
106 } __attribute__((packed));
108 struct vmx_exit_ctrls {
113 uint_t save_dbg_ctrls : 1;
115 uint_t host_64_on : 1;
117 uint_t ld_perf_glbl_ctrl : 1;
119 uint_t ack_int_on_exit : 1;
123 uint_t save_efer : 1;
125 uint_t save_preempt_timer : 1;
127 } __attribute__((packed));
128 } __attribute__((packed));
129 } __attribute__((packed));
131 struct vmx_entry_ctrls {
136 uint_t ld_dbg_ctrls : 1;
138 uint_t guest_ia32e : 1;
139 uint_t smm_entry : 1;
140 uint_t no_dual_monitor : 1;
142 uint_t ld_perf_glbl_ctrl : 1;
146 } __attribute__((packed));
147 } __attribute__((packed));
148 } __attribute__((packed));
161 struct tss_descriptor {
165 /* In IA32, type follows the form 10B1b, where B is the busy flag */
171 uint_t available : 1;
174 uint_t granularity : 1;
182 } __attribute__((packed));
184 struct vmcs_host_state {
185 struct v3_segment gdtr;
186 struct v3_segment idtr;
187 struct v3_segment tr;
194 vmxassist_state_t assist_state;
195 struct vmcs_host_state host_state;
199 addr_t vmcs_ptr_phys;
201 v3_reg_t guest_cr4; /// corresponds to the CR4 Read shadow
204 /* VMX Control Fields */
205 struct vmx_pin_ctrls pin_ctrls;
206 struct vmx_pri_proc_ctrls pri_proc_ctrls;
207 struct vmx_sec_proc_ctrls sec_proc_ctrls;
208 struct vmx_exit_ctrls exit_ctrls;
209 struct vmx_entry_ctrls entry_ctrls;
211 struct vmx_exception_bitmap excp_bmap;
216 int v3_is_vmx_capable();
218 void v3_init_vmx_cpu(int cpu_id);
219 void v3_deinit_vmx_cpu(int cpu_id);
221 int v3_start_vmx_guest(struct guest_info* info);
222 int v3_reset_vmx_vm_core(struct guest_info * core, addr_t rip);
223 int v3_vmx_enter(struct guest_info * info);
225 int v3_init_vmx_vmcs(struct guest_info * info, v3_vm_class_t vm_class);
226 int v3_deinit_vmx_vmcs(struct guest_info * core);
228 #endif // ! __V3VEE__