Merge branch 'vendor/GCC50'
[dragonfly.git] / sys / platform / pc64 / vmm / vmx_vmcs.h
1 /*
2  * Copyright (c) 2003-2013 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Mihai Carabas <mihai.carabas@gmail.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  */
34
35 #ifndef _VMM_VMX_VMCS_H_
36 #define _VMM_VMX_VMCS_H_
37
38 /*
39  * Appendix B: Field Enconding in VMCS
40  * Intel Architecture Manual Vol3C - 326019
41  */
42
43 /* 16-Bit Control Fields */
44 #define         VMCS_VPID                       0x00000000
45 #define         VMCS_PINV                       0x00000002
46 #define         VMCS_EPTP_INDEX                 0x00000004
47
48 /* 16-Bit Guest-State Fields */
49 #define         VMCS_GUEST_ES_SELECTOR          0x00000800
50 #define         VMCS_GUEST_CS_SELECTOR          0x00000802
51 #define         VMCS_GUEST_SS_SELECTOR          0x00000804
52 #define         VMCS_GUEST_DS_SELECTOR          0x00000806
53 #define         VMCS_GUEST_FS_SELECTOR          0x00000808
54 #define         VMCS_GUEST_GS_SELECTOR          0x0000080A
55 #define         VMCS_GUEST_LDTR_SELECTOR        0x0000080C
56 #define         VMCS_GUEST_TR_SELECTOR          0x0000080E
57 #define         VMCS_GUEST_INTERRUPT_STATUS     0x00000810
58
59 /* 16-Bit Host-State Fields */
60 #define         VMCS_HOST_ES_SELECTOR           0x00000C00
61 #define         VMCS_HOST_CS_SELECTOR           0x00000C02
62 #define         VMCS_HOST_SS_SELECTOR           0x00000C04
63 #define         VMCS_HOST_DS_SELECTOR           0x00000C06
64 #define         VMCS_HOST_FS_SELECTOR           0x00000C08
65 #define         VMCS_HOST_GS_SELECTOR           0x00000C0A
66 #define         VMCS_HOST_TR_SELECTOR           0x00000C0C
67
68 /* 64-Bit Control Fields */
69 #define         VMCS_IO_BITMAP_A                0x00002000
70 #define         VMCS_IO_BITMAP_B                0x00002002
71 #define         VMCS_MSR_BITMAP                 0x00002004
72 #define         VMCS_VMEXIT_MSR_STORE           0x00002006
73 #define         VMCS_VMEXIT_MSR_LOAD            0x00002008
74 #define         VMCS_VMENTRY_MSR_LOAD           0x0000200A
75 #define         VMCS_EXECUTIVE_VMCS             0x0000200C
76 #define         VMCS_TSC_OFFSET                 0x00002010
77 #define         VMCS_VIRTUAL_APIC               0x00002012
78 #define         VMCS_APIC_ACCESS                0x00002014
79 #define         VMCS_POSTED_INTERRUPT_DESCR     0x00002016
80 #define         VMCS_VMFUNCTION_CONTROLS        0x00002018
81 #define         VMCS_EPTP                       0x0000201A
82
83 /* 64-Bit Read-Only Data Field */
84 #define         VMCS_GUEST_PHYSICAL_ADDRESS     0x00002400
85
86 /* 64-Bit Guest-State Fields */
87 #define         VMCS_LINK_POINTER               0x00002800
88 #define         VMCS_GUEST_IA32_DEBUGCTL        0x00002802
89 #define         VMCS_GUEST_IA32_PAT             0x00002804
90 #define         VMCS_GUEST_IA32_EFER            0x00002806
91 #define         VMCS_GUEST_IA32_PERF_GLOBAL     0x00002808
92 #define         VMCS_GUEST_PDPTE0               0x0000280A
93 #define         VMCS_GUEST_PDPTE1               0x0000280C
94 #define         VMCS_GUEST_PDPTE2               0x0000280E
95 #define         VMCS_GUEST_PDPTE3               0x00002810
96
97 /* 64-Bit Host-State Fields */
98 #define         VMCS_HOST_IA32_PAT              0x00002C00
99 #define         VMCS_HOST_IA32_EFER             0x00002C02
100 #define         VMCS_HOST_IA32_PERF_GLOBAL_CTRL 0x00002C04
101
102 /* 32-Bit Control Fields */
103 #define         VMCS_PINBASED_CTLS              0x00004000
104 #define         VMCS_PROCBASED_CTLS             0x00004002
105 #define         VMCS_EXCEPTION_BITMAP           0x00004004
106 #define         VMCS_PAGE_FAULT_ERR_MASK        0x00004006
107 #define         VMCS_PAGE_FAULT_ERR_MATCH       0x00004008
108 #define         VMCS_CR3_TARGET_COUNT           0x0000400A
109 #define         VMCS_VMEXIT_CTLS                0x0000400C
110 #define         VMCS_VMEXIT_MSR_STORE_COUNT     0x0000400E
111 #define         VMCS_VMEXIT_MSR_LOAD_COUNT      0x00004010
112 #define         VMCS_VMENTRY_CTLS               0x00004012
113 #define         VMCS_VMENTRY_MSR_LOAD_COUNT     0x00004014
114 #define         VMCS_VMENTRY_INTR_INFO          0x00004016
115 #define         VMCS_VMENTRY_EXCEPTION_ERR      0x00004018
116 #define         VMCS_VMENTRY_INSTR_LENGTH       0x0000401A
117 #define         VMCS_TPR_THRESHOLD              0x0000401C
118 #define         VMCS_PROCBASED2_CTLS            0x0000401E
119 #define         VMCS_PLE_GAP                    0x00004020
120 #define         VMCS_PLE_WINDOW                 0x00004022
121
122 /* 32-Bit Read-Only Data Fields */
123 #define         VMCS_INSTR_ERR                  0x00004400
124 #define         VMCS_VMEXIT_REASON              0x00004402
125 #define         VMCS_BASIC_EXIT_REASON(val)     (val & 0xffff)
126 #define         VMCS_VMEXIT_INTERRUPTION_INFO   0x00004404
127 #define         VMCS_VMEXIT_INTERRUPTION_ERROR  0x00004406
128 #define         VMCS_IDT_VECTORING_INFO         0x00004408
129 #define         VMCS_IDT_VECTORING_ERR          0x0000440A
130 #define         VMCS_VMEXIT_INSTRUCTION_LENGTH  0x0000440C
131 #define         VMCS_VMEXIT_INSTRUCTION_INFO    0x0000440E
132
133 /* 32-Bit Guest-State Fields */
134 #define         VMCS_GUEST_ES_LIMIT             0x00004800
135 #define         VMCS_GUEST_CS_LIMIT             0x00004802
136 #define         VMCS_GUEST_SS_LIMIT             0x00004804
137 #define         VMCS_GUEST_DS_LIMIT             0x00004806
138 #define         VMCS_GUEST_FS_LIMIT             0x00004808
139 #define         VMCS_GUEST_GS_LIMIT             0x0000480A
140 #define         VMCS_GUEST_LDTR_LIMIT           0x0000480C
141 #define         VMCS_GUEST_TR_LIMIT             0x0000480E
142 #define         VMCS_GUEST_GDTR_LIMIT           0x00004810
143 #define         VMCS_GUEST_IDTR_LIMIT           0x00004812
144 #define         VMCS_GUEST_ES_ACCESS_RIGHTS     0x00004814
145 #define         VMCS_GUEST_CS_ACCESS_RIGHTS     0x00004816
146 #define         VMCS_GUEST_SS_ACCESS_RIGHTS     0x00004818
147 #define         VMCS_GUEST_DS_ACCESS_RIGHTS     0x0000481A
148 #define         VMCS_GUEST_FS_ACCESS_RIGHTS     0x0000481C
149 #define         VMCS_GUEST_GS_ACCESS_RIGHTS     0x0000481E
150 #define         VMCS_GUEST_LDTR_ACCESS_RIGHTS   0x00004820
151 #define         VMCS_GUEST_TR_ACCESS_RIGHTS     0x00004822
152 #define         VMCS_GUEST_INTERRUPTIBILITY     0x00004824
153 #define         VMCS_GUEST_ACTIVITY             0x00004826
154 #define         VMCS_GUEST_SMBASE               0x00004828
155 #define         VMCS_GUEST_IA32_SYSENTER_CS     0x0000482A
156 #define         VMCS_PREEMPTION_TIMER_VALUE     0x0000482E
157
158 /* 32-Bit Host-State Field */
159 #define         VMCS_HOST_IA32_SYSENTER_CS      0x00004C00
160
161 /* Natural-Width Control Fields */
162 #define         VMCS_CR0_MASK                   0x00006000
163 #define         VMCS_CR4_MASK                   0x00006002
164 #define         VMCS_CR0_SHADOW                 0x00006004
165 #define         VMCS_CR4_SHADOW                 0x00006006
166 #define         VMCS_CR3_TARGET_VALUE0          0x00006008
167 #define         VMCS_CR3_TARGET_VALUE1          0x0000600A
168 #define         VMCS_CR3_TARGET_VALUE2          0x0000600C
169 #define         VMCS_CR3_TARGET_VALUE3          0x0000600E
170
171 /* Natural-Width Read-Only Data Fields */
172 #define         VMCS_EXIT_QUALIFICATION         0x00006400
173 #define         VMCS_IO_RCX                     0x00006402
174 #define         VMCS_IO_RSI                     0x00006404
175 #define         VMCS_IO_RDI                     0x00006406
176 #define         VMCS_IO_RIP                     0x00006408
177 #define         VMCS_GUEST_LINEAR_ADDRESS       0x0000640A
178
179 /* Natural-Width Guest-State Fields */
180 #define         VMCS_GUEST_CR0                  0x00006800
181 #define         VMCS_GUEST_CR3                  0x00006802
182 #define         VMCS_GUEST_CR4                  0x00006804
183 #define         VMCS_GUEST_ES_BASE              0x00006806
184 #define         VMCS_GUEST_CS_BASE              0x00006808
185 #define         VMCS_GUEST_SS_BASE              0x0000680A
186 #define         VMCS_GUEST_DS_BASE              0x0000680C
187 #define         VMCS_GUEST_FS_BASE              0x0000680E
188 #define         VMCS_GUEST_GS_BASE              0x00006810
189 #define         VMCS_GUEST_LDTR_BASE            0x00006812
190 #define         VMCS_GUEST_TR_BASE              0x00006814
191 #define         VMCS_GUEST_GDTR_BASE            0x00006816
192 #define         VMCS_GUEST_IDTR_BASE            0x00006818
193 #define         VMCS_GUEST_DR7                  0x0000681A
194 #define         VMCS_GUEST_RSP                  0x0000681C
195 #define         VMCS_GUEST_RIP                  0x0000681E
196 #define         VMCS_GUEST_RFLAGS               0x00006820
197 #define         VMCS_GUEST_PENDING_DBG_EXCEPT   0x00006822
198 #define         VMCS_GUEST_IA32_SYSENTER_ESP    0x00006824
199 #define         VMCS_GUEST_IA32_SYSENTER_EIP    0x00006826
200
201 /* Natural-Width Host-State Fields */
202 #define         VMCS_HOST_CR0                   0x00006C00
203 #define         VMCS_HOST_CR3                   0x00006C02
204 #define         VMCS_HOST_CR4                   0x00006C04
205 #define         VMCS_HOST_FS_BASE               0x00006C06
206 #define         VMCS_HOST_GS_BASE               0x00006C08
207 #define         VMCS_HOST_TR_BASE               0x00006C0A
208 #define         VMCS_HOST_GDTR_BASE             0x00006C0C
209 #define         VMCS_HOST_IDTR_BASE             0x00006C0E
210 #define         VMCS_HOST_IA32_SYSENTER_ESP     0x00006C10
211 #define         VMCS_HOST_IA32_SYSENTER_EIP     0x00006C12
212 #define         VMCS_HOST_RSP                   0x00006C14
213 #define         VMCS_HOST_RIP                   0x00006c16
214
215 #endif