• Denys Vlasenko's avatar
    x86/asm/entry/32: Do not use R9 in SYSCALL32 entry point · 53e9accf
    Denys Vlasenko authored
    SYSENTER and SYSCALL 32-bit entry points differ in handling of
    arg2 and arg6.
    
    SYSENTER:
     * ecx  arg2
     * ebp  user stack
     * 0(%ebp) arg6
    
    SYSCALL:
     * ebp  arg2
     * esp  user stack
     * 0(%esp) arg6
    
    Sysenter code loads 0(%ebp) to %ebp right away.
    (This destroys %ebp. It means we do not preserve it on return.
    It's not causing problems since userspace VDSO code does not
    depend on it, and SYSENTER insn can't be sanely used outside of
    VDSO).
    
    Syscall code loads 0(%ebp) to %r9. This allows to eliminate one
    MOV insn (r9 is a register where arg6 should be for 64-bit ABI),
    but on audit/ptrace code paths this requires juggling of r9 and
    ebp: (1) ptrace expects arg6 to be in pt_regs->bp;
    (2) r9 is callee-clobbered register and needs to be
    saved/restored     around calls to C functions.
    
    This patch changes syscall code to load 0(%ebp) to %ebp, making
    it more similar to sysenter code. It's a bit smaller:
    
       text    data     bss     dec     hex filename
       1407       0       0    1407     57f ia32entry.o.before
       1391       0       0    1391     56f ia32entry.o
    
    To preserve ABI compat, we restore ebp on exit.
    
    Run-tested.
    Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
    Cc: Alexei Starovoitov <ast@plumgrid.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Andy Lutomirski <luto@amacapital.net>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Brian Gerst <brgerst@gmail.com>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: Kees Cook <keescook@chromium.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Will Drewry <wad@chromium.org>
    Link: http://lkml.kernel.org/r/1433336169-18964-1-git-send-email-dvlasenk@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    53e9accf
ia32entry.S 14.9 KB