ia64/xen-unstable

changeset 5852:cb0f79c9d3fc

Implement the I/O bitmap vm execution control.

With this patch, we should not bee seeing any vmexits for debug port
accesses.

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jul 25 21:02:09 2005 +0000 (2005-07-25)
parents edc6e8921dd1
children 9b713b8d1100
files xen/arch/x86/domain.c xen/arch/x86/vmx.c xen/arch/x86/vmx_vmcs.c xen/include/asm-x86/vmx.h xen/include/asm-x86/vmx_vmcs.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Mon Jul 25 21:01:57 2005 +0000
     1.2 +++ b/xen/arch/x86/domain.c	Mon Jul 25 21:02:09 2005 +0000
     1.3 @@ -373,6 +373,14 @@ static int vmx_final_setup_guest(
     1.4  
     1.5  out:
     1.6      free_vmcs(vmcs);
     1.7 +    if(v->arch.arch_vmx.io_bitmap_a != 0) {
     1.8 +        free_xenheap_pages(v->arch.arch_vmx.io_bitmap_a, get_order(0x1000));
     1.9 +        v->arch.arch_vmx.io_bitmap_a = 0;
    1.10 +    }
    1.11 +    if(v->arch.arch_vmx.io_bitmap_b != 0) {
    1.12 +        free_xenheap_pages(v->arch.arch_vmx.io_bitmap_b, get_order(0x1000));
    1.13 +        v->arch.arch_vmx.io_bitmap_b = 0;
    1.14 +    }
    1.15      v->arch.arch_vmx.vmcs = 0;
    1.16      return error;
    1.17  }
    1.18 @@ -926,6 +934,14 @@ static void vmx_relinquish_resources(str
    1.19  
    1.20      BUG_ON(v->arch.arch_vmx.vmcs == NULL);
    1.21      free_vmcs(v->arch.arch_vmx.vmcs);
    1.22 +    if(v->arch.arch_vmx.io_bitmap_a != 0) {
    1.23 +        free_xenheap_pages(v->arch.arch_vmx.io_bitmap_a, get_order(0x1000));
    1.24 +        v->arch.arch_vmx.io_bitmap_a = 0;
    1.25 +    }
    1.26 +    if(v->arch.arch_vmx.io_bitmap_b != 0) {
    1.27 +        free_xenheap_pages(v->arch.arch_vmx.io_bitmap_b, get_order(0x1000));
    1.28 +        v->arch.arch_vmx.io_bitmap_b = 0;
    1.29 +    }
    1.30      v->arch.arch_vmx.vmcs = 0;
    1.31      
    1.32      free_monitor_pagetable(v);
     2.1 --- a/xen/arch/x86/vmx.c	Mon Jul 25 21:01:57 2005 +0000
     2.2 +++ b/xen/arch/x86/vmx.c	Mon Jul 25 21:02:09 2005 +0000
     2.3 @@ -609,11 +609,6 @@ static void vmx_io_instruction(struct cp
     2.4      else
     2.5          addr = regs->edx & 0xffff;
     2.6  
     2.7 -    if (addr == 0x80) {
     2.8 -        __update_guest_eip(inst_len);
     2.9 -        return;
    2.10 -    }
    2.11 -
    2.12      vio = get_vio(d->domain, d->vcpu_id);
    2.13      if (vio == 0) {
    2.14          printk("bad shared page: %lx", (unsigned long) vio);
     3.1 --- a/xen/arch/x86/vmx_vmcs.c	Mon Jul 25 21:01:57 2005 +0000
     3.2 +++ b/xen/arch/x86/vmx_vmcs.c	Mon Jul 25 21:02:09 2005 +0000
     3.3 @@ -59,9 +59,11 @@ void free_vmcs(struct vmcs_struct *vmcs)
     3.4      free_xenheap_pages(vmcs, order);
     3.5  }
     3.6  
     3.7 -static inline int construct_vmcs_controls(void)
     3.8 +static inline int construct_vmcs_controls(struct arch_vmx_struct *arch_vmx)
     3.9  {
    3.10      int error = 0;
    3.11 +    void *io_bitmap_a;
    3.12 +    void *io_bitmap_b;
    3.13  
    3.14      error |= __vmwrite(PIN_BASED_VM_EXEC_CONTROL, 
    3.15                         MONITOR_PIN_BASED_EXEC_CONTROLS);
    3.16 @@ -73,6 +75,20 @@ static inline int construct_vmcs_control
    3.17  
    3.18      error |= __vmwrite(VM_ENTRY_CONTROLS, MONITOR_VM_ENTRY_CONTROLS);
    3.19  
    3.20 +    /* need to use 0x1000 instead of PAGE_SIZE */
    3.21 +    io_bitmap_a = (void*) alloc_xenheap_pages(get_order(0x1000)); 
    3.22 +    io_bitmap_b = (void*) alloc_xenheap_pages(get_order(0x1000)); 
    3.23 +    memset(io_bitmap_a, 0xff, 0x1000);
    3.24 +    /* don't bother debug port access */
    3.25 +    clear_bit(PC_DEBUG_PORT, io_bitmap_a);
    3.26 +    memset(io_bitmap_b, 0xff, 0x1000);
    3.27 +
    3.28 +    error |= __vmwrite(IO_BITMAP_A, (u64) virt_to_phys(io_bitmap_a));
    3.29 +    error |= __vmwrite(IO_BITMAP_B, (u64) virt_to_phys(io_bitmap_b));
    3.30 +
    3.31 +    arch_vmx->io_bitmap_a = io_bitmap_a;
    3.32 +    arch_vmx->io_bitmap_b = io_bitmap_b;
    3.33 +
    3.34      return error;
    3.35  }
    3.36  
    3.37 @@ -432,7 +448,7 @@ int construct_vmcs(struct arch_vmx_struc
    3.38                 (unsigned long) vmcs_phys_ptr);
    3.39          return -EINVAL; 
    3.40      }
    3.41 -    if ((error = construct_vmcs_controls())) {
    3.42 +    if ((error = construct_vmcs_controls(arch_vmx))) {
    3.43          printk("construct_vmcs: construct_vmcs_controls failed\n");
    3.44          return -EINVAL;         
    3.45      }
     4.1 --- a/xen/include/asm-x86/vmx.h	Mon Jul 25 21:01:57 2005 +0000
     4.2 +++ b/xen/include/asm-x86/vmx.h	Mon Jul 25 21:02:09 2005 +0000
     4.3 @@ -61,6 +61,7 @@ extern unsigned int cpu_rev;
     4.4      CPU_BASED_INVDPG_EXITING | \
     4.5      CPU_BASED_MWAIT_EXITING | \
     4.6      CPU_BASED_MOV_DR_EXITING | \
     4.7 +    CPU_BASED_ACTIVATE_IO_BITMAP | \
     4.8      CPU_BASED_UNCOND_IO_EXITING \
     4.9      )
    4.10  
     5.1 --- a/xen/include/asm-x86/vmx_vmcs.h	Mon Jul 25 21:01:57 2005 +0000
     5.2 +++ b/xen/include/asm-x86/vmx_vmcs.h	Mon Jul 25 21:02:09 2005 +0000
     5.3 @@ -69,6 +69,8 @@ struct msr_state{
     5.4      unsigned long shadow_gs;
     5.5  };
     5.6  
     5.7 +#define PC_DEBUG_PORT   0x80 
     5.8 +
     5.9  struct arch_vmx_struct {
    5.10      struct vmcs_struct      *vmcs;  /* VMCS pointer in virtual */
    5.11      unsigned long           flags;  /* VMCS flags */
    5.12 @@ -76,6 +78,7 @@ struct arch_vmx_struct {
    5.13      unsigned long           cpu_cr3;
    5.14      unsigned long           cpu_state;
    5.15      struct msr_state        msr_content;
    5.16 +    void                   *io_bitmap_a, *io_bitmap_b;
    5.17  };
    5.18  
    5.19  #define vmx_schedule_tail(next)         \