diff options
author | Clément Léger <cleger@rivosinc.com> | 2023-10-04 15:10:09 +0200 |
---|---|---|
committer | Palmer Dabbelt <palmer@rivosinc.com> | 2024-01-24 15:59:42 -0800 |
commit | 5014396af9bbac0f28d9afee7eae405206d01ee7 (patch) | |
tree | d140198837a2056ff266ae5598715a24a284b7c2 /arch/riscv/include/asm/asm.h | |
parent | 7f43d57b900d7e221a73204239b74d4001193599 (diff) | |
download | lwn-5014396af9bbac0f28d9afee7eae405206d01ee7.tar.gz lwn-5014396af9bbac0f28d9afee7eae405206d01ee7.zip |
riscv: blacklist assembly symbols for kprobe
Adding kprobes on some assembly functions (mainly exception handling)
will result in crashes (either recursive trap or panic). To avoid such
errors, add ASM_NOKPROBE() macro which allow adding specific symbols
into the __kprobe_blacklist section and use to blacklist the following
symbols that showed to be problematic:
- handle_exception()
- ret_from_exception()
- handle_kernel_stack_overflow()
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20231004131009.409193-1-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/include/asm/asm.h')
-rw-r--r-- | arch/riscv/include/asm/asm.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h index b0487b39e674..776354895b81 100644 --- a/arch/riscv/include/asm/asm.h +++ b/arch/riscv/include/asm/asm.h @@ -183,6 +183,16 @@ REG_L x31, PT_T6(sp) .endm +/* Annotate a function as being unsuitable for kprobes. */ +#ifdef CONFIG_KPROBES +#define ASM_NOKPROBE(name) \ + .pushsection "_kprobe_blacklist", "aw"; \ + RISCV_PTR name; \ + .popsection +#else +#define ASM_NOKPROBE(name) +#endif + #endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_ASM_H */ |