ia64/xen-unstable

annotate xen/include/asm-x86/hvm/vmx/vmcs.h @ 10902:022f29d4d2b8

[HVM][VMX] Clean up vmx hvm interface functions:
1) define vmx hvm interface functions static.
2) setup hvm interface functions only once.

Signed-off-by: Xin Li <xin.b.li@intel.com>
author kfraser@localhost.localdomain
date Wed Aug 02 09:38:08 2006 +0100 (2006-08-02)
parents 82f481bda1c7
children d20e1835c24b
rev   line source
kaf24@8708 1 /*
kaf24@8708 2 * vmcs.h: VMCS related definitions
kaf24@8708 3 * Copyright (c) 2004, Intel Corporation.
kaf24@8708 4 *
kaf24@8708 5 * This program is free software; you can redistribute it and/or modify it
kaf24@8708 6 * under the terms and conditions of the GNU General Public License,
kaf24@8708 7 * version 2, as published by the Free Software Foundation.
kaf24@8708 8 *
kaf24@8708 9 * This program is distributed in the hope it will be useful, but WITHOUT
kaf24@8708 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kaf24@8708 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
kaf24@8708 12 * more details.
kaf24@8708 13 *
kaf24@8708 14 * You should have received a copy of the GNU General Public License along with
kaf24@8708 15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
kaf24@8708 16 * Place - Suite 330, Boston, MA 02111-1307 USA.
kaf24@8708 17 *
kaf24@8708 18 */
kaf24@8708 19 #ifndef __ASM_X86_HVM_VMX_VMCS_H__
kaf24@8708 20 #define __ASM_X86_HVM_VMX_VMCS_H__
kaf24@8708 21
kaf24@8708 22 #include <asm/config.h>
kaf24@8708 23 #include <asm/hvm/io.h>
kaf24@8708 24 #include <asm/hvm/vmx/cpu.h>
kaf24@8708 25 #include <public/hvm/vmx_assist.h>
kaf24@8708 26
kaf24@8708 27 extern int start_vmx(void);
kaf24@10079 28 extern void vmcs_dump_vcpu(void);
kfraser@10648 29 extern void vmx_init_vmcs_config(void);
kaf24@8708 30
kaf24@8708 31 enum {
kaf24@9290 32 VMX_CPU_STATE_PAE_ENABLED=0,
kaf24@8708 33 VMX_CPU_STATE_LME_ENABLED,
kaf24@8708 34 VMX_CPU_STATE_LMA_ENABLED,
kaf24@8708 35 VMX_CPU_STATE_ASSIST_ENABLED,
kaf24@8708 36 };
kaf24@8708 37
kaf24@8708 38 #define VMX_LONG_GUEST(ed) \
kaf24@8708 39 (test_bit(VMX_CPU_STATE_LMA_ENABLED, &ed->arch.hvm_vmx.cpu_state))
kaf24@8708 40
kaf24@8708 41 struct vmcs_struct {
kaf24@8708 42 u32 vmcs_revision_id;
kaf24@8708 43 unsigned char data [0]; /* vmcs size is read from MSR */
kaf24@8708 44 };
kaf24@8708 45
kaf24@8708 46 enum {
kaf24@8708 47 VMX_INDEX_MSR_LSTAR = 0,
kaf24@8708 48 VMX_INDEX_MSR_STAR,
kaf24@8708 49 VMX_INDEX_MSR_CSTAR,
kaf24@8708 50 VMX_INDEX_MSR_SYSCALL_MASK,
kaf24@8708 51 VMX_INDEX_MSR_EFER,
kaf24@8708 52
kaf24@8708 53 VMX_MSR_COUNT,
kaf24@8708 54 };
kaf24@8708 55
kaf24@8708 56 struct vmx_msr_state {
kaf24@8708 57 unsigned long flags;
kaf24@8708 58 unsigned long msr_items[VMX_MSR_COUNT];
kaf24@8708 59 unsigned long shadow_gs;
kaf24@8708 60 };
kaf24@8708 61
kfraser@10648 62 /* io bitmap is 4KBytes in size */
kfraser@10648 63 #define IO_BITMAP_SIZE 0x1000
kfraser@10648 64 #define IO_BITMAP_ORDER (get_order_from_bytes(IO_BITMAP_SIZE))
kfraser@10648 65
kaf24@8708 66 struct arch_vmx_struct {
kaf24@10356 67 /* Virtual address of VMCS. */
kaf24@10356 68 struct vmcs_struct *vmcs;
kaf24@10356 69
kaf24@10356 70 /* Protects remote usage of VMCS (VMPTRLD/VMCLEAR). */
kaf24@10356 71 spinlock_t vmcs_lock;
kaf24@10356 72
kaf24@10356 73 /*
kaf24@10356 74 * Activation and launch status of this VMCS.
kaf24@10356 75 * - Activated on a CPU by VMPTRLD. Deactivated by VMCLEAR.
kaf24@10356 76 * - Launched on active CPU by VMLAUNCH when current VMCS.
kaf24@10356 77 */
kaf24@10356 78 int active_cpu;
kaf24@10356 79 int launched;
kaf24@10356 80
kaf24@10356 81 /* Cache of cpu execution control. */
kaf24@10356 82 u32 exec_control;
kaf24@10356 83
kaf24@10356 84 /* If there is vector installed in the INTR_INFO_FIELD. */
kaf24@10356 85 u32 vector_injected;
kaf24@10356 86
kaf24@10356 87 unsigned long cpu_cr0; /* copy of guest CR0 */
kaf24@10356 88 unsigned long cpu_shadow_cr0; /* copy of guest read shadow CR0 */
kaf24@10356 89 unsigned long cpu_cr2; /* save CR2 */
kaf24@10356 90 unsigned long cpu_cr3;
kaf24@10356 91 unsigned long cpu_state;
kaf24@10356 92 unsigned long cpu_based_exec_control;
kaf24@10356 93 struct vmx_msr_state msr_content;
kaf24@10356 94 void *io_bitmap_a, *io_bitmap_b;
kaf24@10356 95 struct timer hlt_timer; /* hlt ins emulation wakeup timer */
kaf24@8708 96 };
kaf24@8708 97
kaf24@8708 98 #define vmx_schedule_tail(next) \
kaf24@8708 99 (next)->thread.arch_vmx.arch_vmx_schedule_tail((next))
kaf24@8708 100
kaf24@10356 101 void vmx_do_resume(struct vcpu *);
kaf24@8708 102
kfraser@10648 103 struct vmcs_struct *vmx_alloc_host_vmcs(void);
kfraser@10648 104 void vmx_free_host_vmcs(struct vmcs_struct *vmcs);
kfraser@10648 105
kfraser@10648 106 int vmx_create_vmcs(struct vcpu *v);
kaf24@10356 107 void vmx_destroy_vmcs(struct vcpu *v);
kaf24@10356 108 void vmx_vmcs_enter(struct vcpu *v);
kaf24@10356 109 void vmx_vmcs_exit(struct vcpu *v);
kaf24@8806 110
kaf24@8708 111 #define VMCS_USE_HOST_ENV 1
kaf24@8708 112 #define VMCS_USE_SEPARATE_ENV 0
kaf24@8708 113
kaf24@8708 114 extern int vmcs_version;
kaf24@8708 115
kaf24@8708 116 #define CPU_BASED_VIRTUAL_INTR_PENDING 0x00000004
kaf24@8708 117 #define CPU_BASED_USE_TSC_OFFSETING 0x00000008
kaf24@8708 118 #define CPU_BASED_HLT_EXITING 0x00000080
kaf24@8708 119 #define CPU_BASED_INVDPG_EXITING 0x00000200
kaf24@8708 120 #define CPU_BASED_MWAIT_EXITING 0x00000400
kaf24@8708 121 #define CPU_BASED_RDPMC_EXITING 0x00000800
kaf24@8708 122 #define CPU_BASED_RDTSC_EXITING 0x00001000
kaf24@8708 123 #define CPU_BASED_CR8_LOAD_EXITING 0x00080000
kaf24@8708 124 #define CPU_BASED_CR8_STORE_EXITING 0x00100000
kaf24@8708 125 #define CPU_BASED_TPR_SHADOW 0x00200000
kaf24@8708 126 #define CPU_BASED_MOV_DR_EXITING 0x00800000
kaf24@8708 127 #define CPU_BASED_UNCOND_IO_EXITING 0x01000000
kaf24@8708 128 #define CPU_BASED_ACTIVATE_IO_BITMAP 0x02000000
kaf24@8708 129 #define CPU_BASED_MONITOR_EXITING 0x20000000
kaf24@8708 130 #define CPU_BASED_PAUSE_EXITING 0x40000000
kaf24@8708 131 #define PIN_BASED_EXT_INTR_MASK 0x1
kaf24@8708 132 #define PIN_BASED_NMI_EXITING 0x8
kaf24@8708 133
kaf24@8708 134 #define VM_EXIT_ACK_INTR_ON_EXIT 0x00008000
kaf24@8708 135 #define VM_EXIT_HOST_ADD_SPACE_SIZE 0x00000200
kaf24@8708 136
kaf24@8708 137
kaf24@8708 138 /* VMCS Encordings */
kaf24@8708 139 enum vmcs_field {
kaf24@8708 140 GUEST_ES_SELECTOR = 0x00000800,
kaf24@8708 141 GUEST_CS_SELECTOR = 0x00000802,
kaf24@8708 142 GUEST_SS_SELECTOR = 0x00000804,
kaf24@8708 143 GUEST_DS_SELECTOR = 0x00000806,
kaf24@8708 144 GUEST_FS_SELECTOR = 0x00000808,
kaf24@8708 145 GUEST_GS_SELECTOR = 0x0000080a,
kaf24@8708 146 GUEST_LDTR_SELECTOR = 0x0000080c,
kaf24@8708 147 GUEST_TR_SELECTOR = 0x0000080e,
kaf24@8708 148 HOST_ES_SELECTOR = 0x00000c00,
kaf24@8708 149 HOST_CS_SELECTOR = 0x00000c02,
kaf24@8708 150 HOST_SS_SELECTOR = 0x00000c04,
kaf24@8708 151 HOST_DS_SELECTOR = 0x00000c06,
kaf24@8708 152 HOST_FS_SELECTOR = 0x00000c08,
kaf24@8708 153 HOST_GS_SELECTOR = 0x00000c0a,
kaf24@8708 154 HOST_TR_SELECTOR = 0x00000c0c,
kaf24@8708 155 IO_BITMAP_A = 0x00002000,
kaf24@8708 156 IO_BITMAP_A_HIGH = 0x00002001,
kaf24@8708 157 IO_BITMAP_B = 0x00002002,
kaf24@8708 158 IO_BITMAP_B_HIGH = 0x00002003,
kaf24@8708 159 VM_EXIT_MSR_STORE_ADDR = 0x00002006,
kaf24@8708 160 VM_EXIT_MSR_STORE_ADDR_HIGH = 0x00002007,
kaf24@8708 161 VM_EXIT_MSR_LOAD_ADDR = 0x00002008,
kaf24@8708 162 VM_EXIT_MSR_LOAD_ADDR_HIGH = 0x00002009,
kaf24@8708 163 VM_ENTRY_MSR_LOAD_ADDR = 0x0000200a,
kaf24@8708 164 VM_ENTRY_MSR_LOAD_ADDR_HIGH = 0x0000200b,
kaf24@8708 165 TSC_OFFSET = 0x00002010,
kaf24@8708 166 TSC_OFFSET_HIGH = 0x00002011,
kaf24@8708 167 VIRTUAL_APIC_PAGE_ADDR = 0x00002012,
kaf24@8708 168 VIRTUAL_APIC_PAGE_ADDR_HIGH = 0x00002013,
kaf24@8708 169 VMCS_LINK_POINTER = 0x00002800,
kaf24@8708 170 VMCS_LINK_POINTER_HIGH = 0x00002801,
kaf24@8708 171 GUEST_IA32_DEBUGCTL = 0x00002802,
kaf24@8708 172 GUEST_IA32_DEBUGCTL_HIGH = 0x00002803,
kaf24@8708 173 PIN_BASED_VM_EXEC_CONTROL = 0x00004000,
kaf24@8708 174 CPU_BASED_VM_EXEC_CONTROL = 0x00004002,
kaf24@8708 175 EXCEPTION_BITMAP = 0x00004004,
kaf24@8708 176 PAGE_FAULT_ERROR_CODE_MASK = 0x00004006,
kaf24@8708 177 PAGE_FAULT_ERROR_CODE_MATCH = 0x00004008,
kaf24@8708 178 CR3_TARGET_COUNT = 0x0000400a,
kaf24@8708 179 VM_EXIT_CONTROLS = 0x0000400c,
kaf24@8708 180 VM_EXIT_MSR_STORE_COUNT = 0x0000400e,
kaf24@8708 181 VM_EXIT_MSR_LOAD_COUNT = 0x00004010,
kaf24@8708 182 VM_ENTRY_CONTROLS = 0x00004012,
kaf24@8708 183 VM_ENTRY_MSR_LOAD_COUNT = 0x00004014,
kaf24@8708 184 VM_ENTRY_INTR_INFO_FIELD = 0x00004016,
kaf24@8708 185 VM_ENTRY_EXCEPTION_ERROR_CODE = 0x00004018,
kaf24@8708 186 VM_ENTRY_INSTRUCTION_LEN = 0x0000401a,
kaf24@8708 187 TPR_THRESHOLD = 0x0000401c,
kaf24@8708 188 SECONDARY_VM_EXEC_CONTROL = 0x0000401e,
kaf24@8708 189 VM_INSTRUCTION_ERROR = 0x00004400,
kaf24@8708 190 VM_EXIT_REASON = 0x00004402,
kaf24@8708 191 VM_EXIT_INTR_INFO = 0x00004404,
kaf24@8708 192 VM_EXIT_INTR_ERROR_CODE = 0x00004406,
kaf24@8708 193 IDT_VECTORING_INFO_FIELD = 0x00004408,
kaf24@8708 194 IDT_VECTORING_ERROR_CODE = 0x0000440a,
kaf24@8708 195 VM_EXIT_INSTRUCTION_LEN = 0x0000440c,
kaf24@8708 196 VMX_INSTRUCTION_INFO = 0x0000440e,
kaf24@8708 197 GUEST_ES_LIMIT = 0x00004800,
kaf24@8708 198 GUEST_CS_LIMIT = 0x00004802,
kaf24@8708 199 GUEST_SS_LIMIT = 0x00004804,
kaf24@8708 200 GUEST_DS_LIMIT = 0x00004806,
kaf24@8708 201 GUEST_FS_LIMIT = 0x00004808,
kaf24@8708 202 GUEST_GS_LIMIT = 0x0000480a,
kaf24@8708 203 GUEST_LDTR_LIMIT = 0x0000480c,
kaf24@8708 204 GUEST_TR_LIMIT = 0x0000480e,
kaf24@8708 205 GUEST_GDTR_LIMIT = 0x00004810,
kaf24@8708 206 GUEST_IDTR_LIMIT = 0x00004812,
kaf24@8708 207 GUEST_ES_AR_BYTES = 0x00004814,
kaf24@8708 208 GUEST_CS_AR_BYTES = 0x00004816,
kaf24@8708 209 GUEST_SS_AR_BYTES = 0x00004818,
kaf24@8708 210 GUEST_DS_AR_BYTES = 0x0000481a,
kaf24@8708 211 GUEST_FS_AR_BYTES = 0x0000481c,
kaf24@8708 212 GUEST_GS_AR_BYTES = 0x0000481e,
kaf24@8708 213 GUEST_LDTR_AR_BYTES = 0x00004820,
kaf24@8708 214 GUEST_TR_AR_BYTES = 0x00004822,
kaf24@8708 215 GUEST_INTERRUPTIBILITY_INFO = 0x00004824,
kaf24@8708 216 GUEST_SYSENTER_CS = 0x0000482A,
kaf24@8708 217 HOST_IA32_SYSENTER_CS = 0x00004c00,
kaf24@8708 218 CR0_GUEST_HOST_MASK = 0x00006000,
kaf24@8708 219 CR4_GUEST_HOST_MASK = 0x00006002,
kaf24@8708 220 CR0_READ_SHADOW = 0x00006004,
kaf24@8708 221 CR4_READ_SHADOW = 0x00006006,
kaf24@8708 222 CR3_TARGET_VALUE0 = 0x00006008,
kaf24@8708 223 CR3_TARGET_VALUE1 = 0x0000600a,
kaf24@8708 224 CR3_TARGET_VALUE2 = 0x0000600c,
kaf24@8708 225 CR3_TARGET_VALUE3 = 0x0000600e,
kaf24@8708 226 EXIT_QUALIFICATION = 0x00006400,
kaf24@8708 227 GUEST_LINEAR_ADDRESS = 0x0000640a,
kaf24@8708 228 GUEST_CR0 = 0x00006800,
kaf24@8708 229 GUEST_CR3 = 0x00006802,
kaf24@8708 230 GUEST_CR4 = 0x00006804,
kaf24@8708 231 GUEST_ES_BASE = 0x00006806,
kaf24@8708 232 GUEST_CS_BASE = 0x00006808,
kaf24@8708 233 GUEST_SS_BASE = 0x0000680a,
kaf24@8708 234 GUEST_DS_BASE = 0x0000680c,
kaf24@8708 235 GUEST_FS_BASE = 0x0000680e,
kaf24@8708 236 GUEST_GS_BASE = 0x00006810,
kaf24@8708 237 GUEST_LDTR_BASE = 0x00006812,
kaf24@8708 238 GUEST_TR_BASE = 0x00006814,
kaf24@8708 239 GUEST_GDTR_BASE = 0x00006816,
kaf24@8708 240 GUEST_IDTR_BASE = 0x00006818,
kaf24@8708 241 GUEST_DR7 = 0x0000681a,
kaf24@8708 242 GUEST_RSP = 0x0000681c,
kaf24@8708 243 GUEST_RIP = 0x0000681e,
kaf24@8708 244 GUEST_RFLAGS = 0x00006820,
kaf24@8708 245 GUEST_PENDING_DBG_EXCEPTIONS = 0x00006822,
kaf24@8708 246 GUEST_SYSENTER_ESP = 0x00006824,
kaf24@8708 247 GUEST_SYSENTER_EIP = 0x00006826,
kaf24@8708 248 HOST_CR0 = 0x00006c00,
kaf24@8708 249 HOST_CR3 = 0x00006c02,
kaf24@8708 250 HOST_CR4 = 0x00006c04,
kaf24@8708 251 HOST_FS_BASE = 0x00006c06,
kaf24@8708 252 HOST_GS_BASE = 0x00006c08,
kaf24@8708 253 HOST_TR_BASE = 0x00006c0a,
kaf24@8708 254 HOST_GDTR_BASE = 0x00006c0c,
kaf24@8708 255 HOST_IDTR_BASE = 0x00006c0e,
kaf24@8708 256 HOST_IA32_SYSENTER_ESP = 0x00006c10,
kaf24@8708 257 HOST_IA32_SYSENTER_EIP = 0x00006c12,
kaf24@8708 258 HOST_RSP = 0x00006c14,
kaf24@8708 259 HOST_RIP = 0x00006c16,
kaf24@8708 260 };
kaf24@8708 261
kaf24@8708 262 #endif /* ASM_X86_HVM_VMX_VMCS_H__ */
kaf24@8708 263
kaf24@8708 264 /*
kaf24@8708 265 * Local variables:
kaf24@8708 266 * mode: C
kaf24@8708 267 * c-set-style: "BSD"
kaf24@8708 268 * c-basic-offset: 4
kaf24@8708 269 * tab-width: 4
kaf24@8708 270 * indent-tabs-mode: nil
kaf24@8708 271 * End:
kaf24@8708 272 */