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.


added support for Intel EPT with(?) and without unrestricted guest support
[palacios.git] / palacios / include / palacios / vmx_hw_info.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) 2011, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2011, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20
21 #ifndef __VMX_HW_INFO_H__
22 #define __VMX_HW_INFO_H__
23
24 #ifdef __V3VEE__
25
26
27
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
45
46
47
48 struct vmx_basic_msr {
49     union {
50         struct {
51             uint32_t lo;
52             uint32_t hi;
53         } __attribute__((packed));
54
55         struct {    uint32_t revision;
56             uint32_t regionSize   : 13;
57             uint8_t rsvd1         : 3; /* Always 0 */
58             uint8_t physWidth     : 1; /* VMCS address field widths 
59                                           (1=32bits, 0=natural width) */
60             uint8_t smm           : 1;
61             uint8_t memType       : 4; /* 0 = UC, 6 = WriteBack */
62             uint8_t io_str_info   : 1;
63             uint8_t def1_maybe_0  : 1; /* 1="Any VMX ctrls that default to 1 may be cleared to 0" */
64             uint32_t rsvd2        : 8; /* Always 0 */
65         }  __attribute__((packed));
66     }  __attribute__((packed));
67 }  __attribute__((packed));
68
69
70 struct vmx_misc_msr {
71     union {
72         struct {
73             uint32_t lo;
74             uint32_t hi;
75         } __attribute__((packed));
76
77         struct {
78             uint8_t tsc_multiple       : 5; /* Bit position in TSC field that drives vmx timer step */
79             uint8_t exits_store_LMA    : 1;
80             uint8_t can_halt           : 1;
81             uint8_t can_shtdown        : 1;
82             uint8_t can_wait_for_sipi  : 1;
83             uint8_t rsvd1              : 7;
84             uint16_t num_cr3_targets   : 9;
85             uint8_t max_msr_cache_size : 3; /* (512 * (max_msr_cache_size + 1)) == max msr load/store list size */
86             uint8_t SMM_ctrl_avail     : 1;
87             uint8_t rsvd2              : 3; 
88             uint32_t MSEG_rev_id;
89         }  __attribute__((packed));
90     }  __attribute__((packed));
91 } __attribute__((packed));
92
93
94 struct vmx_ept_msr {
95     union {
96         struct {
97             uint32_t lo;
98             uint32_t hi;
99         } __attribute__((packed));
100
101         struct {
102             uint8_t exec_only_ok             : 1;
103             uint8_t rsvd1                    : 5;
104             uint8_t pg_walk_len4             : 1; /* support for a page walk of length 4 */
105             uint8_t rsvd2                    : 1;
106             uint8_t ept_uc_ok                : 1; /* EPT page tables can be uncacheable */
107             uint8_t rsvd3                    : 5;
108             uint8_t ept_wb_ok                : 1; /* EPT page tables can be writeback */
109             uint8_t rsvd4                    : 1;
110             uint8_t ept_2MB_ok               : 1; /* 2MB EPT pages supported */
111             uint8_t ept_1GB_ok               : 1; /* 1GB EPT pages supported */
112             uint8_t rsvd5                    : 2;
113             uint8_t INVEPT_avail             : 1; /* INVEPT instruction is available */
114             uint8_t rsvd6                    : 4;
115             uint8_t INVEPT_single_ctx_avail  : 1;
116             uint8_t INVEPT_all_ctx_avail     : 1;
117             uint8_t rsvd7                    : 5;
118             uint8_t INVVPID_avail            : 1;
119             uint8_t rsvd8                    : 7;
120             uint8_t INVVPID_1addr_avail      : 1;
121             uint8_t INVVPID_single_ctx_avail : 1;
122             uint8_t INVVPID_all_ctx_avail    : 1;
123             uint8_t INVVPID_single_ctx_w_glbls_avail : 1;
124             uint32_t rsvd9                   : 20;
125         }  __attribute__((packed));
126     }  __attribute__((packed));
127 }__attribute__((packed));
128
129
130 struct vmx_ctrl_field {
131     uint32_t def_val;
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) */
134 };
135
136
137 struct vmx_cr_field {
138     uint64_t def_val;
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) */
141 };
142
143
144
145
146 struct vmx_hw_info {
147     struct vmx_basic_msr basic_info;
148     struct vmx_misc_msr misc_info;
149     struct vmx_ept_msr ept_info;
150
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;
156
157     struct vmx_cr_field cr0;
158     struct vmx_cr_field cr4;
159 };
160
161
162
163
164 int v3_init_vmx_hw(struct vmx_hw_info * hw_info);
165
166 uint32_t v3_vmx_get_ctrl_features(struct vmx_ctrl_field * fields);
167
168
169
170 #endif
171
172 #endif