Patch "riscv: stacktrace: fix backtracing through exceptions" has been added to the 6.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    riscv: stacktrace: fix backtracing through exceptions

to the 6.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     riscv-stacktrace-fix-backtracing-through-exceptions.patch
and it can be found in the queue-6.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 30a733b518991665d0ae271755d7c3f18115bcce
Author: Clément Léger <cleger@xxxxxxxxxxxx>
Date:   Mon Dec 9 16:57:12 2024 +0100

    riscv: stacktrace: fix backtracing through exceptions
    
    [ Upstream commit 51356ce60e5915a6bd812873186ed54e45c2699d ]
    
    Prior to commit 5d5fc33ce58e ("riscv: Improve exception and system call
    latency"), backtrace through exception worked since ra was filled with
    ret_from_exception symbol address and the stacktrace code checked 'pc' to
    be equal to that symbol. Now that handle_exception uses regular 'call'
    instructions, this isn't working anymore and backtrace stops at
    handle_exception(). Since there are multiple call site to C code in the
    exception handling path, rather than checking multiple potential return
    addresses, add a new symbol at the end of exception handling and check pc
    to be in that range.
    
    Fixes: 5d5fc33ce58e ("riscv: Improve exception and system call latency")
    Signed-off-by: Clément Léger <cleger@xxxxxxxxxxxx>
    Tested-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx>
    Reviewed-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20241209155714.1239665-1-cleger@xxxxxxxxxxxx
    Signed-off-by: Palmer Dabbelt <palmer@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/riscv/kernel/entry.S b/arch/riscv/kernel/entry.S
index c200d329d4bd..7a6c48e6d211 100644
--- a/arch/riscv/kernel/entry.S
+++ b/arch/riscv/kernel/entry.S
@@ -278,6 +278,7 @@ SYM_CODE_START_NOALIGN(ret_from_exception)
 #else
 	sret
 #endif
+SYM_INNER_LABEL(ret_from_exception_end, SYM_L_GLOBAL)
 SYM_CODE_END(ret_from_exception)
 ASM_NOKPROBE(ret_from_exception)
 
diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 153a2db4c5fa..d4355c770c36 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -17,6 +17,7 @@
 #ifdef CONFIG_FRAME_POINTER
 
 extern asmlinkage void handle_exception(void);
+extern unsigned long ret_from_exception_end;
 
 static inline int fp_is_valid(unsigned long fp, unsigned long sp)
 {
@@ -71,7 +72,8 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 			fp = frame->fp;
 			pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra,
 						   &frame->ra);
-			if (pc == (unsigned long)handle_exception) {
+			if (pc >= (unsigned long)handle_exception &&
+			    pc < (unsigned long)&ret_from_exception_end) {
 				if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))
 					break;
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux