Josh Poimboeuf 187b96db5c x86/unwind/orc: Fix unwind_get_return_address_ptr() for inactive tasks
Normally, show_trace_log_lvl() scans the stack, looking for text
addresses to print.  In parallel, it unwinds the stack with
unwind_next_frame().  If the stack address matches the pointer returned
by unwind_get_return_address_ptr() for the current frame, the text
address is printed normally without a question mark.  Otherwise it's
considered a breadcrumb (potentially from a previous call path) and it's
printed with a question mark to indicate that the address is unreliable
and typically can be ignored.

Since the following commit:

  f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tasks")

... for inactive tasks, show_trace_log_lvl() prints *only* unreliable
addresses (prepended with '?').

That happens because, for the first frame of an inactive task,
unwind_get_return_address_ptr() returns the wrong return address
pointer: one word *below* the task stack pointer.  show_trace_log_lvl()
starts scanning at the stack pointer itself, so it never finds the first
'reliable' address, causing only guesses to being printed.

The first frame of an inactive task isn't a normal stack frame.  It's
actually just an instance of 'struct inactive_task_frame' which is left
behind by __switch_to_asm().  Now that this inactive frame is actually
exposed to callers, fix unwind_get_return_address_ptr() to interpret it
properly.

Fixes: f1d9a2abff66 ("x86/unwind/orc: Don't skip the first frame for inactive tasks")
Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200522135435.vbxs7umku5pyrdbk@treble
2020-05-22 19:55:17 +02:00
..
2020-04-19 11:58:32 -07:00
2020-03-30 19:14:28 -07:00
2020-01-09 14:40:03 +01:00
2019-11-26 19:25:25 -08:00
2019-11-27 11:42:01 -08:00
2020-02-26 15:21:22 +01:00
2019-11-12 16:21:15 +01:00
2019-11-12 16:21:15 +01:00
2020-03-21 16:03:25 +01:00
2020-02-16 20:58:06 +01:00
2019-11-28 11:16:43 -08:00
2019-06-24 19:19:24 +02:00
2020-03-21 16:03:25 +01:00
2020-03-21 16:03:25 +01:00
2020-03-30 19:35:52 -07:00
2020-02-16 20:58:06 +01:00
2020-03-21 16:03:25 +01:00
2020-03-30 19:35:52 -07:00
2020-03-30 19:55:39 -07:00
2020-02-16 20:58:06 +01:00
2020-04-15 11:13:12 +02:00
2020-02-09 12:11:12 -08:00