direct-io.hg

changeset 11638:c40ea583941c

[XEN] Fix i386 hypercall code to always create shadow
parameters. Arguments on stack can be clobbered by
callee, since it owns them. But we require this doesn't
happen when we create hypercall continuations. Hence the
need to copy.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Sep 28 11:47:33 2006 +0100 (2006-09-28)
parents 88418d7f22f2
children e57815fcc352
files xen/arch/x86/x86_32/entry.S
line diff
     1.1 --- a/xen/arch/x86/x86_32/entry.S	Thu Sep 28 11:25:15 2006 +0100
     1.2 +++ b/xen/arch/x86/x86_32/entry.S	Thu Sep 28 11:47:33 2006 +0100
     1.3 @@ -175,7 +175,7 @@ ENTRY(hypercall)
     1.4          jae   bad_hypercall
     1.5          PERFC_INCR(PERFC_hypercalls, %eax)
     1.6  #ifndef NDEBUG
     1.7 -        /* Deliberately corrupt parameter regs not used by this hypercall. */
     1.8 +        /* Create shadow parameters and corrupt those not used by this call. */
     1.9          pushl %eax
    1.10          pushl UREGS_eip+4(%esp)
    1.11          pushl 28(%esp) # EBP
    1.12 @@ -192,11 +192,23 @@ ENTRY(hypercall)
    1.13          movl  $0xDEADBEEF,%eax
    1.14          rep   stosl
    1.15          movl  %esi,%eax
    1.16 +#else
    1.17 +        /* 
    1.18 +         * We need shadow parameters even on non-debug builds. We depend on the
    1.19 +         * original versions not being clobbered (needed to create a hypercall
    1.20 +         * continuation). But that isn't guaranteed by the function-call ABI.
    1.21 +         */ 
    1.22 +        pushl 20(%esp) # EBP
    1.23 +        pushl 20(%esp) # EDI
    1.24 +        pushl 20(%esp) # ESI
    1.25 +        pushl 20(%esp) # EDX
    1.26 +        pushl 20(%esp) # ECX
    1.27 +        pushl 20(%esp) # EBX
    1.28  #endif
    1.29          call *hypercall_table(,%eax,4)
    1.30 +        addl  $24,%esp     # Discard the shadow parameters
    1.31  #ifndef NDEBUG
    1.32 -        /* Deliberately corrupt parameter regs used by this hypercall. */
    1.33 -        addl  $24,%esp     # Shadow parameters
    1.34 +        /* Deliberately corrupt real parameter regs used by this hypercall. */
    1.35          popl  %ecx         # Shadow EIP
    1.36          cmpl  %ecx,UREGS_eip+4(%esp)
    1.37          popl  %ecx         # Shadow hypercall index