Skip to contentSkip to conversation

riscv: remove useless pc check in stacktrace handling

PATCH In review Clément Léger 2 participants 2 messages Aug 30, 2024 – Sep 10, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: remove useless pc check in stacktrace handling

Checking for pc to be a kernel text address at this location is useless since pc == handle_exception. Remove this check.

---
 arch/riscv/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/stacktrace.c +1 -1
index c6d5de22463f..f934c573c087 100644
@@ -72,7 +72,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
 			pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra,
 						   &frame->ra);
 			if (pc == (unsigned long)handle_exception) {
-				if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))
+				if (unlikely(!fn(arg, pc)))
 					break;
 
 				pc = ((struct pt_regs *)sp)->epc;
Signature · 1 line
2.45.2
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Clément,

Quoted 14 lines · Clément Léger

Checking for pc to be a kernel text address at this location is useless since pc == handle_exception. Remove this check.

---
  arch/riscv/kernel/stacktrace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/stacktrace.c +0 -0
index c6d5de22463f..f934c573c087 100644

arch/riscv/kernel/stacktrace.c void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, · line 78

Quoted 8 lines
arch/riscv/kernel/stacktrace.c +1 -1
@@ -72,7 +72,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
  			pc = ftrace_graph_ret_addr(current, &graph_idx, frame->ra,
  						   &frame->ra);
  			if (pc == (unsigned long)handle_exception) {
-				if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))
+				if (unlikely(!fn(arg, pc)))
  					break;
 
  				pc = ((struct pt_regs *)sp)->epc;

Thanks,

Alex