ia64/xen-unstable

view xen/include/asm-x86/vmx.h @ 4586:5c732392ad8c

bitkeeper revision 1.1334 (42662de0c8DCr-P3F3XBjh8kE0IjpQ)

[PATCH] x86-64-longs.patch

Use the correct data type for x86-64

Signed-Off-By: Arun Sharma <arun.sharma@intel.com>
author arun.sharma@intel.com[kaf24]
date Wed Apr 20 10:24:32 2005 +0000 (2005-04-20)
parents 6a9598f401d9
children d769cf21930d
line source
1 /*
2 * vmx.h: VMX Architecture 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_H__
20 #define __ASM_X86_VMX_H__
22 #include <xen/sched.h>
23 #include <asm/types.h>
24 #include <asm/regs.h>
25 #include <asm/processor.h>
26 #include <asm/vmx_vmcs.h>
28 extern void vmx_asm_vmexit_handler(struct xen_regs);
29 extern void vmx_asm_do_resume(void);
30 extern void vmx_asm_do_launch(void);
31 extern void vmx_intr_assist(struct exec_domain *d);
33 extern void arch_vmx_do_launch(struct exec_domain *);
34 extern void arch_vmx_do_resume(struct exec_domain *);
36 extern int vmcs_size;
37 extern unsigned int cpu_rev;
39 /*
40 * Need fill bits for SENTER
41 */
43 #define MONITOR_PIN_BASED_EXEC_CONTROLS 0x0000001f
44 #define MONITOR_CPU_BASED_EXEC_CONTROLS 0x0581e7f2
45 #define MONITOR_VM_EXIT_CONTROLS 0x0003edff
46 #define MONITOR_VM_ENTRY_CONTROLS 0x000011ff
48 /*
49 * Exit Reasons
50 */
51 #define VMX_EXIT_REASONS_FAILED_VMENTRY 0x80000000
53 #define EXIT_REASON_EXCEPTION_NMI 0
54 #define EXIT_REASON_EXTERNAL_INTERRUPT 1
56 #define EXIT_REASON_PENDING_INTERRUPT 7
58 #define EXIT_REASON_TASK_SWITCH 9
59 #define EXIT_REASON_CPUID 10
60 #define EXIT_REASON_HLT 12
61 #define EXIT_REASON_INVLPG 14
62 #define EXIT_REASON_RDPMC 15
63 #define EXIT_REASON_RDTSC 16
64 #define EXIT_REASON_VMCALL 18
66 #define EXIT_REASON_CR_ACCESS 28
67 #define EXIT_REASON_DR_ACCESS 29
68 #define EXIT_REASON_IO_INSTRUCTION 30
69 #define EXIT_REASON_MSR_READ 31
70 #define EXIT_REASON_MSR_WRITE 32
71 #define EXIT_REASON_MWAIT_INSTRUCTION 36
73 /*
74 * Interruption-information format
75 */
76 #define INTR_INFO_VECTOR_MASK 0xff /* 7:0 */
77 #define INTR_INFO_INTR_TYPE_MASK 0x700 /* 10:8 */
78 #define INTR_INFO_DELIEVER_CODE_MASK 0x800 /* 11 */
79 #define INTR_INFO_VALID_MASK 0x80000000 /* 31 */
81 #define INTR_TYPE_EXT_INTR (0 << 8) /* external interrupt */
82 #define INTR_TYPE_EXCEPTION (3 << 8) /* processor exception */
84 /*
85 * Exit Qualifications for MOV for Control Register Access
86 */
87 #define CONTROL_REG_ACCESS_NUM 0x7 /* 2:0, number of control register */
88 #define CONTROL_REG_ACCESS_TYPE 0x30 /* 5:4, access type */
89 #define TYPE_MOV_TO_CR (0 << 4)
90 #define TYPE_MOV_FROM_CR (1 << 4)
91 #define TYPE_CLTS (2 << 4)
92 #define CONTROL_REG_ACCESS_REG 0x700 /* 10:8, general purpose register */
93 #define REG_EAX (0 << 8)
94 #define REG_ECX (1 << 8)
95 #define REG_EDX (2 << 8)
96 #define REG_EBX (3 << 8)
97 #define REG_ESP (4 << 8)
98 #define REG_EBP (5 << 8)
99 #define REG_ESI (6 << 8)
100 #define REG_EDI (7 << 8)
102 /*
103 * Exit Qualifications for MOV for Debug Register Access
104 */
105 #define DEBUG_REG_ACCESS_NUM 0x7 /* 2:0, number of debug register */
106 #define DEBUG_REG_ACCESS_TYPE 0x10 /* 4, direction of access */
107 #define TYPE_MOV_TO_DR (0 << 4)
108 #define TYPE_MOV_FROM_DR (1 << 4)
109 #define DEBUG_REG_ACCESS_REG 0x700 /* 11:8, general purpose register */
111 #define EXCEPTION_BITMAP_DE (1 << 0) /* Divide Error */
112 #define EXCEPTION_BITMAP_DB (1 << 1) /* Debug */
113 #define EXCEPTION_BITMAP_NMI (1 << 2) /* NMI */
114 #define EXCEPTION_BITMAP_BP (1 << 3) /* Breakpoint */
115 #define EXCEPTION_BITMAP_OF (1 << 4) /* Overflow */
116 #define EXCEPTION_BITMAP_BR (1 << 5) /* BOUND Range Exceeded */
117 #define EXCEPTION_BITMAP_UD (1 << 6) /* Invalid Opcode */
118 #define EXCEPTION_BITMAP_NM (1 << 7) /* Device Not Available */
119 #define EXCEPTION_BITMAP_DF (1 << 8) /* Double Fault */
120 /* reserved */
121 #define EXCEPTION_BITMAP_TS (1 << 10) /* Invalid TSS */
122 #define EXCEPTION_BITMAP_NP (1 << 11) /* Segment Not Present */
123 #define EXCEPTION_BITMAP_SS (1 << 12) /* Stack-Segment Fault */
124 #define EXCEPTION_BITMAP_GP (1 << 13) /* General Protection */
125 #define EXCEPTION_BITMAP_PG (1 << 14) /* Page Fault */
126 #define EXCEPTION_BITMAP_MF (1 << 16) /* x87 FPU Floating-Point Error (Math Fault) */
127 #define EXCEPTION_BITMAP_AC (1 << 17) /* Alignment Check */
128 #define EXCEPTION_BITMAP_MC (1 << 18) /* Machine Check */
129 #define EXCEPTION_BITMAP_XF (1 << 19) /* SIMD Floating-Point Exception */
131 #ifdef XEN_DEBUGGER
132 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
133 ( EXCEPTION_BITMAP_PG | \
134 EXCEPTION_BITMAP_DB | \
135 EXCEPTION_BITMAP_BP | \
136 EXCEPTION_BITMAP_GP )
137 #else
138 #define MONITOR_DEFAULT_EXCEPTION_BITMAP \
139 ( EXCEPTION_BITMAP_PG | \
140 EXCEPTION_BITMAP_GP )
141 #endif
143 #define VMCALL_OPCODE ".byte 0x0f,0x01,0xc1\n"
144 #define VMCLEAR_OPCODE ".byte 0x66,0x0f,0xc7\n" /* reg/opcode: /6 */
145 #define VMLAUNCH_OPCODE ".byte 0x0f,0x01,0xc2\n"
146 #define VMPTRLD_OPCODE ".byte 0x0f,0xc7\n" /* reg/opcode: /6 */
147 #define VMPTRST_OPCODE ".byte 0x0f,0xc7\n" /* reg/opcode: /7 */
148 #define VMREAD_OPCODE ".byte 0x0f,0x78\n"
149 #define VMRESUME_OPCODE ".byte 0x0f,0x01,0xc3\n"
150 #define VMWRITE_OPCODE ".byte 0x0f,0x79\n"
151 #define VMXOFF_OPCODE ".byte 0x0f,0x01,0xc4\n"
152 #define VMXON_OPCODE ".byte 0xf3,0x0f,0xc7\n"
154 #define MODRM_EAX_06 ".byte 0x30\n" /* [EAX], with reg/opcode: /6 */
155 #define MODRM_EAX_07 ".byte 0x38\n" /* [EAX], with reg/opcode: /7 */
156 #define MODRM_EAX_ECX ".byte 0xc1\n" /* [EAX], [ECX] */
158 static inline int __vmptrld (u64 addr)
159 {
160 unsigned long eflags;
161 __asm__ __volatile__ ( VMPTRLD_OPCODE
162 MODRM_EAX_06
163 :
164 : "a" (&addr)
165 : "memory");
167 __save_flags(eflags);
168 if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF)
169 return -1;
170 return 0;
171 }
173 static inline void __vmptrst (u64 addr)
174 {
175 __asm__ __volatile__ ( VMPTRST_OPCODE
176 MODRM_EAX_07
177 :
178 : "a" (&addr)
179 : "memory");
180 }
182 static inline int __vmpclear (u64 addr)
183 {
184 unsigned long eflags;
186 __asm__ __volatile__ ( VMCLEAR_OPCODE
187 MODRM_EAX_06
188 :
189 : "a" (&addr)
190 : "memory");
191 __save_flags(eflags);
192 if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF)
193 return -1;
194 return 0;
195 }
197 static inline int __vmread (unsigned long field, void *value)
198 {
199 unsigned long eflags;
200 unsigned long ecx = 0;
202 __asm__ __volatile__ ( VMREAD_OPCODE
203 MODRM_EAX_ECX
204 : "=c" (ecx)
205 : "a" (field)
206 : "memory");
208 *((long *) value) = ecx;
210 __save_flags(eflags);
211 if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF)
212 return -1;
213 return 0;
214 }
216 static inline int __vmwrite (unsigned long field, unsigned long value)
217 {
218 unsigned long eflags;
220 __asm__ __volatile__ ( VMWRITE_OPCODE
221 MODRM_EAX_ECX
222 :
223 : "a" (field) , "c" (value)
224 : "memory");
225 __save_flags(eflags);
226 if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF)
227 return -1;
228 return 0;
229 }
231 static inline void __vmxoff (void)
232 {
233 __asm__ __volatile__ ( VMXOFF_OPCODE
234 ::: "memory");
235 }
237 static inline int __vmxon (u64 addr)
238 {
239 unsigned long eflags;
241 __asm__ __volatile__ ( VMXON_OPCODE
242 MODRM_EAX_06
243 :
244 : "a" (&addr)
245 : "memory");
246 __save_flags(eflags);
247 if (eflags & X86_EFLAGS_ZF || eflags & X86_EFLAGS_CF)
248 return -1;
249 return 0;
250 }
252 #endif /* __ASM_X86_VMX_H__ */