[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: Fix xentrace of hypercalls in debug builds of Xen.



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1193128866 -3600
# Node ID 4970cbf9b19e751c7bc79107bd354bc1403d074f
# Parent  5a213170b06e0739b4c8914eedee5530d55a6bb7
x86: Fix xentrace of hypercalls in debug builds of Xen.

Based on a patch by Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/x86_32/entry.S        |    5 ++++-
 xen/arch/x86/x86_64/compat/entry.S |   17 ++++++++++-------
 xen/arch/x86/x86_64/entry.S        |   18 +++++++++++-------
 3 files changed, 25 insertions(+), 15 deletions(-)

diff -r 5a213170b06e -r 4970cbf9b19e xen/arch/x86/x86_32/entry.S
--- a/xen/arch/x86/x86_32/entry.S       Tue Oct 23 09:31:03 2007 +0100
+++ b/xen/arch/x86/x86_32/entry.S       Tue Oct 23 09:41:06 2007 +0100
@@ -181,6 +181,7 @@ 1:      sti
         movl  $0xDEADBEEF,%eax
         rep   stosl
         movl  %esi,%eax
+#define SHADOW_BYTES 32 /* 6 shadow parameters + EIP + hypercall # */
 #else
         /* 
          * We need shadow parameters even on non-debug builds. We depend on the
@@ -193,12 +194,14 @@ 1:      sti
         pushl 20(%esp) # EDX
         pushl 20(%esp) # ECX
         pushl 20(%esp) # EBX
+#define SHADOW_BYTES 24 /* 6 shadow parameters */
 #endif
         cmpb  $0,tb_init_done
         je    tracing_off
         call  trace_hypercall
         /* Now restore all the registers that trace_hypercall clobbered */
-        movl  UREGS_eax+24(%esp),%eax /* Hypercall # */
+        movl  UREGS_eax+SHADOW_BYTES(%esp),%eax /* Hypercall # */
+#undef SHADOW_BYTES
 tracing_off:
         call *hypercall_table(,%eax,4)
         addl  $24,%esp     # Discard the shadow parameters
diff -r 5a213170b06e -r 4970cbf9b19e xen/arch/x86/x86_64/compat/entry.S
--- a/xen/arch/x86/x86_64/compat/entry.S        Tue Oct 23 09:31:03 2007 +0100
+++ b/xen/arch/x86/x86_64/compat/entry.S        Tue Oct 23 09:41:06 2007 +0100
@@ -47,6 +47,7 @@ ENTRY(compat_hypercall)
         movl  UREGS_rax(%rsp),%eax
         pushq %rax
         pushq UREGS_rip+8(%rsp)
+#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
 #else
         /* Relocate argument registers and zero-extend to 64 bits. */
         movl  %eax,%eax              /* Hypercall #  */
@@ -55,18 +56,20 @@ ENTRY(compat_hypercall)
         movl  %edi,%r8d              /* Arg 5        */
         movl  %ebp,%r9d              /* Arg 6        */
         movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
+#define SHADOW_BYTES 0  /* No on-stack shadow state */
 #endif
         cmpb  $0,tb_init_done(%rip)
         je    compat_tracing_off
         call  trace_hypercall
         /* Now restore all the registers that trace_hypercall clobbered */
-        movl  UREGS_rax(%rsp),%eax   /* Hypercall #  */
-        movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
-        movl  UREGS_rcx(%rsp),%esi   /* Arg 2        */
-        movl  UREGS_rdx(%rsp),%edx   /* Arg 3        */
-        movl  UREGS_rsi(%rsp),%ecx   /* Arg 4        */
-        movl  UREGS_rdi(%rsp),%r8d   /* Arg 5        */
-        movl  UREGS_rbp(%rsp),%r9d   /* Arg 6        */
+        movl  UREGS_rax+SHADOW_BYTES(%rsp),%eax   /* Hypercall #  */
+        movl  UREGS_rbx+SHADOW_BYTES(%rsp),%edi   /* Arg 1        */
+        movl  UREGS_rcx+SHADOW_BYTES(%rsp),%esi   /* Arg 2        */
+        movl  UREGS_rdx+SHADOW_BYTES(%rsp),%edx   /* Arg 3        */
+        movl  UREGS_rsi+SHADOW_BYTES(%rsp),%ecx   /* Arg 4        */
+        movl  UREGS_rdi+SHADOW_BYTES(%rsp),%r8d   /* Arg 5        */
+        movl  UREGS_rbp+SHADOW_BYTES(%rsp),%r9d   /* Arg 6        */
+#undef SHADOW_BYTES
 compat_tracing_off:
         leaq  compat_hypercall_table(%rip),%r10
         PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
diff -r 5a213170b06e -r 4970cbf9b19e xen/arch/x86/x86_64/entry.S
--- a/xen/arch/x86/x86_64/entry.S       Tue Oct 23 09:31:03 2007 +0100
+++ b/xen/arch/x86/x86_64/entry.S       Tue Oct 23 09:41:06 2007 +0100
@@ -148,18 +148,22 @@ ENTRY(syscall_enter)
         movq  UREGS_rax(%rsp),%rax
         pushq %rax
         pushq UREGS_rip+8(%rsp)
+#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
+#else
+#define SHADOW_BYTES 0  /* No on-stack shadow state */
 #endif
         cmpb  $0,tb_init_done(%rip)
         je    tracing_off
         call  trace_hypercall
         /* Now restore all the registers that trace_hypercall clobbered */
-        movq  UREGS_rax(%rsp),%rax   /* Hypercall #  */
-        movq  UREGS_rdi(%rsp),%rdi   /* Arg 1        */
-        movq  UREGS_rsi(%rsp),%rsi   /* Arg 2        */
-        movq  UREGS_rdx(%rsp),%rdx   /* Arg 3        */
-        movq  UREGS_r10(%rsp),%rcx   /* Arg 4        */
-        movq  UREGS_rdi(%rsp),%r8    /* Arg 5        */
-        movq  UREGS_rbp(%rsp),%r9    /* Arg 6        */
+        movq  UREGS_rax+SHADOW_BYTES(%rsp),%rax   /* Hypercall #  */
+        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%rdi   /* Arg 1        */
+        movq  UREGS_rsi+SHADOW_BYTES(%rsp),%rsi   /* Arg 2        */
+        movq  UREGS_rdx+SHADOW_BYTES(%rsp),%rdx   /* Arg 3        */
+        movq  UREGS_r10+SHADOW_BYTES(%rsp),%rcx   /* Arg 4        */
+        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%r8    /* Arg 5        */
+        movq  UREGS_rbp+SHADOW_BYTES(%rsp),%r9    /* Arg 6        */
+#undef SHADOW_BYTES
 tracing_off:
         leaq  hypercall_table(%rip),%r10
         PERFC_INCR(PERFC_hypercalls, %rax, %rbx)

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.