debuggers.hg

view xen/include/asm-x86/vmx_vmcs.h @ 4640:e02fc4c21740

bitkeeper revision 1.1345 (4266bd05lHlHunb0CEvOq60j2DvKCQ)

[PATCH] VMX world switch

The attached code implements a VMX world switch to vmxassist (a small assist
module residing in a VMX enabled partition where it is responsible for
emulating real mode) whever CR0.PE is disabled.

The patch temporarily disables the PGE feature flag in cpuid as it is
currently broken (try running an unmodified 2.6 kernel that sets PGE in
mm/init.c/paging_init()).

The patch adds consistency checks before setting the ARCH_VMX_IO_WAIT state
to detect race conditions on SMP systems.

Signed-Off-By: Leendert van Doorn <leendert@watson.ibm.com>
Signed-off-by: ian@xensource.com
author leendert@watson.ibm.com[iap10]
date Wed Apr 20 20:35:17 2005 +0000 (2005-04-20)
parents aa21bd6f8677
children 38a02ee9a9c8 65b28c74cec2
line source
1 /*
2 * vmx_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_VMX_VMCS_H__
20 #define __ASM_X86_VMX_VMCS_H__
22 #include <asm/config.h>
23 #include <asm/vmx_cpu.h>
24 #include <asm/vmx_platform.h>
25 #include <public/vmx_assist.h>
27 extern int start_vmx(void);
28 extern void stop_vmx(void);
30 void vmx_enter_scheduler(void);
32 #define VMX_CPU_STATE_PG_ENABLED 0
33 #define VMX_CPU_STATE_ASSIST_ENABLED 1
34 #define VMCS_SIZE 0x1000
36 struct vmcs_struct {
37 u32 vmcs_revision_id;
38 unsigned char data [0x1000 - sizeof (u32)];
39 };
41 struct arch_vmx_struct {
42 struct vmcs_struct *vmcs; /* VMCS pointer in virtual */
43 unsigned long flags; /* VMCS flags */
44 unsigned long cpu_cr2; /* save CR2 */
45 unsigned long cpu_cr3;
46 unsigned long cpu_state;
47 struct virutal_platform_def vmx_platform;
48 };
50 #define vmx_schedule_tail(next) \
51 (next)->thread.arch_vmx.arch_vmx_schedule_tail((next))
53 #define VMX_DOMAIN(ed) ((ed)->arch.arch_vmx.flags)
55 #define ARCH_VMX_VMCS_LOADED 0 /* VMCS has been loaded and active */
56 #define ARCH_VMX_VMCS_LAUNCH 1 /* Needs VMCS launch */
57 #define ARCH_VMX_VMCS_RESUME 2 /* Needs VMCS resume */
58 #define ARCH_VMX_IO_WAIT 3 /* Waiting for I/O completion */
60 void vmx_do_launch(struct exec_domain *);
61 void vmx_do_resume(struct exec_domain *);
63 struct vmcs_struct *alloc_vmcs(void);
64 void free_vmcs(struct vmcs_struct *);
65 int load_vmcs(struct arch_vmx_struct *, u64);
66 int store_vmcs(struct arch_vmx_struct *, u64);
67 void dump_vmcs(void);
68 int construct_vmcs(struct arch_vmx_struct *, execution_context_t *,
69 full_execution_context_t *, int);
71 #define VMCS_USE_HOST_ENV 1
72 #define VMCS_USE_SEPARATE_ENV 0
74 #define VMCS_EFLAGS_RESERVED_0 0xffc08028 /* bitmap for 0 */
75 #define VMCS_EFLAGS_RESERVED_1 0x00000002 /* bitmap for 1 */
77 extern int vmcs_version;
79 /* VMCS Encordings */
80 enum vmcs_field {
81 GUEST_ES_SELECTOR = 0x00000800,
82 GUEST_CS_SELECTOR = 0x00000802,
83 GUEST_SS_SELECTOR = 0x00000804,
84 GUEST_DS_SELECTOR = 0x00000806,
85 GUEST_FS_SELECTOR = 0x00000808,
86 GUEST_GS_SELECTOR = 0x0000080a,
87 GUEST_LDTR_SELECTOR = 0x0000080c,
88 GUEST_TR_SELECTOR = 0x0000080e,
89 HOST_ES_SELECTOR = 0x00000c00,
90 HOST_CS_SELECTOR = 0x00000c02,
91 HOST_SS_SELECTOR = 0x00000c04,
92 HOST_DS_SELECTOR = 0x00000c06,
93 HOST_FS_SELECTOR = 0x00000c08,
94 HOST_GS_SELECTOR = 0x00000c0a,
95 HOST_TR_SELECTOR = 0x00000c0c,
96 IO_BITMAP_A = 0x00002000,
97 IO_BITMAP_B = 0x00002002,
98 VM_EXIT_MSR_STORE_ADDR = 0x00002006,
99 VM_EXIT_MSR_LOAD_ADDR = 0x00002008,
100 VM_ENTRY_MSR_LOAD_ADDR = 0x0000200a,
101 TSC_OFFSET = 0x00002010,
102 GUEST_VMCS0 = 0x00002800,
103 GUEST_VMCS1 = 0x00002801,
104 GUEST_IA32_DEBUGCTL = 0x00002802,
105 PIN_BASED_VM_EXEC_CONTROL = 0x00004000,
106 CPU_BASED_VM_EXEC_CONTROL = 0x00004002,
107 EXCEPTION_BITMAP = 0x00004004,
108 PAGE_FAULT_ERROR_CODE_MASK = 0x00004006,
109 PAGE_FAULT_ERROR_CODE_MATCH = 0x00004008,
110 CR3_TARGET_COUNT = 0x0000400a,
111 VM_EXIT_CONTROLS = 0x0000400c,
112 VM_EXIT_MSR_STORE_COUNT = 0x0000400e,
113 VM_EXIT_MSR_LOAD_COUNT = 0x00004010,
114 VM_ENTRY_CONTROLS = 0x00004012,
115 VM_ENTRY_MSR_LOAD_COUNT = 0x00004014,
116 VM_ENTRY_INTR_INFO_FIELD = 0x00004016,
117 VM_ENTRY_EXCEPTION_ERROR_CODE = 0x00004018,
118 VM_EXIT_REASON = 0x00004402,
119 VM_EXIT_INTR_INFO = 0x00004404,
120 VM_EXIT_INTR_ERROR_CODE = 0x00004406,
121 IDT_VECTORING_INFO_FIELD = 0x00004408,
122 IDT_VECTORING_ERROR_CODE = 0x0000440a,
123 INSTRUCTION_LEN = 0x0000440c,
124 GUEST_ES_LIMIT = 0x00004800,
125 GUEST_CS_LIMIT = 0x00004802,
126 GUEST_SS_LIMIT = 0x00004804,
127 GUEST_DS_LIMIT = 0x00004806,
128 GUEST_FS_LIMIT = 0x00004808,
129 GUEST_GS_LIMIT = 0x0000480a,
130 GUEST_LDTR_LIMIT = 0x0000480c,
131 GUEST_TR_LIMIT = 0x0000480e,
132 GUEST_GDTR_LIMIT = 0x00004810,
133 GUEST_IDTR_LIMIT = 0x00004812,
134 GUEST_ES_AR_BYTES = 0x00004814,
135 GUEST_CS_AR_BYTES = 0x00004816,
136 GUEST_SS_AR_BYTES = 0x00004818,
137 GUEST_DS_AR_BYTES = 0x0000481a,
138 GUEST_FS_AR_BYTES = 0x0000481c,
139 GUEST_GS_AR_BYTES = 0x0000481e,
140 GUEST_LDTR_AR_BYTES = 0x00004820,
141 GUEST_TR_AR_BYTES = 0x00004822,
142 GUEST_INTERRUPTIBILITY_INFO = 0x00004824,
143 CR0_GUEST_HOST_MASK = 0x00006000,
144 CR4_GUEST_HOST_MASK = 0x00006002,
145 CR0_READ_SHADOW = 0x00006004,
146 CR4_READ_SHADOW = 0x00006006,
147 CR3_TARGET_VALUES = 0x00006008,
148 CR3_GUEST_HOST_MASK = 0x00006208,
149 EXIT_QUALIFICATION = 0x00006400,
150 GUEST_CR0 = 0x00006800,
151 GUEST_CR3 = 0x00006802,
152 GUEST_CR4 = 0x00006804,
153 GUEST_ES_BASE = 0x00006806,
154 GUEST_CS_BASE = 0x00006808,
155 GUEST_SS_BASE = 0x0000680a,
156 GUEST_DS_BASE = 0x0000680c,
157 GUEST_FS_BASE = 0x0000680e,
158 GUEST_GS_BASE = 0x00006810,
159 GUEST_LDTR_BASE = 0x00006812,
160 GUEST_TR_BASE = 0x00006814,
161 GUEST_GDTR_BASE = 0x00006816,
162 GUEST_IDTR_BASE = 0x00006818,
163 GUEST_DR7 = 0x0000681a,
164 GUEST_ESP = 0x0000681c,
165 GUEST_EIP = 0x0000681e,
166 GUEST_EFLAGS = 0x00006820,
167 GUEST_PENDING_DBG_EXCEPTIONS = 0x00006822,
168 HOST_CR0 = 0x00006c00,
169 HOST_CR3 = 0x00006c02,
170 HOST_CR4 = 0x00006c04,
171 HOST_FS_BASE = 0x00006c06,
172 HOST_GS_BASE = 0x00006c08,
173 HOST_TR_BASE = 0x00006c0a,
174 HOST_GDTR_BASE = 0x00006c0c,
175 HOST_IDTR_BASE = 0x00006c0e,
176 HOST_ESP = 0x00006c14,
177 HOST_EIP = 0x00006c16,
178 };
180 #define VMX_DEBUG 1
181 #if VMX_DEBUG
182 #define DBG_LEVEL_0 (1 << 0)
183 #define DBG_LEVEL_1 (1 << 1)
184 #define DBG_LEVEL_2 (1 << 2)
185 #define DBG_LEVEL_3 (1 << 3)
186 #define DBG_LEVEL_IO (1 << 4)
187 #define DBG_LEVEL_VMMU (1 << 5)
189 extern unsigned int opt_vmx_debug_level;
190 #define VMX_DBG_LOG(level, _f, _a...) \
191 if ((level) & opt_vmx_debug_level) \
192 printk("[VMX]" _f "\n", ## _a )
193 #else
194 #define VMX_DBG_LOG(level, _f, _a...)
195 #endif
197 #define __vmx_bug(regs) \
198 do { \
199 printk("__vmx_bug at %s:%d\n", __FILE__, __LINE__); \
200 show_registers(regs); \
201 domain_crash_synchronous(); \
202 } while (0)
204 #endif /* ASM_X86_VMX_VMCS_H__ */
206 /*
207 * Local variables:
208 * mode: C
209 * c-set-style: "BSD"
210 * c-basic-offset: 4
211 * tab-width: 4
212 * indent-tabs-mode: nil
213 * End:
214 */