Skip to content
  1. May 06, 2015
    • H.J. Lu's avatar
      x86/asm: Use -mskip-rax-setup if supported · d9ee948d
      H.J. Lu authored
      
      
      GCC 5 added a compiler option, -mskip-rax-setup, for x86-64. It skips
      setting up the RAX register when SSE is disabled and there are no
      variable arguments passed in vector registers. (According to the x86_64
      ABI, %al is used as a hidden register containing the number of vector
      registers used).
      
      Since the kernel doesn't pass vector registers to functions with
      variable arguments, this option can be used to optimize the x86-64
      kernel.
      
      This GCC feature was suggested by Rasmus Villemoes <linux@rasmusvillemoes.dk>.
      This is the corresponding kernel change using it.
      
      For kernel v3.17:
      
            text   data    bss    dec       filename
        11455921 2204048 5853184 19513153   vmlinux #with -mskip-rax-setup
        11480079 2204048 5853184 19537311   vmlinux
      
      For Kernel v4.0+ - custom config:
      
            text   data    bss    dec       filename
        10231778 3479800 16617472 30329050  vmlinux-gcc5+-mskip-rax-setup
        10268797 3547448 16621568 30437813  vmlinux
      
      Signed-off-by: default avatarH.J. Lu <hjl.tools@gmail.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d9ee948d
  2. Apr 22, 2015
    • Denys Vlasenko's avatar
      x86/asm/entry/32: Update -ENOSYS handling to match the 64-bit logic · 3f5159a9
      Denys Vlasenko authored
      
      
      Recently Andy changed the 64-bit syscall logic so that
      pt_regs->ax is initially set to -ENOSYS, and on syscall exit,
      it is updated with the actual return value. This simplified
      the logic there.
      
      This patch does the same for 32-bit syscall entry points.
      
      The check for %rax being too big is moved to be just before
      the call instruction which dispatches execution through the
      syscall table.
      
      There is no way to accidentally skip this check now by jumping
      to a label after it. This allows us to remove redundant checks
      after ptrace et al.
      
      If %rax is too big, we just skip over the (call, write %rax to
      pt_regs->ax) instruction pair. pt_regs->ax remains set to -ENOSYS,
      and it gets returned to userspace.
      
      Similar to 64-bit code, this eliminates the "ia32_badsys" code path.
      
      Run-tested.
      
      Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      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: Steven Rostedt <rostedt@goodmis.org>
      Cc: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/1429632194-13445-2-git-send-email-dvlasenk@redhat.com
      
      
      [ Changelog massage. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3f5159a9
    • Denys Vlasenko's avatar
      x86/asm/entry/64: Merge 32-bit execve stubs with x32 ones, as they are identical · ac7f5dfb
      Denys Vlasenko authored
      
      
      Run-tested.
      
      Suggested-by: default avatarBrian Gerst <brgerst@gmail.com>
      Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      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: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/1429632194-13445-1-git-send-email-dvlasenk@redhat.com
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ac7f5dfb
    • Denys Vlasenko's avatar
      x86/asm/entry/64: Implement better check for canonical addresses · 17be0aec
      Denys Vlasenko authored
      
      
      This change makes the check exact (no more false positives
      on "negative" addresses).
      
      Andy explains:
      
       "Canonical addresses either start with 17 zeros or 17 ones.
      
        In the old code, we checked that the top (64-47) = 17 bits were all
        zero.  We did this by shifting right by 47 bits and making sure that
        nothing was left.
      
        In the new code, we're shifting left by (64 - 48) = 16 bits and then
        signed shifting right by the same amount, this propagating the 17th
        highest bit to all positions to its left.  If we get the same value we
        started with, then we're good to go."
      
      While it isn't really important to be fully correct here -
      almost all addresses we'll ever see will be userspace ones,
      but OTOH it looks to be cheap enough: the new code uses
      two more ALU ops but preserves %rcx, allowing to not
      reload it from pt_regs->cx again.
      
      On disassembly level, the changes are:
      
        cmp %rcx,0x80(%rsp) -> mov 0x80(%rsp),%r11; cmp %rcx,%r11
        shr $0x2f,%rcx      -> shl $0x10,%rcx; sar $0x10,%rcx; cmp %rcx,%r11
        mov 0x58(%rsp),%rcx -> (eliminated)
      
      Signed-off-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      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: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/1429633649-20169-1-git-send-email-dvlasenk@redhat.com
      
      
      [ Changelog massage. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      17be0aec
    • Hagen Paul Pfeifer's avatar
      x86/asm: Always inline atomics · 3462bd2a
      Hagen Paul Pfeifer authored
      
      
      During some code analysis I realized that atomic_add(), atomic_sub()
      and friends are not necessarily inlined AND that each function
      is defined multiple times:
      
      	atomic_inc:          544 duplicates
      	atomic_dec:          215 duplicates
      	atomic_dec_and_test: 107 duplicates
      	atomic64_inc:         38 duplicates
      	[...]
      
      Each definition is exact equally, e.g.:
      
      	ffffffff813171b8 <atomic_add>:
      	55         push   %rbp
      	48 89 e5   mov    %rsp,%rbp
      	f0 01 3e   lock add %edi,(%rsi)
      	5d         pop    %rbp
      	c3         retq
      
      In turn each definition has one or more callsites (sure):
      
      	ffffffff81317c78: e8 3b f5 ff ff  callq  ffffffff813171b8 <atomic_add> [...]
      	ffffffff8131a062: e8 51 d1 ff ff  callq  ffffffff813171b8 <atomic_add> [...]
      	ffffffff8131a190: e8 23 d0 ff ff  callq  ffffffff813171b8 <atomic_add> [...]
      
      The other way around would be to remove the static linkage - but
      I prefer an enforced inlining here.
      
      	Before:
      	  text     data	  bss      dec       hex     filename
      	  81467393 19874720 20168704 121510817 73e1ba1 vmlinux.orig
      
      	After:
      	  text     data     bss      dec       hex     filename
      	  81461323 19874720 20168704 121504747 73e03eb vmlinux.inlined
      
      Yes, the inlining here makes the kernel even smaller! ;)
      
      Linus further observed:
      
      	"I have this memory of having seen that before - the size
      	 heuristics for gcc getting confused by inlining.
      	 [...]
      
      	 It might be a good idea to mark things that are basically just
      	 wrappers around a single (or a couple of) asm instruction to be
      	 always_inline."
      
      Signed-off-by: default avatarHagen Paul Pfeifer <hagen@jauu.net>
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1429565231-4609-1-git-send-email-hagen@jauu.net
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3462bd2a
    • Andy Lutomirski's avatar
      x86, paravirt, xen: Remove the 64-bit ->irq_enable_sysexit() pvop · aac82d31
      Andy Lutomirski authored
      
      
      We don't use irq_enable_sysexit on 64-bit kernels any more.
      Remove all the paravirt and Xen machinery to support it on
      64-bit kernels.
      
      Tested-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Denys Vlasenko <vda.linux@googlemail.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/8a03355698fe5b94194e9e7360f19f91c1b2cf1f.1428100853.git.luto@kernel.org
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      aac82d31
  3. Apr 16, 2015
  4. Apr 15, 2015
  5. Apr 11, 2015
  6. Apr 10, 2015
  7. Apr 09, 2015
  8. Apr 08, 2015