linux-stable/arch/riscv
Chen Huang eac2f3059e
riscv: stacktrace: fix the riscv stacktrace when CONFIG_FRAME_POINTER enabled
As [1] and [2] said, the arch_stack_walk should not to trace itself, or it will
leave the trace unexpectedly when called. The example is when we do "cat
/sys/kernel/debug/page_owner", all pages' stack is the same.

arch_stack_walk+0x18/0x20
stack_trace_save+0x40/0x60
register_dummy_stack+0x24/0x5e
init_page_owner+0x2e

So we use __builtin_frame_address(1) as the first frame to be walked. And mark
the arch_stack_walk() noinline.

We found that pr_cont will affact pages' stack whose task state is RUNNING when
testing "echo t > /proc/sysrq-trigger". So move the place of pr_cont and mark
the function dump_backtrace() noinline.

Also we move the case when task == NULL into else branch, and test for it in
"echo c > /proc/sysrq-trigger".

[1] https://lore.kernel.org/lkml/20210319184106.5688-1-mark.rutland@arm.com/
[2] https://lore.kernel.org/lkml/20210317142050.57712-1-chenjun102@huawei.com/

Signed-off-by: Chen Huang <chenhuang5@huawei.com>
Fixes: 5d8544e2d0 ("RISC-V: Generic library routines and assembly")
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
2021-05-22 18:59:20 -07:00
..
boot RISC-V Patches for the 5.13 Merge Window, Part 1 2021-05-06 09:24:18 -07:00
configs RISC-V: Enable Microchip PolarFire ICICLE SoC 2021-04-26 08:31:32 -07:00
errata riscv: sifive: Apply errata "cip-1200" patch 2021-04-26 08:24:58 -07:00
include riscv: Consistify protect_kernel_linear_mapping_text_rodata() use 2021-05-06 09:40:15 -07:00
kernel riscv: stacktrace: fix the riscv stacktrace when CONFIG_FRAME_POINTER enabled 2021-05-22 18:59:20 -07:00
lib riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
mm riscv: Consistify protect_kernel_linear_mapping_text_rodata() use 2021-05-06 09:40:15 -07:00
net riscv: bpf: Avoid breaking W^X 2021-04-26 08:25:14 -07:00
Kbuild riscv: Allow device trees to be built into the kernel 2020-05-18 11:38:05 -07:00
Kconfig RISC-V Patches for the 5.13 Merge Window, Part 1 2021-05-06 09:24:18 -07:00
Kconfig.debug RISC-V: Remove EARLY_PRINTK support 2018-12-17 10:23:46 -08:00
Kconfig.erratas riscv: enable SiFive errata CIP-453 and CIP-1200 Kconfig only if CONFIG_64BIT=y 2021-05-06 09:40:13 -07:00
Kconfig.socs RISC-V Patches for the 5.13 Merge Window, Part 1 2021-05-06 09:24:18 -07:00
Makefile RISC-V: enable XIP 2021-04-26 08:31:28 -07:00