ia64/xen-unstable

view xen/include/asm-x86/hvm/vmx/vmcs.h @ 19848:5839491bbf20

[IA64] replace MAX_VCPUS with d->max_vcpus where necessary.

don't use MAX_VCPUS, and use vcpu::max_vcpus.
The changeset of 2f9e1348aa98 introduced max_vcpus to allow more vcpus
per guest. This patch is ia64 counter part.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 11:26:05 2009 +0900 (2009-06-29)
parents bf37a89269bf
children
line source
1 /*
2 * vmcs.h: VMCS related definitions
3 * Copyright (c) 2004, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 *
18 */
19 #ifndef __ASM_X86_HVM_VMX_VMCS_H__
20 #define __ASM_X86_HVM_VMX_VMCS_H__
22 #include <asm/config.h>
23 #include <asm/hvm/io.h>
24 #include <asm/hvm/vmx/vpmu.h>
26 extern void start_vmx(void);
27 extern void vmcs_dump_vcpu(struct vcpu *v);
28 extern void setup_vmcs_dump(void);
29 extern int vmx_cpu_up(void);
30 extern void vmx_cpu_down(void);
32 struct vmcs_struct {
33 u32 vmcs_revision_id;
34 unsigned char data [0]; /* vmcs size is read from MSR */
35 };
37 struct vmx_msr_entry {
38 u32 index;
39 u32 mbz;
40 u64 data;
41 };
43 enum {
44 VMX_INDEX_MSR_LSTAR = 0,
45 VMX_INDEX_MSR_STAR,
46 VMX_INDEX_MSR_SYSCALL_MASK,
48 VMX_MSR_COUNT
49 };
51 struct vmx_msr_state {
52 unsigned long flags;
53 unsigned long msrs[VMX_MSR_COUNT];
54 };
56 #define EPT_DEFAULT_MT 6
57 #define EPT_DEFAULT_GAW 3
59 struct vmx_domain {
60 unsigned long apic_access_mfn;
61 unsigned long vpid_base;
62 union {
63 struct {
64 u64 etmt :3,
65 gaw :3,
66 rsvd :6,
67 asr :52;
68 };
69 u64 eptp;
70 } ept_control;
71 };
73 struct arch_vmx_struct {
74 /* Virtual address of VMCS. */
75 struct vmcs_struct *vmcs;
77 /* Protects remote usage of VMCS (VMPTRLD/VMCLEAR). */
78 spinlock_t vmcs_lock;
80 /*
81 * Activation and launch status of this VMCS.
82 * - Activated on a CPU by VMPTRLD. Deactivated by VMCLEAR.
83 * - Launched on active CPU by VMLAUNCH when current VMCS.
84 */
85 struct list_head active_list;
86 int active_cpu;
87 int launched;
89 /* Cache of cpu execution control. */
90 u32 exec_control;
91 u32 secondary_exec_control;
93 u16 vpid;
95 /* PMU */
96 struct vpmu_struct vpmu;
98 #ifdef __x86_64__
99 struct vmx_msr_state msr_state;
100 unsigned long shadow_gs;
101 unsigned long cstar;
102 #endif
104 unsigned long *msr_bitmap;
105 unsigned int msr_count;
106 struct vmx_msr_entry *msr_area;
107 unsigned int host_msr_count;
108 struct vmx_msr_entry *host_msr_area;
110 unsigned long host_cr0;
112 /* Is the guest in real mode? */
113 uint8_t vmx_realmode;
114 /* Are we emulating rather than VMENTERing? */
115 uint8_t vmx_emulate;
116 /* Bitmask of segments that we can't safely use in virtual 8086 mode */
117 uint16_t vm86_segment_mask;
118 /* Shadow CS, SS, DS, ES, FS, GS, TR while in virtual 8086 mode */
119 struct segment_register vm86_saved_seg[x86_seg_tr + 1];
120 /* Remember EFLAGS while in virtual 8086 mode */
121 uint32_t vm86_saved_eflags;
122 };
124 int vmx_create_vmcs(struct vcpu *v);
125 void vmx_destroy_vmcs(struct vcpu *v);
126 void vmx_vmcs_enter(struct vcpu *v);
127 void vmx_vmcs_exit(struct vcpu *v);
129 #define CPU_BASED_VIRTUAL_INTR_PENDING 0x00000004
130 #define CPU_BASED_USE_TSC_OFFSETING 0x00000008
131 #define CPU_BASED_HLT_EXITING 0x00000080
132 #define CPU_BASED_INVLPG_EXITING 0x00000200
133 #define CPU_BASED_MWAIT_EXITING 0x00000400
134 #define CPU_BASED_RDPMC_EXITING 0x00000800
135 #define CPU_BASED_RDTSC_EXITING 0x00001000
136 #define CPU_BASED_CR3_LOAD_EXITING 0x00008000
137 #define CPU_BASED_CR3_STORE_EXITING 0x00010000
138 #define CPU_BASED_CR8_LOAD_EXITING 0x00080000
139 #define CPU_BASED_CR8_STORE_EXITING 0x00100000
140 #define CPU_BASED_TPR_SHADOW 0x00200000
141 #define CPU_BASED_VIRTUAL_NMI_PENDING 0x00400000
142 #define CPU_BASED_MOV_DR_EXITING 0x00800000
143 #define CPU_BASED_UNCOND_IO_EXITING 0x01000000
144 #define CPU_BASED_ACTIVATE_IO_BITMAP 0x02000000
145 #define CPU_BASED_MONITOR_TRAP_FLAG 0x08000000
146 #define CPU_BASED_ACTIVATE_MSR_BITMAP 0x10000000
147 #define CPU_BASED_MONITOR_EXITING 0x20000000
148 #define CPU_BASED_PAUSE_EXITING 0x40000000
149 #define CPU_BASED_ACTIVATE_SECONDARY_CONTROLS 0x80000000
150 extern u32 vmx_cpu_based_exec_control;
152 #define PIN_BASED_EXT_INTR_MASK 0x00000001
153 #define PIN_BASED_NMI_EXITING 0x00000008
154 #define PIN_BASED_VIRTUAL_NMIS 0x00000020
155 extern u32 vmx_pin_based_exec_control;
157 #define VM_EXIT_IA32E_MODE 0x00000200
158 #define VM_EXIT_ACK_INTR_ON_EXIT 0x00008000
159 #define VM_EXIT_SAVE_GUEST_PAT 0x00040000
160 #define VM_EXIT_LOAD_HOST_PAT 0x00080000
161 extern u32 vmx_vmexit_control;
163 #define VM_ENTRY_IA32E_MODE 0x00000200
164 #define VM_ENTRY_SMM 0x00000400
165 #define VM_ENTRY_DEACT_DUAL_MONITOR 0x00000800
166 #define VM_ENTRY_LOAD_GUEST_PAT 0x00004000
167 extern u32 vmx_vmentry_control;
169 #define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001
170 #define SECONDARY_EXEC_ENABLE_EPT 0x00000002
171 #define SECONDARY_EXEC_ENABLE_VPID 0x00000020
172 #define SECONDARY_EXEC_WBINVD_EXITING 0x00000040
173 #define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080
174 extern u32 vmx_secondary_exec_control;
176 extern bool_t cpu_has_vmx_ins_outs_instr_info;
178 #define cpu_has_wbinvd_exiting \
179 (vmx_secondary_exec_control & SECONDARY_EXEC_WBINVD_EXITING)
180 #define cpu_has_vmx_virtualize_apic_accesses \
181 (vmx_secondary_exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)
182 #define cpu_has_vmx_tpr_shadow \
183 (vmx_cpu_based_exec_control & CPU_BASED_TPR_SHADOW)
184 #define cpu_has_vmx_vnmi \
185 (vmx_pin_based_exec_control & PIN_BASED_VIRTUAL_NMIS)
186 #define cpu_has_vmx_msr_bitmap \
187 (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP)
188 #define cpu_has_vmx_secondary_exec_control \
189 (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)
190 #define cpu_has_vmx_ept \
191 (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT)
192 #define cpu_has_vmx_vpid \
193 (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_VPID)
194 #define cpu_has_monitor_trap_flag \
195 (vmx_cpu_based_exec_control & CPU_BASED_MONITOR_TRAP_FLAG)
196 #define cpu_has_vmx_pat \
197 (vmx_vmentry_control & VM_ENTRY_LOAD_GUEST_PAT)
198 #define cpu_has_vmx_unrestricted_guest \
199 (vmx_secondary_exec_control & SECONDARY_EXEC_UNRESTRICTED_GUEST)
200 #define vmx_unrestricted_guest(v) \
201 ((v)->arch.hvm_vmx.secondary_exec_control & \
202 SECONDARY_EXEC_UNRESTRICTED_GUEST)
204 /* GUEST_INTERRUPTIBILITY_INFO flags. */
205 #define VMX_INTR_SHADOW_STI 0x00000001
206 #define VMX_INTR_SHADOW_MOV_SS 0x00000002
207 #define VMX_INTR_SHADOW_SMI 0x00000004
208 #define VMX_INTR_SHADOW_NMI 0x00000008
210 /* VMCS field encodings. */
211 enum vmcs_field {
212 VIRTUAL_PROCESSOR_ID = 0x00000000,
213 GUEST_ES_SELECTOR = 0x00000800,
214 GUEST_CS_SELECTOR = 0x00000802,
215 GUEST_SS_SELECTOR = 0x00000804,
216 GUEST_DS_SELECTOR = 0x00000806,
217 GUEST_FS_SELECTOR = 0x00000808,
218 GUEST_GS_SELECTOR = 0x0000080a,
219 GUEST_LDTR_SELECTOR = 0x0000080c,
220 GUEST_TR_SELECTOR = 0x0000080e,
221 HOST_ES_SELECTOR = 0x00000c00,
222 HOST_CS_SELECTOR = 0x00000c02,
223 HOST_SS_SELECTOR = 0x00000c04,
224 HOST_DS_SELECTOR = 0x00000c06,
225 HOST_FS_SELECTOR = 0x00000c08,
226 HOST_GS_SELECTOR = 0x00000c0a,
227 HOST_TR_SELECTOR = 0x00000c0c,
228 IO_BITMAP_A = 0x00002000,
229 IO_BITMAP_A_HIGH = 0x00002001,
230 IO_BITMAP_B = 0x00002002,
231 IO_BITMAP_B_HIGH = 0x00002003,
232 MSR_BITMAP = 0x00002004,
233 MSR_BITMAP_HIGH = 0x00002005,
234 VM_EXIT_MSR_STORE_ADDR = 0x00002006,
235 VM_EXIT_MSR_STORE_ADDR_HIGH = 0x00002007,
236 VM_EXIT_MSR_LOAD_ADDR = 0x00002008,
237 VM_EXIT_MSR_LOAD_ADDR_HIGH = 0x00002009,
238 VM_ENTRY_MSR_LOAD_ADDR = 0x0000200a,
239 VM_ENTRY_MSR_LOAD_ADDR_HIGH = 0x0000200b,
240 TSC_OFFSET = 0x00002010,
241 TSC_OFFSET_HIGH = 0x00002011,
242 VIRTUAL_APIC_PAGE_ADDR = 0x00002012,
243 VIRTUAL_APIC_PAGE_ADDR_HIGH = 0x00002013,
244 APIC_ACCESS_ADDR = 0x00002014,
245 APIC_ACCESS_ADDR_HIGH = 0x00002015,
246 EPT_POINTER = 0x0000201a,
247 EPT_POINTER_HIGH = 0x0000201b,
248 GUEST_PHYSICAL_ADDRESS = 0x00002400,
249 GUEST_PHYSICAL_ADDRESS_HIGH = 0x00002401,
250 VMCS_LINK_POINTER = 0x00002800,
251 VMCS_LINK_POINTER_HIGH = 0x00002801,
252 GUEST_IA32_DEBUGCTL = 0x00002802,
253 GUEST_IA32_DEBUGCTL_HIGH = 0x00002803,
254 GUEST_PAT = 0x00002804,
255 GUEST_PAT_HIGH = 0x00002805,
256 GUEST_PDPTR0 = 0x0000280a,
257 GUEST_PDPTR0_HIGH = 0x0000280b,
258 GUEST_PDPTR1 = 0x0000280c,
259 GUEST_PDPTR1_HIGH = 0x0000280d,
260 GUEST_PDPTR2 = 0x0000280e,
261 GUEST_PDPTR2_HIGH = 0x0000280f,
262 GUEST_PDPTR3 = 0x00002810,
263 GUEST_PDPTR3_HIGH = 0x00002811,
264 HOST_PAT = 0x00002c00,
265 HOST_PAT_HIGH = 0x00002c01,
266 PIN_BASED_VM_EXEC_CONTROL = 0x00004000,
267 CPU_BASED_VM_EXEC_CONTROL = 0x00004002,
268 EXCEPTION_BITMAP = 0x00004004,
269 PAGE_FAULT_ERROR_CODE_MASK = 0x00004006,
270 PAGE_FAULT_ERROR_CODE_MATCH = 0x00004008,
271 CR3_TARGET_COUNT = 0x0000400a,
272 VM_EXIT_CONTROLS = 0x0000400c,
273 VM_EXIT_MSR_STORE_COUNT = 0x0000400e,
274 VM_EXIT_MSR_LOAD_COUNT = 0x00004010,
275 VM_ENTRY_CONTROLS = 0x00004012,
276 VM_ENTRY_MSR_LOAD_COUNT = 0x00004014,
277 VM_ENTRY_INTR_INFO = 0x00004016,
278 VM_ENTRY_EXCEPTION_ERROR_CODE = 0x00004018,
279 VM_ENTRY_INSTRUCTION_LEN = 0x0000401a,
280 TPR_THRESHOLD = 0x0000401c,
281 SECONDARY_VM_EXEC_CONTROL = 0x0000401e,
282 VM_INSTRUCTION_ERROR = 0x00004400,
283 VM_EXIT_REASON = 0x00004402,
284 VM_EXIT_INTR_INFO = 0x00004404,
285 VM_EXIT_INTR_ERROR_CODE = 0x00004406,
286 IDT_VECTORING_INFO = 0x00004408,
287 IDT_VECTORING_ERROR_CODE = 0x0000440a,
288 VM_EXIT_INSTRUCTION_LEN = 0x0000440c,
289 VMX_INSTRUCTION_INFO = 0x0000440e,
290 GUEST_ES_LIMIT = 0x00004800,
291 GUEST_CS_LIMIT = 0x00004802,
292 GUEST_SS_LIMIT = 0x00004804,
293 GUEST_DS_LIMIT = 0x00004806,
294 GUEST_FS_LIMIT = 0x00004808,
295 GUEST_GS_LIMIT = 0x0000480a,
296 GUEST_LDTR_LIMIT = 0x0000480c,
297 GUEST_TR_LIMIT = 0x0000480e,
298 GUEST_GDTR_LIMIT = 0x00004810,
299 GUEST_IDTR_LIMIT = 0x00004812,
300 GUEST_ES_AR_BYTES = 0x00004814,
301 GUEST_CS_AR_BYTES = 0x00004816,
302 GUEST_SS_AR_BYTES = 0x00004818,
303 GUEST_DS_AR_BYTES = 0x0000481a,
304 GUEST_FS_AR_BYTES = 0x0000481c,
305 GUEST_GS_AR_BYTES = 0x0000481e,
306 GUEST_LDTR_AR_BYTES = 0x00004820,
307 GUEST_TR_AR_BYTES = 0x00004822,
308 GUEST_INTERRUPTIBILITY_INFO = 0x00004824,
309 GUEST_ACTIVITY_STATE = 0x00004826,
310 GUEST_SYSENTER_CS = 0x0000482A,
311 HOST_SYSENTER_CS = 0x00004c00,
312 CR0_GUEST_HOST_MASK = 0x00006000,
313 CR4_GUEST_HOST_MASK = 0x00006002,
314 CR0_READ_SHADOW = 0x00006004,
315 CR4_READ_SHADOW = 0x00006006,
316 CR3_TARGET_VALUE0 = 0x00006008,
317 CR3_TARGET_VALUE1 = 0x0000600a,
318 CR3_TARGET_VALUE2 = 0x0000600c,
319 CR3_TARGET_VALUE3 = 0x0000600e,
320 EXIT_QUALIFICATION = 0x00006400,
321 GUEST_LINEAR_ADDRESS = 0x0000640a,
322 GUEST_CR0 = 0x00006800,
323 GUEST_CR3 = 0x00006802,
324 GUEST_CR4 = 0x00006804,
325 GUEST_ES_BASE = 0x00006806,
326 GUEST_CS_BASE = 0x00006808,
327 GUEST_SS_BASE = 0x0000680a,
328 GUEST_DS_BASE = 0x0000680c,
329 GUEST_FS_BASE = 0x0000680e,
330 GUEST_GS_BASE = 0x00006810,
331 GUEST_LDTR_BASE = 0x00006812,
332 GUEST_TR_BASE = 0x00006814,
333 GUEST_GDTR_BASE = 0x00006816,
334 GUEST_IDTR_BASE = 0x00006818,
335 GUEST_DR7 = 0x0000681a,
336 GUEST_RSP = 0x0000681c,
337 GUEST_RIP = 0x0000681e,
338 GUEST_RFLAGS = 0x00006820,
339 GUEST_PENDING_DBG_EXCEPTIONS = 0x00006822,
340 GUEST_SYSENTER_ESP = 0x00006824,
341 GUEST_SYSENTER_EIP = 0x00006826,
342 HOST_CR0 = 0x00006c00,
343 HOST_CR3 = 0x00006c02,
344 HOST_CR4 = 0x00006c04,
345 HOST_FS_BASE = 0x00006c06,
346 HOST_GS_BASE = 0x00006c08,
347 HOST_TR_BASE = 0x00006c0a,
348 HOST_GDTR_BASE = 0x00006c0c,
349 HOST_IDTR_BASE = 0x00006c0e,
350 HOST_SYSENTER_ESP = 0x00006c10,
351 HOST_SYSENTER_EIP = 0x00006c12,
352 HOST_RSP = 0x00006c14,
353 HOST_RIP = 0x00006c16,
354 };
356 #define VMCS_VPID_WIDTH 16
358 void vmx_disable_intercept_for_msr(struct vcpu *v, u32 msr);
359 int vmx_read_guest_msr(u32 msr, u64 *val);
360 int vmx_write_guest_msr(u32 msr, u64 val);
361 int vmx_add_guest_msr(u32 msr);
362 int vmx_add_host_load_msr(u32 msr);
364 #endif /* ASM_X86_HVM_VMX_VMCS_H__ */
366 /*
367 * Local variables:
368 * mode: C
369 * c-set-style: "BSD"
370 * c-basic-offset: 4
371 * tab-width: 4
372 * indent-tabs-mode: nil
373 * End:
374 */