1. 19 12月, 2017 1 次提交
    • J
      x86/stacktrace: Make zombie stack traces reliable · 6454b3bd
      Josh Poimboeuf 提交于
      Commit:
      
        1959a601 ("x86/dumpstack: Pin the target stack when dumping it")
      
      changed the behavior of stack traces for zombies.  Before that commit,
      /proc/<pid>/stack reported the last execution path of the zombie before
      it died:
      
        [<ffffffff8105b877>] do_exit+0x6f7/0xa80
        [<ffffffff8105bc79>] do_group_exit+0x39/0xa0
        [<ffffffff8105bcf0>] __wake_up_parent+0x0/0x30
        [<ffffffff8152dd09>] system_call_fastpath+0x16/0x1b
        [<00007fd128f9c4f9>] 0x7fd128f9c4f9
        [<ffffffffffffffff>] 0xffffffffffffffff
      
      After the commit, it just reports an empty stack trace.
      
      The new behavior is actually probably more correct.  If the stack
      refcount has gone down to zero, then the task has already gone through
      do_exit() and isn't going to run anymore.  The stack could be freed at
      any time and is basically gone, so reporting an empty stack makes sense.
      
      However, save_stack_trace_tsk_reliable() treats such a missing stack
      condition as an error.  That can cause livepatch transition stalls if
      there are any unreaped zombies.  Instead, just treat it as a reliable,
      empty stack.
      Reported-and-tested-by: NMiroslav Benes <mbenes@suse.cz>
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: live-patching@vger.kernel.org
      Fixes: af085d90 ("stacktrace/x86: add function for detecting reliable stack traces")
      Link: http://lkml.kernel.org/r/e4b09e630e99d0c1080528f0821fc9d9dbaeea82.1513631620.git.jpoimboe@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      6454b3bd
  2. 30 9月, 2017 1 次提交
    • V
      x86/stacktrace: Avoid recording save_stack_trace() wrappers · 77072f09
      Vlastimil Babka 提交于
      The save_stack_trace() and save_stack_trace_tsk() wrappers of
      __save_stack_trace() add themselves to the call stack, and thus appear in the
      recorded stacktraces. This is redundant and wasteful when we have limited space
      to record the useful part of the backtrace with e.g. page_owner functionality.
      
      Fix this by making sure __save_stack_trace() is noinline (which matches the
      current gcc decision) and bumping the skip in the wrappers
      (save_stack_trace_tsk() only when called for the current task). This is similar
      to what was done for arm in 3683f44c ("ARM: stacktrace: avoid listing
      stacktrace functions in stacktrace") and is pending for arm64.
      
      Also make sure that __save_stack_trace_reliable() doesn't get this problem in
      the future by marking it __always_inline (which matches current gcc decision),
      per Josh Poimboeuf.
      Signed-off-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Miroslav Benes <mbenes@suse.cz>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20170929092335.2744-1-vbabka@suse.czSigned-off-by: NIngo Molnar <mingo@kernel.org>
      77072f09
  3. 08 3月, 2017 1 次提交
    • J
      stacktrace/x86: add function for detecting reliable stack traces · af085d90
      Josh Poimboeuf 提交于
      For live patching and possibly other use cases, a stack trace is only
      useful if it can be assured that it's completely reliable.  Add a new
      save_stack_trace_tsk_reliable() function to achieve that.
      
      Note that if the target task isn't the current task, and the target task
      is allowed to run, then it could be writing the stack while the unwinder
      is reading it, resulting in possible corruption.  So the caller of
      save_stack_trace_tsk_reliable() must ensure that the task is either
      'current' or inactive.
      
      save_stack_trace_tsk_reliable() relies on the x86 unwinder's detection
      of pt_regs on the stack.  If the pt_regs are not user-mode registers
      from a syscall, then they indicate an in-kernel interrupt or exception
      (e.g. preemption or a page fault), in which case the stack is considered
      unreliable due to the nature of frame pointers.
      
      It also relies on the x86 unwinder's detection of other issues, such as:
      
      - corrupted stack data
      - stack grows the wrong way
      - stack walk doesn't reach the bottom
      - user didn't provide a large enough entries array
      
      Such issues are reported by checking unwind_error() and !unwind_done().
      
      Also add CONFIG_HAVE_RELIABLE_STACKTRACE so arch-independent code can
      determine at build time whether the function is implemented.
      Signed-off-by: NJosh Poimboeuf <jpoimboe@redhat.com>
      Reviewed-by: NMiroslav Benes <mbenes@suse.cz>
      Acked-by: Ingo Molnar <mingo@kernel.org>	# for the x86 changes
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      af085d90
  4. 02 3月, 2017 2 次提交
  5. 20 9月, 2016 1 次提交
  6. 16 9月, 2016 1 次提交
  7. 15 9月, 2016 1 次提交
    • J
      x86/dumpstack: Add get_stack_info() interface · cb76c939
      Josh Poimboeuf 提交于
      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: NJosh 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.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      cb76c939
  8. 14 7月, 2016 1 次提交
    • P
      x86/kernel: Audit and remove any unnecessary uses of module.h · 186f4360
      Paul Gortmaker 提交于
      Historically a lot of these existed because we did not have
      a distinction between what was modular code and what was providing
      support to modules via EXPORT_SYMBOL and friends.  That changed
      when we forked out support for the latter into the export.h file.
      
      This means we should be able to reduce the usage of module.h
      in code that is obj-y Makefile or bool Kconfig.  The advantage
      in doing so is that module.h itself sources about 15 other headers;
      adding significantly to what we feed cpp, and it can obscure what
      headers we are effectively using.
      
      Since module.h was the source for init.h (for __init) and for
      export.h (for EXPORT_SYMBOL) we consider each obj-y/bool instance
      for the presence of either and replace as needed.  Build testing
      revealed some implicit header usage that was fixed up accordingly.
      
      Note that some bool/obj-y instances remain since module.h is
      the header for some exception table entry stuff, and for things
      like __init_or_module (code that is tossed when MODULES=n).
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@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/20160714001901.31603-4-paul.gortmaker@windriver.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      186f4360
  9. 20 2月, 2016 1 次提交
  10. 15 6月, 2011 1 次提交
  11. 12 5月, 2011 1 次提交
  12. 18 3月, 2011 1 次提交
    • N
      x86, dumpstack: Correct stack dump info when frame pointer is available · e8e999cf
      Namhyung Kim 提交于
      Current stack dump code scans entire stack and check each entry
      contains a pointer to kernel code. If CONFIG_FRAME_POINTER=y it
      could mark whether the pointer is valid or not based on value of
      the frame pointer. Invalid entries could be preceded by '?' sign.
      
      However this was not going to happen because scan start point
      was always higher than the frame pointer so that they could not
      meet.
      
      Commit 9c0729dc ("x86: Eliminate bp argument from the stack
      tracing routines") delayed bp acquisition point, so the bp was
      read in lower frame, thus all of the entries were marked
      invalid.
      
      This patch fixes this by reverting above commit while retaining
      stack_frame() helper as suggested by Frederic Weisbecker.
      
      End result looks like below:
      
      before:
      
       [    3.508329] Call Trace:
       [    3.508551]  [<ffffffff814f35c9>] ? panic+0x91/0x199
       [    3.508662]  [<ffffffff814f3739>] ? printk+0x68/0x6a
       [    3.508770]  [<ffffffff81a981b2>] ? mount_block_root+0x257/0x26e
       [    3.508876]  [<ffffffff81a9821f>] ? mount_root+0x56/0x5a
       [    3.508975]  [<ffffffff81a98393>] ? prepare_namespace+0x170/0x1a9
       [    3.509216]  [<ffffffff81a9772b>] ? kernel_init+0x1d2/0x1e2
       [    3.509335]  [<ffffffff81003894>] ? kernel_thread_helper+0x4/0x10
       [    3.509442]  [<ffffffff814f6880>] ? restore_args+0x0/0x30
       [    3.509542]  [<ffffffff81a97559>] ? kernel_init+0x0/0x1e2
       [    3.509641]  [<ffffffff81003890>] ? kernel_thread_helper+0x0/0x10
      
      after:
      
       [    3.522991] Call Trace:
       [    3.523351]  [<ffffffff814f35b9>] panic+0x91/0x199
       [    3.523468]  [<ffffffff814f3729>] ? printk+0x68/0x6a
       [    3.523576]  [<ffffffff81a981b2>] mount_block_root+0x257/0x26e
       [    3.523681]  [<ffffffff81a9821f>] mount_root+0x56/0x5a
       [    3.523780]  [<ffffffff81a98393>] prepare_namespace+0x170/0x1a9
       [    3.523885]  [<ffffffff81a9772b>] kernel_init+0x1d2/0x1e2
       [    3.523987]  [<ffffffff81003894>] kernel_thread_helper+0x4/0x10
       [    3.524228]  [<ffffffff814f6880>] ? restore_args+0x0/0x30
       [    3.524345]  [<ffffffff81a97559>] ? kernel_init+0x0/0x1e2
       [    3.524445]  [<ffffffff81003890>] ? kernel_thread_helper+0x0/0x10
      
       -v5:
         * fix build breakage with oprofile
      
       -v4:
         * use 0 instead of regs->bp
         * separate out printk changes
      
       -v3:
         * apply comment from Frederic
         * add a couple of printk fixes
      Signed-off-by: NNamhyung Kim <namhyung@gmail.com>
      Acked-by: NPeter Zijlstra <a.p.zijlstra@chello.nl>
      Acked-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Soren Sandmann <ssp@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Robert Richter <robert.richter@amd.com>
      LKML-Reference: <1300416006-3163-1-git-send-email-namhyung@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      e8e999cf
  13. 18 11月, 2010 1 次提交
    • S
      x86: Eliminate bp argument from the stack tracing routines · 9c0729dc
      Soeren Sandmann Pedersen 提交于
      The various stack tracing routines take a 'bp' argument in which the
      caller is supposed to provide the base pointer to use, or 0 if doesn't
      have one. Since bp is garbage whenever CONFIG_FRAME_POINTER is not
      defined, this means all callers in principle should either always pass
      0, or be conditional on CONFIG_FRAME_POINTER.
      
      However, there are only really three use cases for stack tracing:
      
      (a) Trace the current task, including IRQ stack if any
      (b) Trace the current task, but skip IRQ stack
      (c) Trace some other task
      
      In all cases, if CONFIG_FRAME_POINTER is not defined, bp should just
      be 0.  If it _is_ defined, then
      
      - in case (a) bp should be gotten directly from the CPU's register, so
        the caller should pass NULL for regs,
      
      - in case (b) the caller should should pass the IRQ registers to
        dump_trace(),
      
      - in case (c) bp should be gotten from the top of the task's stack, so
        the caller should pass NULL for regs.
      
      Hence, the bp argument is not necessary because the combination of
      task and regs is sufficient to determine an appropriate value for bp.
      
      This patch introduces a new inline function stack_frame(task, regs)
      that computes the desired bp. This function is then called from the
      two versions of dump_stack().
      Signed-off-by: NSoren Sandmann <ssp@redhat.com>
      Acked-by: NSteven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Arjan van de Ven <arjan@infradead.org>,
      Cc: Frederic Weisbecker <fweisbec@gmail.com>,
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>,
      LKML-Reference: <m3oc9rop28.fsf@dhcp-100-3-82.bos.redhat.com>>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      9c0729dc
  14. 09 6月, 2010 3 次提交
    • O
      x86: Unify save_stack_address() and save_stack_address_nosched() · 018378c5
      Oleg Nesterov 提交于
      Cleanup. Factor the common code in save_stack_address() and
      save_stack_address_nosched().
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Roland McGrath <roland@redhat.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      LKML-Reference: <20100603193243.GA31534@redhat.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      018378c5
    • O
      x86: Make save_stack_address() !CONFIG_FRAME_POINTER friendly · 147ec4d2
      Oleg Nesterov 提交于
      If CONFIG_FRAME_POINTER=n, print_context_stack() shouldn't neglect the
      non-reliable addresses on stack, this is all we have if dump_trace(bp)
      is called with the wrong or zero bp.
      
      For example, /proc/pid/stack doesn't work if CONFIG_FRAME_POINTER=n.
      
      This patch obviously has no effect if CONFIG_FRAME_POINTER=y, otherwise
      it reverts 1650743c "x86: don't save unreliable stack trace entries".
      
      Also, remove the unnecessary type-cast.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Roland McGrath <roland@redhat.com>
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Cc: Vegard Nossum <vegard.nossum@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <20100603193239.GA31530@redhat.com>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      147ec4d2
    • F
      x86: Unify dumpstack.h and stacktrace.h · c9cf4dbb
      Frederic Weisbecker 提交于
      arch/x86/include/asm/stacktrace.h and arch/x86/kernel/dumpstack.h
      declare headers of objects that deal with the same topic.
      Actually most of the files that include stacktrace.h also include
      dumpstack.h
      
      Although dumpstack.h seems more reserved for internals of stack
      traces, those are quite often needed to define specialized stack
      trace operations. And perf event arch headers are going to need
      access to such low level operations anyway. So don't continue to
      bother with dumpstack.h as it's not anymore about isolated deep
      internals.
      
      v2: fix struct stack_frame definition conflict in sysprof
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Soeren Sandmann <sandmann@daimi.au.dk>
      c9cf4dbb
  15. 17 12月, 2009 1 次提交
    • F
      perf events, x86/stacktrace: Make stack walking optional · 61c1917f
      Frederic Weisbecker 提交于
      The current print_context_stack helper that does the stack
      walking job is good for usual stacktraces as it walks through
      all the stack and reports even addresses that look unreliable,
      which is nice when we don't have frame pointers for example.
      
      But we have users like perf that only require reliable
      stacktraces, and those may want a more adapted stack walker, so
      lets make this function a callback in stacktrace_ops that users
      can tune for their needs.
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Paul Mackerras <paulus@samba.org>
      LKML-Reference: <1261024834-5336-1-git-send-regression-fweisbec@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      61c1917f
  16. 13 6月, 2009 1 次提交
    • V
      x86: add save_stack_trace_bp() for tracing from a specific stack frame · acc6be54
      Vegard Nossum 提交于
      This will help kmemcheck (and possibly other debugging tools) since we
      can now simply pass regs->bp to the stack tracer instead of specifying
      the number of stack frames to skip, which is unreliable if gcc decides
      to inline functions, etc.
      
      Note that this makes the API incomplete for other architectures, but I
      expect that those can be updated lazily, e.g. when they need it.
      
      Cc: Arjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NVegard Nossum <vegard.nossum@gmail.com>
      acc6be54
  17. 15 5月, 2009 1 次提交
    • S
      x86/stacktrace: return 0 instead of -1 for stack ops · 29a67975
      Steven Rostedt 提交于
      If we return -1 in the ops->stack for the stacktrace saving, we end up
      breaking out of the loop if the stack we are tracing is in the exception
      stack. This causes traces like:
      
                <idle>-0     [002] 34263.745825: raise_softirq_irqoff <-__blk_complete_request
                <idle>-0     [002] 34263.745826:
       <= 0
       <= 0
       <= 0
       <= 0
       <= 0
       <= 0
       <= 0
      
      By returning "0" instead, the irq stack is saved as well, and we see:
      
                <idle>-0     [003]   883.280992: raise_softirq_irqoff <-__hrtimer_star
      t_range_ns
                <idle>-0     [003]   883.280992:
       <= hrtimer_start_range_ns
       <= tick_nohz_restart_sched_tick
       <= cpu_idle
       <= start_secondary
       <=
       <= 0
       <= 0
      
      [ Impact: record stacks from interrupts ]
      Signed-off-by: NSteven Rostedt <rostedt@goodmis.org>
      29a67975
  18. 31 1月, 2009 1 次提交
  19. 23 11月, 2008 2 次提交
  20. 30 6月, 2008 1 次提交
  21. 26 2月, 2008 1 次提交
    • V
      x86: don't save unreliable stack trace entries · 1650743c
      Vegard Nossum 提交于
      Currently, there is no way for print_stack_trace() to determine whether
      a given stack trace entry was deemed reliable or not, simply because
      save_stack_trace() does not record this information. (Perhaps needless
      to say, this makes the saved stack traces A LOT harder to read, and
      probably with no other benefits, since debugging features that use
      save_stack_trace() most likely also require frame pointers, etc.)
      
      This patch reverts to the old behaviour of only recording the reliable trace
      entries for saved stack traces.
      Signed-off-by: NVegard Nossum <vegardno@ifi.uio.no>
      Acked-by: NArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1650743c
  22. 30 1月, 2008 4 次提交
  23. 26 1月, 2008 1 次提交
  24. 18 10月, 2007 1 次提交
  25. 14 10月, 2007 1 次提交
    • D
      Delete filenames in comments. · 835c34a1
      Dave Jones 提交于
      Since the x86 merge, lots of files that referenced their own filenames
      are no longer correct.  Rather than keep them up to date, just delete
      them, as they add no real value.
      
      Additionally:
      - fix up comment formatting in scx200_32.c
      - Remove a credit from myself in setup_64.c from a time when we had no SCM
      - remove longwinded history from tsc_32.c which can be figured out from
        git.
      Signed-off-by: NDave Jones <davej@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      835c34a1
  26. 11 10月, 2007 1 次提交
  27. 09 5月, 2007 1 次提交
  28. 13 2月, 2007 1 次提交
  29. 26 9月, 2006 2 次提交
    • A
      [PATCH] Merge stacktrace and show_trace · c0b766f1
      Andi Kleen 提交于
      This unifies the standard backtracer and the new stacktrace
      in memory backtracer. The standard one is converted to use callbacks
      and then reimplement stacktrace using new callbacks.
      
      The main advantage is that stacktrace can now use the new dwarf2 unwinder
      and avoid false positives in many cases.
      
      I kept it simple to make sure the standard backtracer stays reliable.
      
      Cc: mingo@elte.hu
      Signed-off-by: NAndi Kleen <ak@suse.de>
      c0b766f1
    • A
      [PATCH] x86: Some preparationary cleanup for stack trace · 5a1b3999
      Andi Kleen 提交于
      - Remove unused all_contexts parameter
      No caller used it
      - Move skip argument into the structure (needed for
      followon patches)
      
      Cc: mingo@elte.hu
      Signed-off-by: NAndi Kleen <ak@suse.de>
      5a1b3999
  30. 04 7月, 2006 1 次提交