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) 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.
15 * Author: Peter Dinda <pdinda@northwestern.edu>
16 * Author: Jack Lange <jarusl@cs.northwestern.edu>
18 * This is free software. You are permitted to use,
19 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
28 #include <palacios/vmm_types.h>
29 #include <palacios/vmcs.h>
30 #include <palacios/vmm.h>
31 #include <palacios/vm_guest.h>
35 #define VMX_FAIL_INVALID 1
36 #define VMX_FAIL_VALID 2
43 struct vmx_pin_ctrls {
47 uint_t ext_int_exit : 1;
52 uint_t active_preempt_timer : 1;
54 } __attribute__((packed));
55 } __attribute__((packed));
56 } __attribute__((packed));
59 struct vmx_pri_proc_ctrls {
64 uint_t int_wndw_exit : 1;
65 uint_t tsc_offset : 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;
74 uint_t cr3_ld_exit : 1;
75 uint_t cr3_str_exit : 1;
77 uint_t cr8_ld_exit : 1;
78 uint_t cr8_str_exit : 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;
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;
90 } __attribute__((packed));
91 } __attribute__((packed));
92 } __attribute__((packed));
94 struct vmx_sec_proc_ctrls {
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;
106 uint_t pause_loop_exit : 1;
108 } __attribute__((packed));
109 } __attribute__((packed));
110 } __attribute__((packed));
112 struct vmx_exit_ctrls {
117 uint_t save_dbg_ctrls : 1;
119 uint_t host_64_on : 1;
121 uint_t ld_perf_glbl_ctrl : 1;
123 uint_t ack_int_on_exit : 1;
127 uint_t save_efer : 1;
129 uint_t save_preempt_timer : 1;
131 } __attribute__((packed));
132 } __attribute__((packed));
133 } __attribute__((packed));
135 struct vmx_entry_ctrls {
140 uint_t ld_dbg_ctrls : 1;
142 uint_t guest_ia32e : 1;
143 uint_t smm_entry : 1;
144 uint_t no_dual_monitor : 1;
146 uint_t ld_perf_glbl_ctrl : 1;
150 } __attribute__((packed));
151 } __attribute__((packed));
152 } __attribute__((packed));
165 struct tss_descriptor {
169 /* In IA32, type follows the form 10B1b, where B is the busy flag */
175 uint_t available : 1;
178 uint_t granularity : 1;
186 }__attribute__((packed));
188 struct vmcs_host_state {
189 struct v3_segment gdtr;
190 struct v3_segment idtr;
191 struct v3_segment tr;
200 vmxassist_state_t assist_state;
201 struct vmcs_host_state host_state;
203 addr_t vmcs_ptr_phys;
207 v3_reg_t guest_cr4; /// corresponds to the CR4 Read shadow
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;
218 int v3_is_vmx_capable();
220 void v3_init_vmx_cpu(int cpu_id);
221 void v3_deinit_vmx_cpu(int cpu_id);
223 int v3_start_vmx_guest(struct guest_info* info);
224 int v3_vmx_enter(struct guest_info * info);
226 int v3_init_vmx_vmcs(struct guest_info * info, v3_vm_class_t vm_class);
227 int v3_deinit_vmx_vmcs(struct guest_info * core);
229 #endif // ! __V3VEE__