1. 25 3月, 2015 12 次提交
    • I
      x86/asm: Further improve segment.h readability · 72d64cc7
      Ingo Molnar 提交于
       - extend/clarify explanations where necessary
      
       - move comments from macro values to before the macro, to
         make them more consistent, and to reduce preprocessor overhead
      
       - sort GDT index and selector values likewise by number
      
       - use consistent, modern kernel coding style across the file
      
       - capitalize consistently
      
       - use consistent vertical spacing
      
       - remove the unused get_limit() method (noticed by Andy Lutomirski)
      
      No change in code (verified with objdump -d):
      
       64-bit defconfig+kvmconfig:
      
         815a129bc1f80de6445c1d8ca5b97cad  vmlinux.o.before.asm
         815a129bc1f80de6445c1d8ca5b97cad  vmlinux.o.after.asm
      
       32-bit defconfig+kvmconfig:
      
         e659ef045159ddf41a0771b33a34aae5  vmlinux.o.before.asm
         e659ef045159ddf41a0771b33a34aae5  vmlinux.o.after.asm
      Acked-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      72d64cc7
    • A
      x86/asm/entry: Check for syscall exit work with IRQs disabled · b3494a4a
      Andy Lutomirski 提交于
      We currently have a race: if we're preempted during syscall
      exit, we can fail to process syscall return work that is queued
      up while we're preempted in ret_from_sys_call after checking
      ti.flags.
      
      Fix it by disabling interrupts before checking ti.flags.
      Reported-by: NStefan Seyfried <stefan.seyfried@googlemail.com>
      Reported-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NAndy Lutomirski <luto@kernel.org>
      Acked-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Tejun Heo <tj@kernel.org>
      Fixes: 96b6352c ("x86_64, entry: Remove the syscall exit audit")
      Link: http://lkml.kernel.org/r/189320d42b4d671df78c10555976bb10af1ffc75.1427137498.git.luto@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      b3494a4a
    • I
      x86/asm/entry/64: Rename THREAD_INFO() to ASM_THREAD_INFO() · dca5b52a
      Ingo Molnar 提交于
      The THREAD_INFO() macro has a somewhat confusingly generic name,
      defined in a generic .h C header file. It also does not make it
      clear that it constructs a memory operand for use in assembly
      code.
      
      Rename it to ASM_THREAD_INFO() to make it all glaringly
      obvious on first glance.
      Acked-by: NBorislav Petkov <bp@suse.de>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/20150324184442.GC14760@gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      dca5b52a
    • I
      x86/asm/entry/64: Merge the field offset into the THREAD_INFO() macro · f9d71854
      Ingo Molnar 提交于
      Before:
      
         TI_sysenter_return+THREAD_INFO(%rsp,3*8),%r10d
      
      After:
      
         movl    THREAD_INFO(TI_sysenter_return, %rsp, 3*8), %r10d
      
      to turn it into a clear thread_info accessor.
      
      No code changed:
      
       md5:
         fb4cb2b3ce05d89940ca304efc8ff183  ia32entry.o.before.asm
         fb4cb2b3ce05d89940ca304efc8ff183  ia32entry.o.after.asm
      
         e39f2958a5d1300158e276e4f7663263  entry_64.o.before.asm
         e39f2958a5d1300158e276e4f7663263  entry_64.o.after.asm
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      Acked-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Borislav Petkov <bp@suse.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/20150324184411.GB14760@gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      f9d71854
    • I
      x86/asm/entry/64: Improve the THREAD_INFO() macro explanation · 1ddc6f3c
      Ingo Molnar 提交于
      Explain the background, and add a real example.
      Acked-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      Acked-by: NBorislav Petkov <bp@suse.de>
      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/20150324184311.GA14760@gmail.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      1ddc6f3c
    • I
      x86/asm/entry/64: Always set up SYSENTER MSRs · d56fe4bf
      Ingo Molnar 提交于
      On CONFIG_IA32_EMULATION=y kernels we set up
      MSR_IA32_SYSENTER_CS/ESP/EIP, but on !CONFIG_IA32_EMULATION
      kernels we leave them unchanged.
      
      Clear them to make sure the instruction is disabled properly.
      
      SYSCALL is set up properly in both cases.
      Acked-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Alexei Starovoitov <ast@plumgrid.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d56fe4bf
    • D
      x86/asm: Deobfuscate segment.h · 84f53788
      Denys Vlasenko 提交于
      This file just defines a number of constants, and a few macros
      and inline functions. It is particularly badly written.
      
      For example, it is not trivial to see how descriptors are
      numbered (you'd expect that should be easy, right?).
      
      This change deobfuscates it via the following changes:
      
      Group all GDT_ENTRY_foo together (move intervening stuff away).
      
      Number them explicitly: use a number, not PREV_DEFINE+1, +2, +3:
      I want to immediately see that GDT_ENTRY_PNPBIOS_CS32 is 18.
      Seeing (GDT_ENTRY_KERNEL_BASE+6) instead is not useful.
      
      The above change allows to remove GDT_ENTRY_KERNEL_BASE
      and GDT_ENTRY_PNPBIOS_BASE, which weren't used anywhere else.
      
      After a group of GDT_ENTRY_foo, define all selector values.
      
      Remove or improve some comments. In particular:
      Comment deleted as stating the obvious:
          /*
           * The GDT has 32 entries
           */
          #define GDT_ENTRIES 32
      
      "The segment offset needs to contain a RPL. Grr. -AK"
          changed to
      "Selectors need to also have a correct RPL (+3 thingy)"
      
      "GDT layout to get 64bit syscall right (sysret hardcodes gdt
      offsets)" expanded into a description *how exactly* sysret
      hardcodes them.
      
      Patch was tested to compile and not change vmlinux.o
      on 32-bit and 64-bit builds (verified with objdump).
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      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>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      84f53788
    • D
      x86/asm/entry/64: Get rid of int_ret_from_sys_call_fixup · 65c23774
      Denys Vlasenko 提交于
      With the FIXUP_TOP_OF_STACK macro removed, this intermediate jump
      is unnecessary.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      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/1426785469-15125-5-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      65c23774
    • D
      x86/asm/entry/64: Get rid of the FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK macros · a71ffdd7
      Denys Vlasenko 提交于
      The FIXUP_TOP_OF_STACK macro is only necessary because we don't save %r11
      to pt_regs->r11 on SYSCALL64 fast path, but we want ptrace to see it populated.
      
      Bite the bullet, add a single additional PUSH instruction, and remove
      the FIXUP_TOP_OF_STACK macro.
      
      The RESTORE_TOP_OF_STACK macro is already a nop. Remove it too.
      
      On SandyBridge CPU, it does not get slower:
      measured 54.22 ns per getpid syscall before and after last two
      changes on defconfig kernel.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      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/1426785469-15125-4-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      a71ffdd7
    • D
      x86/asm/entry/64: Use PUSH instructions to build pt_regs on stack · 9ed8e7d8
      Denys Vlasenko 提交于
      With this change, on SYSCALL64 code path we are now populating
      pt_regs->cs, pt_regs->ss and pt_regs->rcx unconditionally and
      therefore don't need to do that in FIXUP_TOP_OF_STACK.
      
      We lose a number of large instructions there:
      
          text    data     bss     dec     hex filename
         13298       0       0   13298    33f2 entry_64_before.o
         12978       0       0   12978    32b2 entry_64.o
      
      What's more important, we convert two "MOVQ $imm,off(%rsp)" to
      "PUSH $imm" (the ones which fill pt_regs->cs,ss).
      
      Before this patch, placing them on fast path was slowing it down
      by two cycles: this form of MOV is very large, 12 bytes, and
      this probably reduces decode bandwidth to one instruction per cycle
      when CPU sees them.
      
      Therefore they were living in FIXUP_TOP_OF_STACK instead (away
      from fast path).
      
      "PUSH $imm" is a small 2-byte instruction. Moving it to fast path does
      not slow it down in my measurements.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      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/1426785469-15125-3-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      9ed8e7d8
    • D
      x86/asm/entry: Get rid of KERNEL_STACK_OFFSET · ef593260
      Denys Vlasenko 提交于
      PER_CPU_VAR(kernel_stack) was set up in a way where it points
      five stack slots below the top of stack.
      
      Presumably, it was done to avoid one "sub $5*8,%rsp"
      in syscall/sysenter code paths, where iret frame needs to be
      created by hand.
      
      Ironically, none of them benefits from this optimization,
      since all of them need to allocate additional data on stack
      (struct pt_regs), so they still have to perform subtraction.
      
      This patch eliminates KERNEL_STACK_OFFSET.
      
      PER_CPU_VAR(kernel_stack) now points directly to top of stack.
      pt_regs allocations are adjusted to allocate iret frame as well.
      Hopefully we can merge it later with 32-bit specific
      PER_CPU_VAR(cpu_current_top_of_stack) variable...
      
      Net result in generated code is that constants in several insns
      are changed.
      
      This change is necessary for changing struct pt_regs creation
      in SYSCALL64 code path from MOV to PUSH instructions.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      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/1426785469-15125-2-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ef593260
    • D
      x86/asm/entry/64: Change the THREAD_INFO() definition to not depend on KERNEL_STACK_OFFSET · b3fe8ba3
      Denys Vlasenko 提交于
      This changes the THREAD_INFO() definition and all its callsites
      so that they do not count stack position from
      (top of stack - KERNEL_STACK_OFFSET), but from top of stack.
      
      Semi-mysterious expressions THREAD_INFO(%rsp,RIP) - "why RIP??"
      are now replaced by more logical THREAD_INFO(%rsp,SIZEOF_PTREGS)
      - "calculate thread_info's address using information that
      rsp is SIZEOF_PTREGS bytes below top of stack".
      
      While at it, replace "(off)-THREAD_SIZE(reg)" with equivalent
      "((off)-THREAD_SIZE)(reg)". The form without parentheses
      falsely looks like we invoke THREAD_SIZE() macro.
      
      Improve comment atop THREAD_INFO macro definition.
      
      This patch does not change generated code (verified by objdump).
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      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/1426785469-15125-1-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      b3fe8ba3
  2. 24 3月, 2015 1 次提交
    • D
      x86/asm/entry/64: Fold syscall32_cpu_init() into its sole user · a76c7f46
      Denys Vlasenko 提交于
      Having syscall32/sysenter32 initialization in a separate tiny
      function, called from within a function that is already syscall
      init specific, serves no real purpose.
      
      Its existense also caused an unintended effect of having
      wrmsrl(MSR_CSTAR) performed twice: once we set it to a dummy
      function returning -ENOSYS, and immediately after
      (if CONFIG_IA32_EMULATION), we set it to point to the proper
      syscall32 entry point, ia32_cstar_target.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Alexei Starovoitov <ast@plumgrid.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      a76c7f46
  3. 23 3月, 2015 11 次提交
  4. 21 3月, 2015 2 次提交
  5. 20 3月, 2015 1 次提交
    • R
      Revert "x86/PCI: Refine the way to release PCI IRQ resources" · 9e8ce4b9
      Rafael J. Wysocki 提交于
      Commit b4b55cda (Refine the way to release PCI IRQ resources)
      introduced a regression in the PCI IRQ resource management by causing
      the IRQ resource of a device, established when pci_enabled_device()
      is called on a fully disabled device, to be released when the driver
      is unbound from the device, regardless of the enable_cnt.
      
      This leads to the situation that an ill-behaved driver can now make a
      device unusable to subsequent drivers by an imbalance in their use of
      pci_enable/disable_device().  That is a serious problem for secondary
      drivers like vfio-pci, which are innocent of the transgressions of
      the previous driver.
      
      Since the solution of this problem is not immediate and requires
      further discussion, revert commit b4b55cda and the issue it was
      supposed to address (a bug related to xen-pciback) will be taken
      care of in a different way going forward.
      Reported-by: NAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9e8ce4b9
  6. 19 3月, 2015 1 次提交
  7. 18 3月, 2015 3 次提交
  8. 17 3月, 2015 9 次提交
    • I
      x86/asm/entry/64: Rename 'old_rsp' to 'rsp_scratch' · c38e5038
      Ingo Molnar 提交于
      Make clear that the usage of PER_CPU(old_rsp) is purely temporary,
      by renaming it to 'rsp_scratch'.
      
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c38e5038
    • I
      x86/asm/entry/64: Update comments about stack frames · 7fcb3bc3
      Ingo Molnar 提交于
      Tweak a few outdated comments that were obsoleted by recent changes
      to syscall entry code:
      
       - we no longer have a "partial stack frame" on
         entry, ever.
      
       - explain the syscall entry usage of old_rsp.
      
      Partially based on a (split out of) patch from Denys Vlasenko.
      
      Originally-from: Denys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      7fcb3bc3
    • I
      x86/asm/entry/64: Remove thread_struct::usersp · ac9af498
      Ingo Molnar 提交于
      Nothing uses thread_struct::usersp anymore, so remove it.
      
      Originally-from: Denys Vlasenko <dvlasenk@redhat.com>
      Tested-by: NBorislav Petkov <bp@alien8.de>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ac9af498
    • I
      x86/asm/entry/64: Simplify 'old_rsp' usage · 9854dd74
      Ingo Molnar 提交于
      Remove all manipulations of PER_CPU(old_rsp) in C code:
      
       - it is not used on SYSRET return anymore, and system entries
         are atomic, so updating it from the fork and context switch
         paths is pointless.
      
       - Tweak a few related comments as well: we no longer have a
         "partial stack frame" on entry, ever.
      
      Based on (split out of) patch from Denys Vlasenko.
      
      Originally-from: Denys Vlasenko <dvlasenk@redhat.com>
      Tested-by: NBorislav Petkov <bp@alien8.de>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Denys Vlasenko <dvlasenk@redhat.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: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/1426599779-8010-2-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      9854dd74
    • D
      x86/asm/entry/64: Enable interrupts *after* we fetch PER_CPU_VAR(old_rsp) · 33db1fd4
      Denys Vlasenko 提交于
      We want to use PER_CPU_VAR(old_rsp) as a simple temporary register,
      to shuffle user-space RSP into (and from) when we set up the system
      call stack frame. At that point we cannot shuffle values into general
      purpose registers, because we have not saved them yet.
      
      To be able to do this shuffling into a memory location, we must be
      atomic and must not be preempted while we do the shuffling, otherwise
      the 'temporary' register gets overwritten by some other task's
      temporary register contents ...
      Tested-by: NBorislav Petkov <bp@alien8.de>
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Alexei Starovoitov <ast@plumgrid.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      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/1426600344-8254-1-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      33db1fd4
    • I
      x86/asm/entry: Document and clean up the enable_sep_cpu() and syscall32_cpu_init() functions · 8b6c0ab1
      Ingo Molnar 提交于
      Clean up the flow and document the functions a bit better.
      
      Cc: Denys 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>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      8b6c0ab1
    • D
      x86/asm/entry/32: Document the 32-bit SYSENTER "emergency stack" better · d828c71f
      Denys Vlasenko 提交于
      Before the patch, the 'tss_struct::stack' field was not referenced anywhere.
      
      It was used only to set SYSENTER's stack to point after the last byte
      of tss_struct, thus the trailing field, stack[64], was used.
      
      But grep would not know it. You can comment it out, compile,
      and kernel will even run until an unlucky NMI corrupts
      io_bitmap[] (which is also not easily detectable).
      
      This patch changes code so that the purpose and usage of this
      field is not mysterious anymore, and can be easily grepped for.
      
      This does change generated code, for a subtle reason:
      since tss_struct is ____cacheline_aligned, there happens to be
      5 longs of padding at the end. Old code was using the padding
      too; new code will strictly use it only for SYSENTER_stack[].
      Signed-off-by: NDenys 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/1425912738-559-2-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      d828c71f
    • D
      x86/asm/entry: Simplify task_pt_regs() macro definition · 5c39403e
      Denys Vlasenko 提交于
      Before this change, task_pt_regs() was using KSTK_TOP(),
      and it was the only use of that macro. In turn, KSTK_TOP used
      THREAD_SIZE_LONGS, and it was the only use of that macro too.
      
      Fold these macros into task_pt_regs(). Tweak comment
      about "- 8" - we now use a symbolic constant, not literal 8.
      Signed-off-by: NDenys Vlasenko <dvlasenk@redhat.com>
      Reviewed-by: NSteven Rostedt <rostedt@goodmis.org>
      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: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Drewry <wad@chromium.org>
      Link: http://lkml.kernel.org/r/1426255743-5394-1-git-send-email-dvlasenk@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      5c39403e
    • A
      x86/asm/entry/32: Document our abuse of x86_hw_tss::ss1 and x86_hw_tss::sp1 · 76e4c490
      Andy Lutomirski 提交于
      This has confused me for a while.  Now that I figured it out, document it.
      Signed-off-by: NAndy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/b7efc1b7364039824776f68e9ddee9ec1500e894.1426009661.git.luto@amacapital.netSigned-off-by: NIngo Molnar <mingo@kernel.org>
      76e4c490