# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1169749258 0
# Node ID fde9e1d474b7cc403a4ea9921c283fdd5d13adb7
# Parent 9e4f61bb200e0309aa306451c1a43a9fd125a4c8
hvm: Define a global I/O access bitmap, allowing direct access to port 0x80.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
xen/arch/x86/hvm/hvm.c | 25 ++++++++++++++++++++++---
xen/arch/x86/hvm/svm/svm.c | 2 +-
xen/arch/x86/hvm/svm/vmcb.c | 18 ++----------------
xen/arch/x86/hvm/vmx/vmcs.c | 6 +++++-
xen/arch/x86/hvm/vmx/vmx.c | 5 +----
xen/include/asm-x86/hvm/support.h | 22 +++++++++++-----------
xen/include/asm-x86/hvm/svm/vmcb.h | 1 -
7 files changed, 42 insertions(+), 37 deletions(-)
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/arch/x86/hvm/hvm.c Thu Jan 25 18:20:58 2007 +0000
@@ -50,12 +50,31 @@
#include <public/version.h>
#include <public/memory.h>
-int hvm_enabled = 0;
-
-unsigned int opt_hvm_debug_level = 0;
+int hvm_enabled;
+
+unsigned int opt_hvm_debug_level;
integer_param("hvm_debug", opt_hvm_debug_level);
struct hvm_function_table hvm_funcs;
+
+/* I/O permission bitmap is globally shared by all HVM guests. */
+char __attribute__ ((__section__ (".bss.page_aligned")))
+ hvm_io_bitmap[3*PAGE_SIZE];
+
+void hvm_enable(void)
+{
+ if ( hvm_enabled )
+ return;
+
+ /*
+ * Allow direct access to the PC debug port (it is often used for I/O
+ * delays, but the vmexits simply slow things down).
+ */
+ memset(hvm_io_bitmap, ~0, sizeof(hvm_io_bitmap));
+ clear_bit(0x80, hvm_io_bitmap);
+
+ hvm_enabled = 1;
+}
void hvm_stts(struct vcpu *v)
{
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c Thu Jan 25 18:20:58 2007 +0000
@@ -1069,7 +1069,7 @@ int start_svm(void)
hvm_funcs.init_ap_context = svm_init_ap_context;
hvm_funcs.init_hypercall_page = svm_init_hypercall_page;
- hvm_enabled = 1;
+ hvm_enable();
return 1;
}
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/arch/x86/hvm/svm/vmcb.c Thu Jan 25 18:20:58 2007 +0000
@@ -115,19 +115,12 @@ static int construct_vmcb(struct vcpu *v
vmcb->cr_intercepts = ~(CR_INTERCEPT_CR2_READ | CR_INTERCEPT_CR2_WRITE);
/* I/O and MSR permission bitmaps. */
- arch_svm->iopm = alloc_xenheap_pages(get_order_from_bytes(IOPM_SIZE));
arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE));
- if ( (arch_svm->iopm == NULL) || (arch_svm->msrpm == NULL) )
- {
- free_xenheap_pages(arch_svm->iopm, get_order_from_bytes(IOPM_SIZE));
- free_xenheap_pages(arch_svm->msrpm, get_order_from_bytes(MSRPM_SIZE));
+ if ( arch_svm->msrpm == NULL )
return -ENOMEM;
- }
- memset(arch_svm->iopm, 0xff, IOPM_SIZE);
- clear_bit(PC_DEBUG_PORT, arch_svm->iopm);
memset(arch_svm->msrpm, 0xff, MSRPM_SIZE);
- vmcb->iopm_base_pa = (u64)virt_to_maddr(arch_svm->iopm);
vmcb->msrpm_base_pa = (u64)virt_to_maddr(arch_svm->msrpm);
+ vmcb->iopm_base_pa = (u64)virt_to_maddr(hvm_io_bitmap);
/* Virtualise EFLAGS.IF and LAPIC TPR (CR8). */
vmcb->vintr.fields.intr_masking = 1;
@@ -240,13 +233,6 @@ void svm_destroy_vmcb(struct vcpu *v)
if ( arch_svm->vmcb != NULL )
free_vmcb(arch_svm->vmcb);
-
- if ( arch_svm->iopm != NULL )
- {
- free_xenheap_pages(
- arch_svm->iopm, get_order_from_bytes(IOPM_SIZE));
- arch_svm->iopm = NULL;
- }
if ( arch_svm->msrpm != NULL )
{
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/arch/x86/hvm/vmx/vmcs.c
--- a/xen/arch/x86/hvm/vmx/vmcs.c Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/vmcs.c Thu Jan 25 18:20:58 2007 +0000
@@ -56,7 +56,7 @@
CPU_BASED_INVDPG_EXITING | \
CPU_BASED_MWAIT_EXITING | \
CPU_BASED_MOV_DR_EXITING | \
- CPU_BASED_UNCOND_IO_EXITING | \
+ CPU_BASED_ACTIVATE_IO_BITMAP | \
CPU_BASED_USE_TSC_OFFSETING )
/* Basic flags for VM-Exit controls. */
@@ -302,6 +302,10 @@ static void construct_vmcs(struct vcpu *
__vmwrite(CPU_BASED_VM_EXEC_CONTROL, vmx_cpu_based_exec_control);
v->arch.hvm_vcpu.u.vmx.exec_control = vmx_cpu_based_exec_control;
+ /* I/O access bitmap. */
+ __vmwrite(IO_BITMAP_A, virt_to_maddr(hvm_io_bitmap));
+ __vmwrite(IO_BITMAP_B, virt_to_maddr(hvm_io_bitmap + PAGE_SIZE));
+
/* Host data selectors. */
__vmwrite(HOST_SS_SELECTOR, __HYPERVISOR_DS);
__vmwrite(HOST_DS_SELECTOR, __HYPERVISOR_DS);
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Jan 25 18:20:58 2007 +0000
@@ -1011,9 +1011,6 @@ static void vmx_inject_exception(
/* Setup HVM interfaces */
static void vmx_setup_hvm_funcs(void)
{
- if ( hvm_enabled )
- return;
-
hvm_funcs.disable = stop_vmx;
hvm_funcs.vcpu_initialise = vmx_vcpu_initialise;
@@ -1104,7 +1101,7 @@ int start_vmx(void)
vmx_setup_hvm_funcs();
- hvm_enabled = 1;
+ hvm_enable();
return 1;
}
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/include/asm-x86/hvm/support.h
--- a/xen/include/asm-x86/hvm/support.h Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/include/asm-x86/hvm/support.h Thu Jan 25 18:20:58 2007 +0000
@@ -90,8 +90,6 @@ enum hval_bitmaps {
EXCEPTION_BITMAP_BP )
#endif
-#define PC_DEBUG_PORT 0x80
-
#define VMX_DELIVER_NO_ERROR_CODE -1
#if HVM_DEBUG
@@ -244,16 +242,18 @@ static inline void hvm_get_buffer(hvm_do
#define hvm_get_struct(_h, _p) \
hvm_get_buffer((_h), (char *)(_p), sizeof(*(_p)))
-
-extern int hvm_save(struct vcpu*, hvm_domain_context_t *h);
-extern int hvm_load(struct vcpu*, hvm_domain_context_t *h);
-
-extern int arch_sethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c);
-extern int arch_gethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c);
-
-extern void shpage_init(struct domain *d, shared_iopage_t *sp);
-
+int hvm_save(struct vcpu*, hvm_domain_context_t *h);
+int hvm_load(struct vcpu*, hvm_domain_context_t *h);
+
+int arch_sethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c);
+int arch_gethvm_ctxt(struct vcpu *v, struct hvm_domain_context *c);
+
+void shpage_init(struct domain *d, shared_iopage_t *sp);
+
+extern char hvm_io_bitmap[];
extern int hvm_enabled;
+
+void hvm_enable(void);
int hvm_copy_to_guest_phys(paddr_t paddr, void *buf, int size);
int hvm_copy_from_guest_phys(void *buf, paddr_t paddr, int size);
diff -r 9e4f61bb200e -r fde9e1d474b7 xen/include/asm-x86/hvm/svm/vmcb.h
--- a/xen/include/asm-x86/hvm/svm/vmcb.h Thu Jan 25 17:00:18 2007 +0000
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h Thu Jan 25 18:20:58 2007 +0000
@@ -452,7 +452,6 @@ struct arch_svm_struct {
struct arch_svm_struct {
struct vmcb_struct *vmcb;
u64 vmcb_pa;
- u32 *iopm;
u32 *msrpm;
u64 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
int saved_irq_vector;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|