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] linux-2.6.18/x86-64: streamline syscall code

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] linux-2.6.18/x86-64: streamline syscall code
From: "Jan Beulich" <JBeulich@xxxxxxxx>
Date: Tue, 04 Oct 2011 15:19:47 +0100
Delivery-date: Tue, 04 Oct 2011 07:20:48 -0700
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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>

--- a/arch/x86_64/kernel/entry-xen.S
+++ b/arch/x86_64/kernel/entry-xen.S
@@ -153,6 +153,7 @@ NMI_MASK = 0x80000000
          * 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 @@ NMI_MASK = 0x80000000
        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 @@ END(ret_from_fork)
 
 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 @@ sysret_check:
         * 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] linux-2.6.18/x86-64: streamline syscall code, Jan Beulich <=