direct-io.hg
changeset 13613:fde9e1d474b7
hvm: Define a global I/O access bitmap, allowing direct access to port 0x80.
Signed-off-by: Keir Fraser <keir@xensource.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kfraser@localhost.localdomain |
---|---|
date | Thu Jan 25 18:20:58 2007 +0000 (2007-01-25) |
parents | 9e4f61bb200e |
children | 1abb694a52df |
files | xen/arch/x86/hvm/hvm.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/support.h xen/include/asm-x86/hvm/svm/vmcb.h |
line diff
1.1 --- a/xen/arch/x86/hvm/hvm.c Thu Jan 25 17:00:18 2007 +0000 1.2 +++ b/xen/arch/x86/hvm/hvm.c Thu Jan 25 18:20:58 2007 +0000 1.3 @@ -50,13 +50,32 @@ 1.4 #include <public/version.h> 1.5 #include <public/memory.h> 1.6 1.7 -int hvm_enabled = 0; 1.8 +int hvm_enabled; 1.9 1.10 -unsigned int opt_hvm_debug_level = 0; 1.11 +unsigned int opt_hvm_debug_level; 1.12 integer_param("hvm_debug", opt_hvm_debug_level); 1.13 1.14 struct hvm_function_table hvm_funcs; 1.15 1.16 +/* I/O permission bitmap is globally shared by all HVM guests. */ 1.17 +char __attribute__ ((__section__ (".bss.page_aligned"))) 1.18 + hvm_io_bitmap[3*PAGE_SIZE]; 1.19 + 1.20 +void hvm_enable(void) 1.21 +{ 1.22 + if ( hvm_enabled ) 1.23 + return; 1.24 + 1.25 + /* 1.26 + * Allow direct access to the PC debug port (it is often used for I/O 1.27 + * delays, but the vmexits simply slow things down). 1.28 + */ 1.29 + memset(hvm_io_bitmap, ~0, sizeof(hvm_io_bitmap)); 1.30 + clear_bit(0x80, hvm_io_bitmap); 1.31 + 1.32 + hvm_enabled = 1; 1.33 +} 1.34 + 1.35 void hvm_stts(struct vcpu *v) 1.36 { 1.37 /* FPU state already dirty? Then no need to setup_fpu() lazily. */
2.1 --- a/xen/arch/x86/hvm/svm/svm.c Thu Jan 25 17:00:18 2007 +0000 2.2 +++ b/xen/arch/x86/hvm/svm/svm.c Thu Jan 25 18:20:58 2007 +0000 2.3 @@ -1069,7 +1069,7 @@ int start_svm(void) 2.4 hvm_funcs.init_ap_context = svm_init_ap_context; 2.5 hvm_funcs.init_hypercall_page = svm_init_hypercall_page; 2.6 2.7 - hvm_enabled = 1; 2.8 + hvm_enable(); 2.9 2.10 return 1; 2.11 }
3.1 --- a/xen/arch/x86/hvm/svm/vmcb.c Thu Jan 25 17:00:18 2007 +0000 3.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c Thu Jan 25 18:20:58 2007 +0000 3.3 @@ -115,19 +115,12 @@ static int construct_vmcb(struct vcpu *v 3.4 vmcb->cr_intercepts = ~(CR_INTERCEPT_CR2_READ | CR_INTERCEPT_CR2_WRITE); 3.5 3.6 /* I/O and MSR permission bitmaps. */ 3.7 - arch_svm->iopm = alloc_xenheap_pages(get_order_from_bytes(IOPM_SIZE)); 3.8 arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE)); 3.9 - if ( (arch_svm->iopm == NULL) || (arch_svm->msrpm == NULL) ) 3.10 - { 3.11 - free_xenheap_pages(arch_svm->iopm, get_order_from_bytes(IOPM_SIZE)); 3.12 - free_xenheap_pages(arch_svm->msrpm, get_order_from_bytes(MSRPM_SIZE)); 3.13 + if ( arch_svm->msrpm == NULL ) 3.14 return -ENOMEM; 3.15 - } 3.16 - memset(arch_svm->iopm, 0xff, IOPM_SIZE); 3.17 - clear_bit(PC_DEBUG_PORT, arch_svm->iopm); 3.18 memset(arch_svm->msrpm, 0xff, MSRPM_SIZE); 3.19 - vmcb->iopm_base_pa = (u64)virt_to_maddr(arch_svm->iopm); 3.20 vmcb->msrpm_base_pa = (u64)virt_to_maddr(arch_svm->msrpm); 3.21 + vmcb->iopm_base_pa = (u64)virt_to_maddr(hvm_io_bitmap); 3.22 3.23 /* Virtualise EFLAGS.IF and LAPIC TPR (CR8). */ 3.24 vmcb->vintr.fields.intr_masking = 1; 3.25 @@ -241,13 +234,6 @@ void svm_destroy_vmcb(struct vcpu *v) 3.26 if ( arch_svm->vmcb != NULL ) 3.27 free_vmcb(arch_svm->vmcb); 3.28 3.29 - if ( arch_svm->iopm != NULL ) 3.30 - { 3.31 - free_xenheap_pages( 3.32 - arch_svm->iopm, get_order_from_bytes(IOPM_SIZE)); 3.33 - arch_svm->iopm = NULL; 3.34 - } 3.35 - 3.36 if ( arch_svm->msrpm != NULL ) 3.37 { 3.38 free_xenheap_pages(
4.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c Thu Jan 25 17:00:18 2007 +0000 4.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c Thu Jan 25 18:20:58 2007 +0000 4.3 @@ -56,7 +56,7 @@ 4.4 CPU_BASED_INVDPG_EXITING | \ 4.5 CPU_BASED_MWAIT_EXITING | \ 4.6 CPU_BASED_MOV_DR_EXITING | \ 4.7 - CPU_BASED_UNCOND_IO_EXITING | \ 4.8 + CPU_BASED_ACTIVATE_IO_BITMAP | \ 4.9 CPU_BASED_USE_TSC_OFFSETING ) 4.10 4.11 /* Basic flags for VM-Exit controls. */ 4.12 @@ -302,6 +302,10 @@ static void construct_vmcs(struct vcpu * 4.13 __vmwrite(CPU_BASED_VM_EXEC_CONTROL, vmx_cpu_based_exec_control); 4.14 v->arch.hvm_vcpu.u.vmx.exec_control = vmx_cpu_based_exec_control; 4.15 4.16 + /* I/O access bitmap. */ 4.17 + __vmwrite(IO_BITMAP_A, virt_to_maddr(hvm_io_bitmap)); 4.18 + __vmwrite(IO_BITMAP_B, virt_to_maddr(hvm_io_bitmap + PAGE_SIZE)); 4.19 + 4.20 /* Host data selectors. */ 4.21 __vmwrite(HOST_SS_SELECTOR, __HYPERVISOR_DS); 4.22 __vmwrite(HOST_DS_SELECTOR, __HYPERVISOR_DS);
5.1 --- a/xen/arch/x86/hvm/vmx/vmx.c Thu Jan 25 17:00:18 2007 +0000 5.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Jan 25 18:20:58 2007 +0000 5.3 @@ -1011,9 +1011,6 @@ static void vmx_inject_exception( 5.4 /* Setup HVM interfaces */ 5.5 static void vmx_setup_hvm_funcs(void) 5.6 { 5.7 - if ( hvm_enabled ) 5.8 - return; 5.9 - 5.10 hvm_funcs.disable = stop_vmx; 5.11 5.12 hvm_funcs.vcpu_initialise = vmx_vcpu_initialise; 5.13 @@ -1104,7 +1101,7 @@ int start_vmx(void) 5.14 5.15 vmx_setup_hvm_funcs(); 5.16 5.17 - hvm_enabled = 1; 5.18 + hvm_enable(); 5.19 5.20 return 1; 5.21 }
6.1 --- a/xen/include/asm-x86/hvm/support.h Thu Jan 25 17:00:18 2007 +0000 6.2 +++ b/xen/include/asm-x86/hvm/support.h Thu Jan 25 18:20:58 2007 +0000 6.3 @@ -90,8 +90,6 @@ enum hval_bitmaps { 6.4 EXCEPTION_BITMAP_BP ) 6.5 #endif 6.6 6.7 -#define PC_DEBUG_PORT 0x80 6.8 - 6.9 #define VMX_DELIVER_NO_ERROR_CODE -1 6.10 6.11 #if HVM_DEBUG 6.12 @@ -244,16 +242,18 @@ static inline void hvm_get_buffer(hvm_do 6.13 #define hvm_get_struct(_h, _p) \ 6.14 hvm_get_buffer((_h), (char *)(_p), sizeof(*(_p))) 6.15 6.16 +int hvm_save(struct vcpu*, hvm_domain_context_t *h); 6.17 +int hvm_load(struct vcpu*, hvm_domain_context_t *h); 6.18 6.19 -extern int hvm_save(struct vcpu*, hvm_domain_context_t *h); 6.20 -extern int hvm_load(struct vcpu*, hvm_domain_context_t *h); 6.21 +int arch_sethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c); 6.22 +int arch_gethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c); 6.23 6.24 -extern int arch_sethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c); 6.25 -extern int arch_gethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c); 6.26 +void shpage_init(struct domain *d, shared_iopage_t *sp); 6.27 6.28 -extern void shpage_init(struct domain *d, shared_iopage_t *sp); 6.29 +extern char hvm_io_bitmap[]; 6.30 +extern int hvm_enabled; 6.31 6.32 -extern int hvm_enabled; 6.33 +void hvm_enable(void); 6.34 6.35 int hvm_copy_to_guest_phys(paddr_t paddr, void *buf, int size); 6.36 int hvm_copy_from_guest_phys(void *buf, paddr_t paddr, int size);
7.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h Thu Jan 25 17:00:18 2007 +0000 7.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h Thu Jan 25 18:20:58 2007 +0000 7.3 @@ -452,7 +452,6 @@ struct vmcb_struct { 7.4 struct arch_svm_struct { 7.5 struct vmcb_struct *vmcb; 7.6 u64 vmcb_pa; 7.7 - u32 *iopm; 7.8 u32 *msrpm; 7.9 u64 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */ 7.10 int saved_irq_vector;