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".
21 #ifndef __VMX_HW_INFO_H__
22 #define __VMX_HW_INFO_H__
28 #define VMX_BASIC_MSR 0x00000480
29 #define VMX_PINBASED_CTLS_MSR 0x00000481
30 #define VMX_PROCBASED_CTLS_MSR 0x00000482
31 #define VMX_EXIT_CTLS_MSR 0x00000483
32 #define VMX_ENTRY_CTLS_MSR 0x00000484
33 #define VMX_MISC_MSR 0x00000485
34 #define VMX_CR0_FIXED0_MSR 0x00000486
35 #define VMX_CR0_FIXED1_MSR 0x00000487
36 #define VMX_CR4_FIXED0_MSR 0x00000488
37 #define VMX_CR4_FIXED1_MSR 0x00000489
38 #define VMX_VMCS_ENUM_MSR 0x0000048A
39 #define VMX_PROCBASED_CTLS2_MSR 0x0000048B
40 #define VMX_EPT_VPID_CAP_MSR 0x0000048C
41 #define VMX_TRUE_PINBASED_CTLS_MSR 0x0000048D
42 #define VMX_TRUE_PROCBASED_CTLS_MSR 0x0000048E
43 #define VMX_TRUE_EXIT_CTLS_MSR 0x0000048F
44 #define VMX_TRUE_ENTRY_CTLS_MSR 0x00000490
48 struct vmx_basic_msr {
53 } __attribute__((packed));
55 struct { uint32_t revision;
56 uint64_t regionSize : 13;
57 uint64_t rsvd1 : 3; /* Always 0 */
58 uint64_t physWidth : 1; /* VMCS address field widths
59 (1=32bits, 0=natural width) */
61 uint64_t memType : 4; /* 0 = UC, 6 = WriteBack */
62 uint64_t io_str_info : 1;
63 uint64_t def1_maybe_0 : 1; /* 1="Any VMX ctrls that default to 1 may be cleared to 0" */
64 uint64_t rsvd2 : 8; /* Always 0 */
65 } __attribute__((packed));
66 } __attribute__((packed));
67 } __attribute__((packed));
75 } __attribute__((packed));
78 uint64_t tsc_multiple : 5; /* Bit position in TSC field that drives vmx timer step */
79 uint64_t exits_store_LMA : 1;
80 uint64_t can_halt : 1;
81 uint64_t can_shtdown : 1;
82 uint64_t can_wait_for_sipi : 1;
84 uint64_t num_cr3_targets : 9;
85 uint64_t max_msr_cache_size : 3; /* (512 * (max_msr_cache_size + 1)) == max msr load/store list size */
86 uint64_t SMM_ctrl_avail : 1;
89 } __attribute__((packed));
90 } __attribute__((packed));
91 } __attribute__((packed));
99 } __attribute__((packed));
102 uint64_t exec_only_ok : 1;
104 uint64_t pg_walk_len4 : 1; /* support for a page walk of length 4 */
106 uint64_t ept_uc_ok : 1; /* EPT page tables can be uncacheable */
108 uint64_t ept_wb_ok : 1; /* EPT page tables can be writeback */
110 uint64_t ept_2MB_ok : 1; /* 2MB EPT pages supported */
111 uint64_t ept_1GB_ok : 1; /* 1GB EPT pages supported */
113 uint64_t INVEPT_avail : 1; /* INVEPT instruction is available */
115 uint64_t INVEPT_single_ctx_avail : 1;
116 uint64_t INVEPT_all_ctx_avail : 1;
118 uint64_t INVVPID_avail : 1;
120 uint64_t INVVPID_1addr_avail : 1;
121 uint64_t INVVPID_single_ctx_avail : 1;
122 uint64_t INVVPID_all_ctx_avail : 1;
123 uint64_t INVVPID_single_ctx_w_glbls_avail : 1;
125 } __attribute__((packed));
126 } __attribute__((packed));
127 }__attribute__((packed));
130 struct vmx_ctrl_field {
132 uint32_t req_val; /* Required values: field_val & req_mask == req_val */
133 uint32_t req_mask; /* If a mask bit is set it's value is restricted (i.e. the VMM cannot change it) */
137 struct vmx_cr_field {
139 uint64_t req_val; /* Required values: field_val & req_mask == req_val */
140 uint64_t req_mask; /* If a mask bit is set it's value is restricted (i.e. the VMM cannot change it) */
147 struct vmx_basic_msr basic_info;
148 struct vmx_misc_msr misc_info;
149 struct vmx_ept_msr ept_info;
151 struct vmx_ctrl_field pin_ctrls;
152 struct vmx_ctrl_field proc_ctrls;
153 struct vmx_ctrl_field exit_ctrls;
154 struct vmx_ctrl_field entry_ctrls;
155 struct vmx_ctrl_field sec_proc_ctrls;
157 struct vmx_cr_field cr0;
158 struct vmx_cr_field cr4;
165 int v3_init_vmx_hw(struct vmx_hw_info * hw_info);
167 uint32_t v3_vmx_get_ctrl_features(struct vmx_ctrl_field * fields);