Skip to contentSkip to conversation

vmx: fix single stepping on debugger

PATCH New Kouya Shimura 1 participant 1 message Nov 11, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmx: fix single stepping on debugger

The debuggee domain will die with unexpected trap
on single stepping of emulated instruction.

xen/arch/x86/hvm/vmx/realmode.c +8 -0
diff -r 5fd51e1e9c79 xen/arch/x86/hvm/vmx/realmode.c
@@ -148,6 +148,14 @@ static void realmode_emulate_one(struct 
             hvmemul_ctxt->exn_insn_len = 0;
         }
 
+        if ( curr->domain->debugger_attached &&
+	     ( hvmemul_ctxt->exn_vector == TRAP_debug ||
+	       hvmemul_ctxt->exn_vector == TRAP_int3 ) )
+        {
+            domain_pause_for_debugger();
+            return;
+        }
+
         if ( curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PE )
         {
             gdprintk(XENLOG_ERR, "Exception %02x in protected mode.\n",
xen/arch/x86/hvm/vmx/vmx.c +7 -2
diff -r 5fd51e1e9c79 xen/arch/x86/hvm/vmx/vmx.c
@@ -1154,8 +1154,6 @@ static void vmx_inject_exception(
 {
     struct vcpu *curr = current;
 
-    vmx_inject_hw_exception(curr, trapnr, errcode);
-
     if ( trapnr == TRAP_page_fault )
         curr->arch.hvm_vcpu.guest_cr[2] = cr2;
 
@@ -1164,7 +1162,14 @@ static void vmx_inject_exception(
     {
         __restore_debug_registers(curr);
         write_debugreg(6, read_debugreg(6) | 0x4000);
+        if ( curr->domain->debugger_attached )
+        {
+            domain_pause_for_debugger();
+            return;
+        }
     }
+
+    vmx_inject_hw_exception(curr, trapnr, errcode);
 }
 
 static int vmx_event_pending(struct vcpu *v)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel