Re: [PATCH] powerpc/ftrace: Ignore ftrace locations in exit text sections
From: Michael Ellerman <mpe@ellerman.id.au>
Date: 2024-02-13 01:52:42
Christophe Leroy [off-list ref] writes:
Le 09/02/2024 à 08:59, Naveen N Rao a écrit :quoted
Michael reported that we are seeing ftrace bug on bootup when KASAN is enabled, and if we are using -fpatchable-function-entry:
...
quoted
diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h index ea26665f82cf..d389dcecdb0b 100644 --- a/arch/powerpc/include/asm/sections.h +++ b/arch/powerpc/include/asm/sections.h@@ -14,6 +14,7 @@ typedef struct func_desc func_desc_t; extern char __head_end[]; extern char __srwx_boundary[]; +extern char _sexittext[], _eexittext[];Should we try to at least use the same symbols as others, or best try to move this into include/asm-generic/sections.h, just like inittext ? $ git grep exittext arch/arm64/include/asm/sections.h:extern char __exittext_begin[], __exittext_end[]; arch/arm64/kernel/patching.c: addr >= (unsigned long)__exittext_begin && arch/arm64/kernel/patching.c: addr < (unsigned long)__exittext_end; arch/arm64/kernel/vmlinux.lds.S: __exittext_begin = .; arch/arm64/kernel/vmlinux.lds.S: __exittext_end = .; arch/riscv/include/asm/sections.h:extern char __exittext_begin[], __exittext_end[]; arch/riscv/kernel/patch.c:static inline bool is_kernel_exittext(uintptr_t addr) arch/riscv/kernel/patch.c: addr >= (uintptr_t)__exittext_begin && arch/riscv/kernel/patch.c: addr < (uintptr_t)__exittext_end; arch/riscv/kernel/patch.c: if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) arch/riscv/kernel/vmlinux-xip.lds.S: __exittext_begin = .; arch/riscv/kernel/vmlinux-xip.lds.S: __exittext_end = .; arch/riscv/kernel/vmlinux.lds.S: __exittext_begin = .; arch/riscv/kernel/vmlinux.lds.S: __exittext_end = .;
I'll change it to use __exittext_begin/end.
quoted
diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 82010629cf88..b5efd8d7bc01 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c@@ -27,10 +27,22 @@ #include <asm/ftrace.h> #include <asm/syscall.h> #include <asm/inst.h> +#include <asm/sections.h> #define NUM_FTRACE_TRAMPS 2 static unsigned long ftrace_tramps[NUM_FTRACE_TRAMPS]; +unsigned long ftrace_call_adjust(unsigned long addr) +{ + if (addr >= (unsigned long)_sexittext && addr < (unsigned long)_eexittext) + return 0;Then arm64 has a function called is_exit_text() and riscv has is_kernel_exittext(). Can we refactor ?
I'd like to get the fix in and backported, so I'll take it as-is but with the section names changed to match the other arches. We can do further refactoring on top. cheers