direct-io.hg

changeset 10486:5610d916ad1b

[HVM][VMX] Added flag_dr_dirty to hvm vcpu struct. If this flag is set,
save the debug registers, clear the flag, and remove guest access to
debug registers.
Signed-off-by: George Dunlap <dunlapg@umich.edu>
Signed-off-by: Nitin Kamble <nitin.a.kamble@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jun 27 09:51:18 2006 +0100 (2006-06-27)
parents 81bfa15a071e
children 9158ecb9045f
files xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vcpu.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Jun 27 09:48:23 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Jun 27 09:51:18 2006 +0100
     1.3 @@ -359,6 +359,26 @@ static inline int long_mode_do_msr_write
     1.4  
     1.5  #define loaddebug(_v,_reg) \
     1.6      __asm__ __volatile__ ("mov %0,%%db" #_reg : : "r" ((_v)->debugreg[_reg]))
     1.7 +#define savedebug(_v,_reg) \
     1.8 +    __asm__ __volatile__ ("mov %%db" #_reg ",%0" : : "r" ((_v)->debugreg[_reg]))
     1.9 +
    1.10 +static inline void vmx_save_dr(struct vcpu *v)
    1.11 +{
    1.12 +    if ( v->arch.hvm_vcpu.flag_dr_dirty )
    1.13 +    {
    1.14 +        savedebug(&v->arch.guest_context, 0);
    1.15 +        savedebug(&v->arch.guest_context, 1);
    1.16 +        savedebug(&v->arch.guest_context, 2);
    1.17 +        savedebug(&v->arch.guest_context, 3);
    1.18 +        savedebug(&v->arch.guest_context, 6);
    1.19 +        
    1.20 +        v->arch.hvm_vcpu.flag_dr_dirty = 0;
    1.21 +
    1.22 +        v->arch.hvm_vcpu.u.vmx.exec_control |= CPU_BASED_MOV_DR_EXITING;
    1.23 +        __vmwrite(CPU_BASED_VM_EXEC_CONTROL,
    1.24 +                  v->arch.hvm_vcpu.u.vmx.exec_control);
    1.25 +    }
    1.26 +}
    1.27  
    1.28  static inline void __restore_debug_registers(struct vcpu *v)
    1.29  {
    1.30 @@ -409,6 +429,7 @@ static void vmx_ctxt_switch_from(struct 
    1.31      vmx_freeze_time(v);
    1.32      vmx_save_segments(v);
    1.33      vmx_load_msrs();
    1.34 +    vmx_save_dr(v);
    1.35  }
    1.36  
    1.37  static void vmx_ctxt_switch_to(struct vcpu *v)
     2.1 --- a/xen/include/asm-x86/hvm/vcpu.h	Tue Jun 27 09:48:23 2006 +0100
     2.2 +++ b/xen/include/asm-x86/hvm/vcpu.h	Tue Jun 27 09:51:18 2006 +0100
     2.3 @@ -38,6 +38,9 @@ struct hvm_vcpu {
     2.4      /* For AP startup */
     2.5      unsigned long   init_sipi_sipi_state;
     2.6  
     2.7 +    /* Flags */
     2.8 +    int   flag_dr_dirty;
     2.9 +
    2.10      union {
    2.11          struct arch_vmx_struct vmx;
    2.12          struct arch_svm_struct svm;