[PATCH] riscv: remove useless pc check in stacktrace handling

Clément Léger posted 1 patch 1 year, 5 months ago
arch/riscv/kernel/stacktrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] riscv: remove useless pc check in stacktrace handling
Posted by Clément Léger 1 year, 5 months ago
Checking for pc to be a kernel text address at this location is useless
since pc == handle_exception. Remove this check.

Signed-off-by: Clément Léger <cleger@rivosinc.com>

---
 arch/riscv/kernel/stacktrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index c6d5de22463f..f934c573c087 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -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;
-- 
2.45.2

Re: [PATCH] riscv: remove useless pc check in stacktrace handling
Posted by Alexandre Ghiti 1 year, 5 months ago
Hi Clément,

On 30/08/2024 10:49, Clément Léger wrote:
> Checking for pc to be a kernel text address at this location is useless
> since pc == handle_exception. Remove this check.
>
> Signed-off-by: Clément Léger <cleger@rivosinc.com>
>
> ---
>   arch/riscv/kernel/stacktrace.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
> index c6d5de22463f..f934c573c087 100644
> --- a/arch/riscv/kernel/stacktrace.c
> +++ b/arch/riscv/kernel/stacktrace.c
> @@ -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;


Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex