Skip to content
  1. Sep 15, 2016
    • Josh Poimboeuf's avatar
      x86/dumpstack: Add recursion checking for all stacks · fcd709ef
      Josh Poimboeuf authored
      
      
      in_exception_stack() has some recursion checking which makes sure the
      stack trace code never traverses a given exception stack more than once.
      This prevents an infinite loop if corruption somehow causes a stack's
      "next stack" pointer to point to itself (directly or indirectly).
      
      The recursion checking can be useful for other stacks in addition to the
      exception stack, so extend it to work for all stacks.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/95de5db4cfe111754845a5cef04e20630d01423f.1473905218.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      fcd709ef
    • Josh Poimboeuf's avatar
      x86/dumpstack: Add support for unwinding empty IRQ stacks · 5fe599e0
      Josh Poimboeuf authored
      
      
      When an interrupt happens in entry code while running on a software IRQ
      stack, and the IRQ stack was empty, regs->sp will contain the stack end
      address (e.g., irq_stack_ptr).  If the regs are passed to dump_trace(),
      get_stack_info() will report STACK_TYPE_UNKNOWN, causing dump_trace() to
      return prematurely without trying to go to the next stack.
      
      Update the bounds checking for software interrupt stacks so that the
      ending address is now considered part of the stack.
      
      This means that it's now possible for the 'walk_stack' callbacks --
      print_context_stack() and print_context_stack_bp() -- to be called with
      an empty stack.  But that's fine; they're already prepared to deal with
      that due to their on_stack() checks.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/5a5e5de92dcf11e8dc6b6e8e50ad7639d067830b.1473905218.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5fe599e0
    • Josh Poimboeuf's avatar
      x86/dumpstack: Add get_stack_info() interface · cb76c939
      Josh Poimboeuf authored
      
      
      valid_stack_ptr() is buggy: it assumes that all stacks are of size
      THREAD_SIZE, which is not true for exception stacks.  So the
      walk_stack() callbacks will need to know the location of the beginning
      of the stack as well as the end.
      
      Another issue is that in general the various features of a stack (type,
      size, next stack pointer, description string) are scattered around in
      various places throughout the stack dump code.
      
      Encapsulate all that information in a single place with a new stack_info
      struct and a get_stack_info() interface.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/8164dd0db96b7e6a279fa17ae5e6dc375eecb4a9.1473905218.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cb76c939
    • Josh Poimboeuf's avatar
      x86/dumpstack: Simplify in_exception_stack() · 9c003907
      Josh Poimboeuf authored
      
      
      in_exception_stack() does some bad, bad things just so the unwinder can
      print different values for different areas of the debug exception stack.
      
      There's no need to clarify where exactly on the stack it is.  Just print
      "#DB" and be done with it.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/e91cb410169dd576678dd427c35efb716fd0cee1.1473905218.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9c003907
  2. Sep 14, 2016
    • Josh Poimboeuf's avatar
      x86/dumpstack: Allow preemption in show_stack_log_lvl() and dump_trace() · cfeeed27
      Josh Poimboeuf authored
      
      
      show_stack_log_lvl() and dump_trace() are already preemption safe:
      
      - If they're running in irq or exception context, preemption is already
        disabled and the percpu stack pointers can be trusted.
      
      - If they're running with preemption enabled, they must be running on
        the task stack anyway, so it doesn't matter if they're comparing the
        stack pointer against a percpu stack pointer from this CPU or another
        one: either way it won't match.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/a0ca0b1044eca97d4f0ec7c1619cf80b3b65560d.1473371307.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cfeeed27
    • Andy Lutomirski's avatar
      x86/entry/64: Clean up and document espfix64 stack setup · 85063fac
      Andy Lutomirski authored
      
      
      The espfix64 setup code was a bit inscrutible and contained an
      unnecessary push of RAX.  Remove that push, update all the stack
      offsets to match, and document the whole mess.
      
      Reported-By: default avatarBorislav Petkov <bp@alien8.de>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/e5459eb10cf1175c8b36b840bc425f210d045f35.1473717910.git.luto@kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      85063fac
    • Andy Lutomirski's avatar
      selftests/x86/sigreturn: Use CX, not AX, as the scratch register · 1ef0199a
      Andy Lutomirski authored
      
      
      RAX is handled specially in ESPFIX64.  Use CX as our scratch
      register so that, if something goes wrong with RAX handling, we'll
      notice.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Reviewed-by: default avatarBorislav Petkov <bp@suse.de>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuah Khan <shuahkh@osg.samsung.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/9ceeb24ea56925586c330dc46306f757ddea9fb5.1473717910.git.luto@kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1ef0199a
  3. Sep 08, 2016
    • Josh Poimboeuf's avatar
      x86/dumpstack: Remove unnecessary stack pointer arguments · 5a8ff54c
      Josh Poimboeuf authored
      
      
      When calling show_stack_log_lvl() or dump_trace() with a regs argument,
      providing a stack pointer or frame pointer is redundant.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com&gt;d>
      Reviewed-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1694e2e955e3b9a73a3c3d5ba2634344014dd550.1472057064.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      5a8ff54c
    • Josh Poimboeuf's avatar
      x86/dumpstack: Add get_stack_pointer() and get_frame_pointer() · 4b8afafb
      Josh Poimboeuf authored
      
      
      The various functions involved in dumping the stack all do similar
      things with regard to getting the stack pointer and the frame pointer
      based on the regs and task arguments.  Create helper functions to
      do that instead.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Reviewed-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/f448914885a35f333fe04da1b97a6c2cc1f80974.1472057064.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4b8afafb
    • Josh Poimboeuf's avatar
      x86/dumpstack: Make printk_stack_address() more generally useful · d438f5fd
      Josh Poimboeuf authored
      
      
      Change printk_stack_address() to be useful when called by an unwinder
      outside the context of dump_trace().
      
      Specifically:
      
      - printk_stack_address()'s 'data' argument is always used as the log
        level string.  Make that explicit.
      
      - Call touch_nmi_watchdog().
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/9fbe0db05bacf66d337c162edbf61450d0cff1e2.1472057064.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d438f5fd
    • Josh Poimboeuf's avatar
      oprofile/x86: Add regs->ip to oprofile trace · 3e344a0d
      Josh Poimboeuf authored
      
      
      dump_trace() doesn't add the interrupted instruction's address to the
      trace, so add it manually.  This makes the profile more useful, and also
      makes it more consistent with what perf profiling does.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarRobert Richter <rric@kernel.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/6c745a83dbd69fc6857ef9b2f8be0f011d775936.1472057064.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      3e344a0d
    • Josh Poimboeuf's avatar
      perf/x86: Check perf_callchain_store() error · 019e579d
      Josh Poimboeuf authored
      
      
      Add a check to perf_callchain_kernel() so that it returns early if the
      callchain entry array is already full.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/dce6d60bab08be2600efd90021d9b85620646161.1472057064.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      019e579d
    • Colin Ian King's avatar
      selftests/x86: Fix spelling mistake "preseve" -> "preserve" · 1d723de7
      Colin Ian King authored
      
      
      Trivial fix to spelling mistakes in printf messages.
      
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Acked-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shuah Khan <shuah@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kselftest@vger.kernel.org
      Link: http://lkml.kernel.org/r/20160828105106.9763-1-colin.king@canonical.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1d723de7
    • Andy Lutomirski's avatar
      virtio_console: Stop doing DMA on the stack · 9472fe70
      Andy Lutomirski authored
      
      
      virtio_console uses a small DMA buffer for control requests.  Move
      that buffer into heap memory.
      
      Doing virtio DMA on the stack is normally okay on non-DMA-API virtio
      systems (which is currently most of them), but it breaks completely
      if the stack is virtually mapped (CONFIG_VMAP_STACK=y).
      
      Tested by typing both directions using picocom aimed at /dev/hvc0.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Reviewed-by: default avatarAmit Shah <amit.shah@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: virtualization@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/0afe68f9b4be6c95af9e7672b07acd0274c26dfe.1472569320.git.luto@kernel.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9472fe70
    • Andy Lutomirski's avatar
      x86/mm: Improve stack-overflow #PF handling · 6271cfdf
      Andy Lutomirski authored
      
      
      If we get a page fault indicating kernel stack overflow, invoke
      handle_stack_overflow().  To prevent us from overflowing the stack
      again while handling the overflow (because we are likely to have
      very little stack space left), call handle_stack_overflow() on the
      double-fault stack.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/6d6cf96b3fb9b4c9aa303817e1dc4de0c7c36487.1472603235.git.luto@kernel.org
      [ Minor edit. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6271cfdf
    • Ingo Molnar's avatar
  4. Aug 24, 2016
    • Brian Gerst's avatar
      sched: Remove __schedule() non-standard frame annotation · 01175255
      Brian Gerst authored
      
      
      Now that the x86 switch_to() uses the standard C calling convention,
      the STACK_FRAME_NON_STANDARD() annotation is no longer needed.
      
      Suggested-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-8-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      01175255
    • Brian Gerst's avatar
      sched/x86: Fix thread_saved_pc() · ffcb043b
      Brian Gerst authored
      
      
      thread_saved_pc() was using a completely bogus method to get the return
      address.  Since switch_to() was previously inlined, there was no sane way
      to know where on the stack the return address was stored.  Now with the
      frame of a sleeping thread well defined, this can be implemented correctly.
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-7-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ffcb043b
    • Brian Gerst's avatar
      sched/x86: Pass kernel thread parameters in 'struct fork_frame' · 616d2483
      Brian Gerst authored
      
      
      Instead of setting up a fake pt_regs context, put the kernel thread
      function pointer and arg into the unused callee-restored registers
      of 'struct fork_frame'.
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-6-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      616d2483
    • Brian Gerst's avatar
      sched/x86: Rewrite the switch_to() code · 0100301b
      Brian Gerst authored
      
      
      Move the low-level context switch code to an out-of-line asm stub instead of
      using complex inline asm.  This allows constructing a new stack frame for the
      child process to make it seamlessly flow to ret_from_fork without an extra
      test and branch in __switch_to().  It also improves code generation for
      __schedule() by using the C calling convention instead of clobbering all
      registers.
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-5-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0100301b
    • Brian Gerst's avatar
      sched/x86: Add 'struct inactive_task_frame' to better document the sleeping task stack frame · 7b32aead
      Brian Gerst authored
      
      
      Add 'struct inactive_task_frame', which defines the layout of the stack for
      a sleeping process.  For now, the only defined field is the BP register
      (frame pointer).
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-4-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      7b32aead
    • Brian Gerst's avatar
      sched/x86/64, kgdb: Clear GDB_PS on 64-bit · 16363019
      Brian Gerst authored
      
      
      switch_to() no longer saves EFLAGS, so it's bogus to look for it on the
      stack.  Set it to zero like 32-bit.
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-3-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      16363019
    • Brian Gerst's avatar
      sched/x86/32, kgdb: Don't use thread.ip in sleeping_thread_to_gdb_regs() · 4e047aa7
      Brian Gerst authored
      
      
      Match 64-bit and set gdb_regs[GDB_PC] to zero.  thread.ip is always the
      same point in the scheduler (except for newly forked processes), and will
      be removed in a future patch.
      
      Signed-off-by: default avatarBrian Gerst <brgerst@gmail.com>
      Reviewed-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jason Wessel <jason.wessel@windriver.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1471106302-10159-2-git-send-email-brgerst@gmail.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      4e047aa7
    • Josh Poimboeuf's avatar
      x86/dumpstack/ftrace: Don't print unreliable addresses in print_context_stack_bp() · 13e25bab
      Josh Poimboeuf authored
      
      
      When function graph tracing is enabled, print_context_stack_bp() can
      report return_to_handler() as an unreliable address, which is confusing
      and misleading: return_to_handler() is really only useful as a hint for
      debugging, whereas print_context_stack_bp() users only care about the
      actual 'reliable' call path.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/c51aef578d8027791b38d2ad9bac0c7f499fde91.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      13e25bab
    • Josh Poimboeuf's avatar
      x86/dumpstack/ftrace: Mark function graph handler function as unreliable · 6f727b84
      Josh Poimboeuf authored
      
      
      When function graph tracing is enabled for a function, its return
      address on the stack is replaced with the address of an ftrace handler
      (return_to_handler).
      
      Currently 'return_to_handler' can be reported as reliable.  That's not
      ideal, and can actually be misleading.  When saving or dumping the
      stack, you normally only care about what led up to that point (the call
      path), rather than what will happen in the future (the return path).
      
      That's especially true in the non-oops stack trace case, which isn't
      used for debugging.  For example, in a perf profiling operation,
      reporting return_to_handler() in the trace would just be confusing.
      
      And in the oops case, where debugging is important, "unreliable" is also
      more appropriate there because it serves as a hint that graph tracing
      was involved, instead of trying to imply that return_to_handler() was
      the real caller.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/f8af15749c7d632d3e7f815995831d5b7f82950d.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6f727b84
    • Josh Poimboeuf's avatar
      ftrace/x86: Implement HAVE_FUNCTION_GRAPH_RET_ADDR_PTR · 471bd10f
      Josh Poimboeuf authored
      
      
      Use the more reliable version of ftrace_graph_ret_addr() so we no longer
      have to worry about the unwinder getting out of sync with the function
      graph ret_stack index, which can happen if the unwinder skips any frames
      before calling ftrace_graph_ret_addr().
      
      This fixes this issue (and several others like it):
      
        $ cat /proc/self/stack
        [<ffffffff810489a2>] save_stack_trace_tsk+0x22/0x40
        [<ffffffff81311a89>] proc_pid_stack+0xb9/0x110
        [<ffffffff813127c4>] proc_single_show+0x54/0x80
        [<ffffffff812be088>] seq_read+0x108/0x3e0
        [<ffffffff812923d7>] __vfs_read+0x37/0x140
        [<ffffffff812929d9>] vfs_read+0x99/0x140
        [<ffffffff81293f28>] SyS_read+0x58/0xc0
        [<ffffffff818af97c>] entry_SYSCALL_64_fastpath+0x1f/0xbd
        [<ffffffffffffffff>] 0xffffffffffffffff
      
        $ echo function_graph > /sys/kernel/debug/tracing/current_tracer
      
        $ cat /proc/self/stack
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff810394cc>] print_context_stack+0xfc/0x100
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff8103891b>] dump_trace+0x12b/0x350
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff810489a2>] save_stack_trace_tsk+0x22/0x40
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff81311a89>] proc_pid_stack+0xb9/0x110
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff813127c4>] proc_single_show+0x54/0x80
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff812be088>] seq_read+0x108/0x3e0
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff812923d7>] __vfs_read+0x37/0x140
        [<ffffffff818b2428>] return_to_handler+0x0/0x27
        [<ffffffff812929d9>] vfs_read+0x99/0x140
        [<ffffffffffffffff>] 0xffffffffffffffff
      
      Enabling function graph tracing causes the stack trace to change in two
      ways:
      
      First, the real call addresses are confusingly interspersed with
      'return_to_handler' addresses.  This issue will be fixed by the next
      patch.
      
      Second, the stack trace is offset by two frames, because the unwinder
      skipped the first two frames and got out of sync with the ret_stack
      index.  This patch fixes this issue.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/a6d623e36f8d08f9a17bd74d804d201177a23afd.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      471bd10f
    • Josh Poimboeuf's avatar
      x86/dumpstack/ftrace: Convert dump_trace() callbacks to use ftrace_graph_ret_addr() · 408fe5de
      Josh Poimboeuf authored
      
      
      Convert print_context_stack() and print_context_stack_bp() to use the
      arch-independent ftrace_graph_ret_addr() helper.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/56ec97cafc1bf2e34d1119e6443d897db406da86.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      408fe5de
    • Josh Poimboeuf's avatar
      ftrace: Add ftrace_graph_ret_addr() stack unwinding helpers · 223918e3
      Josh Poimboeuf authored
      
      
      When function graph tracing is enabled for a function, ftrace modifies
      the stack by replacing the original return address with the address of a
      hook function (return_to_handler).
      
      Stack unwinders need a way to get the original return address.  Add an
      arch-independent helper function for that named ftrace_graph_ret_addr().
      
      This adds two variations of the function: one depends on
      HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, and the other relies on an index state
      variable.
      
      The former is recommended because, in some cases, the latter can cause
      problems when the unwinder skips stack frames.  It can get out of sync
      with the ret_stack index and wrong addresses can be reported for the
      stack trace.
      
      Once all arches have been ported to use
      HAVE_FUNCTION_GRAPH_RET_ADDR_PTR, we can get rid of the distinction.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/36bd90f762fc5e5af3929e3797a68a64906421cf.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      223918e3
    • Josh Poimboeuf's avatar
      ftrace: Add return address pointer to ftrace_ret_stack · 9a7c348b
      Josh Poimboeuf authored
      
      
      Storing this value will help prevent unwinders from getting out of sync
      with the function graph tracer ret_stack.  Now instead of needing a
      stateful iterator, they can compare the return address pointer to find
      the right ret_stack entry.
      
      Note that an array of 50 ftrace_ret_stack structs is allocated for every
      task.  So when an arch implements this, it will add either 200 or 400
      bytes of memory usage per task (depending on whether it's a 32-bit or
      64-bit platform).
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/a95cfcc39e8f26b89a430c56926af0bb217bc0a1.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9a7c348b
    • Josh Poimboeuf's avatar
      ftrace: Only allocate the ret_stack 'fp' field when needed · daa460a8
      Josh Poimboeuf authored
      
      
      This saves some memory when HAVE_FUNCTION_GRAPH_FP_TEST isn't defined.
      On x86_64 with newer versions of gcc which have -mfentry, it saves 400
      bytes per task.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/5c7747d9ea7b5cb47ef0a8ce8a6cea6bf7aa94bf.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      daa460a8
    • Josh Poimboeuf's avatar
      ftrace: Remove CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST from config · e4a744ef
      Josh Poimboeuf authored
      
      
      Make HAVE_FUNCTION_GRAPH_FP_TEST a normal define, independent from
      kconfig.  This removes some config file pollution and simplifies the
      checking for the fp test.
      
      Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Acked-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Byungchul Park <byungchul.park@lge.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: Nilay Vaish <nilayvaish@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/2c4e5f05054d6d367f702fd153af7a0109dd5c81.1471607358.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e4a744ef
    • Andy Lutomirski's avatar
      x86/mm/64: Enable vmapped stacks (CONFIG_HAVE_ARCH_VMAP_STACK=y) · e37e43a4
      Andy Lutomirski authored
      
      
      This allows x86_64 kernels to enable vmapped stacks by setting
      HAVE_ARCH_VMAP_STACK=y - which enables the CONFIG_VMAP_STACK=y
      high level Kconfig option.
      
      There are a couple of interesting bits:
      
      First, x86 lazily faults in top-level paging entries for the vmalloc
      area.  This won't work if we get a page fault while trying to access
      the stack: the CPU will promote it to a double-fault and we'll die.
      To avoid this problem, probe the new stack when switching stacks and
      forcibly populate the pgd entry for the stack when switching mms.
      
      Second, once we have guard pages around the stack, we'll want to
      detect and handle stack overflow.
      
      I didn't enable it on x86_32.  We'd need to rework the double-fault
      code a bit and I'm concerned about running out of vmalloc virtual
      addresses under some workloads.
      
      This patch, by itself, will behave somewhat erratically when the
      stack overflows while RSP is still more than a few tens of bytes
      above the bottom of the stack.  Specifically, we'll get #PF and make
      it to no_context and them oops without reliably triggering a
      double-fault, and no_context doesn't know about stack overflows.
      The next patch will improve that case.
      
      Thank you to Nadav and Brian for helping me pay enough attention to
      the SDM to hopefully get this right.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Nadav Amit <nadav.amit@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/c88f3e2920b18e6cc621d772a04a62c06869037e.1470907718.git.luto@kernel.org
      [ Minor edits. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e37e43a4
    • Andy Lutomirski's avatar
      dma-api: Teach the "DMA-from-stack" check about vmapped stacks · b4a0f533
      Andy Lutomirski authored
      
      
      If we're using CONFIG_VMAP_STACK=y and we manage to point an sg entry
      at the stack, then either the sg page will be in highmem or sg_virt()
      will return the direct-map alias.  In neither case will the existing
      check_for_stack() implementation realize that it's a stack page.
      
      Fix it by explicitly checking for stack pages.
      
      This has no effect by itself.  It's broken out for ease of review.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/448460622731312298bf19dcbacb1606e75de7a9.1470907718.git.luto@kernel.org
      [ Minor edits. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b4a0f533
    • Andy Lutomirski's avatar
      fork: Add generic vmalloced stack support · ba14a194
      Andy Lutomirski authored
      
      
      If CONFIG_VMAP_STACK=y is selected, kernel stacks are allocated with
      __vmalloc_node_range().
      
      Grsecurity has had a similar feature (called GRKERNSEC_KSTACKOVERFLOW=y)
      for a long time.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/14c07d4fd173a5b117f51e8b939f9f4323e39899.1470907718.git.luto@kernel.org
      [ Minor edits. ]
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      ba14a194
    • Ingo Molnar's avatar
      eb4e8410
    • Borislav Petkov's avatar
      x86/entry: Remove outdated comment about SYSCALL targets · 556b6723
      Borislav Petkov authored
      
      
      The comment probably meant some old AMD64 incarnation which most likely
      never saw the light of day. STAR and LSTAR are two different registers
      and STAR sets CS/SS(DS) selectors for *all* modes, not only 32-bit.
      
      So simply remove that comment.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20160823172356.15879-1-bp@alien8.de
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      556b6723
  5. Aug 22, 2016
  6. Aug 20, 2016
    • Helge Deller's avatar
      parisc: Fix order of EREFUSED define in errno.h · 3eb53b20
      Helge Deller authored
      
      
      When building gccgo in userspace, errno.h gets parsed and the go include file
      sysinfo.go is generated.
      
      Since EREFUSED is defined to the same value as ECONNREFUSED, and ECONNREFUSED
      is defined later on in errno.h, this leads to go complaining that EREFUSED
      isn't defined yet.
      
      Fix this trivial problem by moving the define of EREFUSED down after
      ECONNREFUSED in errno.h (and clean up the indenting while touching this line).
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: stable@vger.kernel.org
      3eb53b20