WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] vmx-gdbserver-sstep.patch

To: Ian Pratt <Ian.Pratt@xxxxxxxxxxxx>, Keir Fraser <Keir.Fraser@xxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] vmx-gdbserver-sstep.patch
From: Arun Sharma <arun.sharma@xxxxxxxxx>
Date: Wed, 18 May 2005 19:24:05 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 19 May 2005 02:22:14 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.1i
This patch enables single stepping a VMX domain using the gdbserver.

Signed-Off-By: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>
Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>

--- 1.190/xen/arch/x86/domain.c 2005-05-12 06:58:45 -07:00
+++ edited/xen/arch/x86/domain.c        2005-05-17 15:55:28 -07:00
@@ -417,6 +417,12 @@
 
         /* Ensure real hardware interrupts are enabled. */
         ed->arch.guest_context.user_regs.eflags |= EF_IE;
+    } else {
+        __vmwrite(GUEST_EFLAGS, ed->arch.guest_context.user_regs.eflags);
+        if (ed->arch.guest_context.user_regs.eflags & EF_TF)
+                __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
+        else 
+                __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_DB);
     }
 
     if ( test_bit(_VCPUF_initialised, &ed->vcpu_flags) )
===== xen/arch/x86/vmx.c 1.50 vs edited =====
--- 1.50/xen/arch/x86/vmx.c     2005-05-12 06:58:45 -07:00
+++ edited/xen/arch/x86/vmx.c   2005-05-17 15:29:07 -07:00
@@ -166,7 +166,7 @@
         cr0 &= ~X86_CR0_TS;
         __vmwrite(GUEST_CR0, cr0);
     }
-    __vmwrite(EXCEPTION_BITMAP, MONITOR_DEFAULT_EXCEPTION_BITMAP);
+    __vm_clear_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_NM);
 }
 
 static void vmx_do_general_protection_fault(struct cpu_user_regs *regs) 
@@ -1108,6 +1108,21 @@
             save_cpu_user_regs(&regs);
             pdb_handle_exception(3, &regs, 1);
             restore_cpu_user_regs(&regs);
+            break;
+        }
+#else
+        case TRAP_debug:
+        {
+            void store_cpu_user_regs(struct cpu_user_regs *regs);
+            long do_sched_op(unsigned long op);
+
+
+            store_cpu_user_regs(&regs);
+            __vm_clear_bit(GUEST_PENDING_DBG_EXCEPTIONS, PENDING_DEBUG_EXC_BS);
+
+            set_bit(_VCPUF_ctrl_pause, &current->vcpu_flags);
+            do_sched_op(SCHEDOP_yield);
+
             break;
         }
 #endif
===== xen/arch/x86/vmx_platform.c 1.15 vs edited =====
--- 1.15/xen/arch/x86/vmx_platform.c    2005-04-28 07:04:10 -07:00
+++ edited/xen/arch/x86/vmx_platform.c  2005-05-17 15:15:24 -07:00
@@ -49,7 +49,7 @@
     return 0;
 }
 #elif defined (__i386__)
-static void store_cpu_user_regs(struct cpu_user_regs *regs)
+void store_cpu_user_regs(struct cpu_user_regs *regs)
 {
     __vmread(GUEST_SS_SELECTOR, &regs->ss);
     __vmread(GUEST_ESP, &regs->esp);
===== xen/include/asm-x86/vmx.h 1.7 vs edited =====
--- 1.7/xen/include/asm-x86/vmx.h       2005-05-11 13:20:21 -07:00
+++ edited/xen/include/asm-x86/vmx.h    2005-05-17 15:28:11 -07:00
@@ -131,6 +131,11 @@
 #define EXCEPTION_BITMAP_MC     (1 << 18)       /* Machine Check */
 #define EXCEPTION_BITMAP_XF     (1 << 19)       /* SIMD Floating-Point 
Exception */
 
+/* Pending Debug exceptions */
+
+#define PENDING_DEBUG_EXC_BP    (1 << 12)       /* break point */
+#define PENDING_DEBUG_EXC_BS    (1 << 14)       /* Single step */
+
 #ifdef XEN_DEBUGGER
 #define MONITOR_DEFAULT_EXCEPTION_BITMAP        \
     ( EXCEPTION_BITMAP_PG |                     \
@@ -231,6 +236,30 @@
     return 0;
 }
 
+static inline int __vm_set_bit(unsigned long field, unsigned long mask)
+{
+        unsigned long tmp;
+        int err = 0;
+
+        err |= __vmread(field, &tmp);
+        tmp |= mask;
+        err |= __vmwrite(field, tmp);
+
+        return err;
+}
+
+static inline int __vm_clear_bit(unsigned long field, unsigned long mask)
+{
+        unsigned long tmp;
+        int err = 0;
+
+        err |= __vmread(field, &tmp);
+        tmp &= ~mask;
+        err |= __vmwrite(field, tmp);
+
+        return err;
+}
+
 static inline void __vmxoff (void)
 {
     __asm__ __volatile__ ( VMXOFF_OPCODE 
@@ -263,8 +292,7 @@
 
     __vmread(CR0_READ_SHADOW, &cr0);
     if (!(cr0 & X86_CR0_TS))
-       __vmwrite(EXCEPTION_BITMAP, MONITOR_DEFAULT_EXCEPTION_BITMAP | 
-                                   EXCEPTION_BITMAP_NM);
+       __vm_set_bit(EXCEPTION_BITMAP, EXCEPTION_BITMAP_NM);
 }
  

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>