ia64/xen-unstable

changeset 16195:4970cbf9b19e

x86: Fix xentrace of hypercalls in debug builds of Xen.

Based on a patch by Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>

Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Tue Oct 23 09:41:06 2007 +0100 (2007-10-23)
parents 5a213170b06e
children 9d1d27fddc50
files xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/compat/entry.S xen/arch/x86/x86_64/entry.S
line diff
     1.1 --- a/xen/arch/x86/x86_32/entry.S	Tue Oct 23 09:31:03 2007 +0100
     1.2 +++ b/xen/arch/x86/x86_32/entry.S	Tue Oct 23 09:41:06 2007 +0100
     1.3 @@ -181,6 +181,7 @@ 1:      sti
     1.4          movl  $0xDEADBEEF,%eax
     1.5          rep   stosl
     1.6          movl  %esi,%eax
     1.7 +#define SHADOW_BYTES 32 /* 6 shadow parameters + EIP + hypercall # */
     1.8  #else
     1.9          /* 
    1.10           * We need shadow parameters even on non-debug builds. We depend on the
    1.11 @@ -193,12 +194,14 @@ 1:      sti
    1.12          pushl 20(%esp) # EDX
    1.13          pushl 20(%esp) # ECX
    1.14          pushl 20(%esp) # EBX
    1.15 +#define SHADOW_BYTES 24 /* 6 shadow parameters */
    1.16  #endif
    1.17          cmpb  $0,tb_init_done
    1.18          je    tracing_off
    1.19          call  trace_hypercall
    1.20          /* Now restore all the registers that trace_hypercall clobbered */
    1.21 -        movl  UREGS_eax+24(%esp),%eax /* Hypercall # */
    1.22 +        movl  UREGS_eax+SHADOW_BYTES(%esp),%eax /* Hypercall # */
    1.23 +#undef SHADOW_BYTES
    1.24  tracing_off:
    1.25          call *hypercall_table(,%eax,4)
    1.26          addl  $24,%esp     # Discard the shadow parameters
     2.1 --- a/xen/arch/x86/x86_64/compat/entry.S	Tue Oct 23 09:31:03 2007 +0100
     2.2 +++ b/xen/arch/x86/x86_64/compat/entry.S	Tue Oct 23 09:41:06 2007 +0100
     2.3 @@ -47,6 +47,7 @@ ENTRY(compat_hypercall)
     2.4          movl  UREGS_rax(%rsp),%eax
     2.5          pushq %rax
     2.6          pushq UREGS_rip+8(%rsp)
     2.7 +#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
     2.8  #else
     2.9          /* Relocate argument registers and zero-extend to 64 bits. */
    2.10          movl  %eax,%eax              /* Hypercall #  */
    2.11 @@ -55,18 +56,20 @@ ENTRY(compat_hypercall)
    2.12          movl  %edi,%r8d              /* Arg 5        */
    2.13          movl  %ebp,%r9d              /* Arg 6        */
    2.14          movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
    2.15 +#define SHADOW_BYTES 0  /* No on-stack shadow state */
    2.16  #endif
    2.17          cmpb  $0,tb_init_done(%rip)
    2.18          je    compat_tracing_off
    2.19          call  trace_hypercall
    2.20          /* Now restore all the registers that trace_hypercall clobbered */
    2.21 -        movl  UREGS_rax(%rsp),%eax   /* Hypercall #  */
    2.22 -        movl  UREGS_rbx(%rsp),%edi   /* Arg 1        */
    2.23 -        movl  UREGS_rcx(%rsp),%esi   /* Arg 2        */
    2.24 -        movl  UREGS_rdx(%rsp),%edx   /* Arg 3        */
    2.25 -        movl  UREGS_rsi(%rsp),%ecx   /* Arg 4        */
    2.26 -        movl  UREGS_rdi(%rsp),%r8d   /* Arg 5        */
    2.27 -        movl  UREGS_rbp(%rsp),%r9d   /* Arg 6        */
    2.28 +        movl  UREGS_rax+SHADOW_BYTES(%rsp),%eax   /* Hypercall #  */
    2.29 +        movl  UREGS_rbx+SHADOW_BYTES(%rsp),%edi   /* Arg 1        */
    2.30 +        movl  UREGS_rcx+SHADOW_BYTES(%rsp),%esi   /* Arg 2        */
    2.31 +        movl  UREGS_rdx+SHADOW_BYTES(%rsp),%edx   /* Arg 3        */
    2.32 +        movl  UREGS_rsi+SHADOW_BYTES(%rsp),%ecx   /* Arg 4        */
    2.33 +        movl  UREGS_rdi+SHADOW_BYTES(%rsp),%r8d   /* Arg 5        */
    2.34 +        movl  UREGS_rbp+SHADOW_BYTES(%rsp),%r9d   /* Arg 6        */
    2.35 +#undef SHADOW_BYTES
    2.36  compat_tracing_off:
    2.37          leaq  compat_hypercall_table(%rip),%r10
    2.38          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)
     3.1 --- a/xen/arch/x86/x86_64/entry.S	Tue Oct 23 09:31:03 2007 +0100
     3.2 +++ b/xen/arch/x86/x86_64/entry.S	Tue Oct 23 09:41:06 2007 +0100
     3.3 @@ -148,18 +148,22 @@ ENTRY(syscall_enter)
     3.4          movq  UREGS_rax(%rsp),%rax
     3.5          pushq %rax
     3.6          pushq UREGS_rip+8(%rsp)
     3.7 +#define SHADOW_BYTES 16 /* Shadow EIP + shadow hypercall # */
     3.8 +#else
     3.9 +#define SHADOW_BYTES 0  /* No on-stack shadow state */
    3.10  #endif
    3.11          cmpb  $0,tb_init_done(%rip)
    3.12          je    tracing_off
    3.13          call  trace_hypercall
    3.14          /* Now restore all the registers that trace_hypercall clobbered */
    3.15 -        movq  UREGS_rax(%rsp),%rax   /* Hypercall #  */
    3.16 -        movq  UREGS_rdi(%rsp),%rdi   /* Arg 1        */
    3.17 -        movq  UREGS_rsi(%rsp),%rsi   /* Arg 2        */
    3.18 -        movq  UREGS_rdx(%rsp),%rdx   /* Arg 3        */
    3.19 -        movq  UREGS_r10(%rsp),%rcx   /* Arg 4        */
    3.20 -        movq  UREGS_rdi(%rsp),%r8    /* Arg 5        */
    3.21 -        movq  UREGS_rbp(%rsp),%r9    /* Arg 6        */
    3.22 +        movq  UREGS_rax+SHADOW_BYTES(%rsp),%rax   /* Hypercall #  */
    3.23 +        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%rdi   /* Arg 1        */
    3.24 +        movq  UREGS_rsi+SHADOW_BYTES(%rsp),%rsi   /* Arg 2        */
    3.25 +        movq  UREGS_rdx+SHADOW_BYTES(%rsp),%rdx   /* Arg 3        */
    3.26 +        movq  UREGS_r10+SHADOW_BYTES(%rsp),%rcx   /* Arg 4        */
    3.27 +        movq  UREGS_rdi+SHADOW_BYTES(%rsp),%r8    /* Arg 5        */
    3.28 +        movq  UREGS_rbp+SHADOW_BYTES(%rsp),%r9    /* Arg 6        */
    3.29 +#undef SHADOW_BYTES
    3.30  tracing_off:
    3.31          leaq  hypercall_table(%rip),%r10
    3.32          PERFC_INCR(PERFC_hypercalls, %rax, %rbx)