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

[Xen-changelog] [linux-2.6.18-xen] x86-64: streamline syscall code



# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1317818689 -7200
# Node ID 5bda145fc6dcda60cd125699d7ece4bbade0660f
# Parent  4dd3a1d5b26796c1c10c5c2a0026832675aa615d
x86-64: streamline syscall code

System calls using the sysret exit path (or its VGCF_in_syscall IRET
equivalent on Xen) always go into user mode, hence the conditionals
in HYPERVISOR_IRET can be omitted entirely.

Further, there's no need to spill %rcx to the stack upon syscall entry
(neither does native code): No argument gets passed there, and due to
the use of the syscall instruction the register's contents don't need
to be preserved either.

Finally, rather than restoring %rcx and %r11 (not preserved by syscall/
sysret anyway) from the stack frame, we can as well simply clear them
out (to avoid leaking kernel data), thus reducing the necessary memory
(cache) bandwidth.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 4dd3a1d5b267 -r 5bda145fc6dc arch/x86_64/kernel/entry-xen.S
--- a/arch/x86_64/kernel/entry-xen.S    Wed Oct 05 14:42:56 2011 +0200
+++ b/arch/x86_64/kernel/entry-xen.S    Wed Oct 05 14:44:49 2011 +0200
@@ -153,6 +153,7 @@
          * with rax, r11, and rcx being taken care of in the hypercall stub.
          */
        .macro HYPERVISOR_IRET flag
+       .if \flag == 0  # return from syscall always uses the hypercall
        testb $3,1*8(%rsp)
        jnz   2f
        testl $NMI_MASK,2*8(%rsp)
@@ -165,6 +166,7 @@
        orl   $3,1*8(%rsp)
        orl   $3,4*8(%rsp)
 1:     iretq
+       .endif
 
 2:     /* Slow iret via hypervisor. */
        andl  $~NMI_MASK, 2*8(%rsp)
@@ -248,7 +250,7 @@
 
 ENTRY(system_call)
        _frame (RIP-0x10)
-       SAVE_ARGS -8,0
+       SAVE_ARGS -8,1
        movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) 
        GET_THREAD_INFO(%rcx)
        testl 
$(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
@@ -279,8 +281,9 @@
         * sysretq will re-enable interrupts:
         */
        TRACE_IRQS_ON
-        XEN_UNBLOCK_EVENTS(%rsi)                
-       RESTORE_ARGS 0,8,0
+       RESTORE_ARGS 0,8,1,1
+       xor %ecx,%ecx
+       xor %r11,%r11
         HYPERVISOR_IRET VGCF_IN_SYSCALL
 
        /* Handle reschedules */

_______________________________________________
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®.