[HVM][VMX] Added flag_dr_dirty to hvm vcpu struct. If this flag is set,
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 27 Jun 2006 08:51:18 +0000 (09:51 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 27 Jun 2006 08:51:18 +0000 (09:51 +0100)
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>
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vcpu.h

index 659dcdce1083344c93119c80d9c8f40e51cb426c..07792d291844882e69d19baf25b2badd23d91b11 100644 (file)
@@ -359,6 +359,26 @@ static inline int long_mode_do_msr_write(struct cpu_user_regs *regs)
 
 #define loaddebug(_v,_reg) \
     __asm__ __volatile__ ("mov %0,%%db" #_reg : : "r" ((_v)->debugreg[_reg]))
+#define savedebug(_v,_reg) \
+    __asm__ __volatile__ ("mov %%db" #_reg ",%0" : : "r" ((_v)->debugreg[_reg]))
+
+static inline void vmx_save_dr(struct vcpu *v)
+{
+    if ( v->arch.hvm_vcpu.flag_dr_dirty )
+    {
+        savedebug(&v->arch.guest_context, 0);
+        savedebug(&v->arch.guest_context, 1);
+        savedebug(&v->arch.guest_context, 2);
+        savedebug(&v->arch.guest_context, 3);
+        savedebug(&v->arch.guest_context, 6);
+        
+        v->arch.hvm_vcpu.flag_dr_dirty = 0;
+
+        v->arch.hvm_vcpu.u.vmx.exec_control |= CPU_BASED_MOV_DR_EXITING;
+        __vmwrite(CPU_BASED_VM_EXEC_CONTROL,
+                  v->arch.hvm_vcpu.u.vmx.exec_control);
+    }
+}
 
 static inline void __restore_debug_registers(struct vcpu *v)
 {
@@ -409,6 +429,7 @@ static void vmx_ctxt_switch_from(struct vcpu *v)
     vmx_freeze_time(v);
     vmx_save_segments(v);
     vmx_load_msrs();
+    vmx_save_dr(v);
 }
 
 static void vmx_ctxt_switch_to(struct vcpu *v)
index 3503c57ffe4948b96e5ee0bf241086319d0f9574..80dd267fc9373dc41fb5d3c381156cd541737ed3 100644 (file)
@@ -38,6 +38,9 @@ struct hvm_vcpu {
     /* For AP startup */
     unsigned long   init_sipi_sipi_state;
 
+    /* Flags */
+    int   flag_dr_dirty;
+
     union {
         struct arch_vmx_struct vmx;
         struct arch_svm_struct svm;