Commit 5014396a authored by Clément Léger's avatar Clément Léger Committed by Palmer Dabbelt

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: default avatarClément Léger <cleger@rivosinc.com>
Reviewed-by: default avatarCharlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20231004131009.409193-1-cleger@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 7f43d57b
...@@ -183,6 +183,16 @@ ...@@ -183,6 +183,16 @@
REG_L x31, PT_T6(sp) REG_L x31, PT_T6(sp)
.endm .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 /* __ASSEMBLY__ */
#endif /* _ASM_RISCV_ASM_H */ #endif /* _ASM_RISCV_ASM_H */
...@@ -111,6 +111,7 @@ SYM_CODE_START(handle_exception) ...@@ -111,6 +111,7 @@ SYM_CODE_START(handle_exception)
1: 1:
tail do_trap_unknown tail do_trap_unknown
SYM_CODE_END(handle_exception) SYM_CODE_END(handle_exception)
ASM_NOKPROBE(handle_exception)
/* /*
* The ret_from_exception must be called with interrupt disabled. Here is the * The ret_from_exception must be called with interrupt disabled. Here is the
...@@ -184,6 +185,7 @@ SYM_CODE_START_NOALIGN(ret_from_exception) ...@@ -184,6 +185,7 @@ SYM_CODE_START_NOALIGN(ret_from_exception)
sret sret
#endif #endif
SYM_CODE_END(ret_from_exception) SYM_CODE_END(ret_from_exception)
ASM_NOKPROBE(ret_from_exception)
#ifdef CONFIG_VMAP_STACK #ifdef CONFIG_VMAP_STACK
SYM_CODE_START_LOCAL(handle_kernel_stack_overflow) SYM_CODE_START_LOCAL(handle_kernel_stack_overflow)
...@@ -219,6 +221,7 @@ SYM_CODE_START_LOCAL(handle_kernel_stack_overflow) ...@@ -219,6 +221,7 @@ SYM_CODE_START_LOCAL(handle_kernel_stack_overflow)
move a0, sp move a0, sp
tail handle_bad_stack tail handle_bad_stack
SYM_CODE_END(handle_kernel_stack_overflow) SYM_CODE_END(handle_kernel_stack_overflow)
ASM_NOKPROBE(handle_kernel_stack_overflow)
#endif #endif
SYM_CODE_START(ret_from_fork) SYM_CODE_START(ret_from_fork)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment