[v6,12/13] riscv/kprobe: Move exception related symbols to .kprobe_blacklist
Commit Message
From: Liao Chang <liaochang1@huawei.com>
Due to the generic exception entry and exit code is part of the critical
path for kprobe breakpoint and uprobe syscall entry, set a kprobe on the
assembly symbols in entry.S result in kernel stack overflow crash, hence
it has to explicitly blacklist it, requiring a new _ASM_NOKPROBE() asm
helper.
Signed-off-by: Liao Chang <liaochang1@huawei.com>
---
arch/riscv/include/asm/asm.h | 10 ++++++++++
arch/riscv/kernel/entry.S | 12 ++++++++++++
arch/riscv/kernel/mcount.S | 1 +
3 files changed, 23 insertions(+)
Comments
Chen Guokai <chenguokai17@mails.ucas.ac.cn> writes:
> From: Liao Chang <liaochang1@huawei.com>
>
> Due to the generic exception entry and exit code is part of the critical
> path for kprobe breakpoint and uprobe syscall entry, set a kprobe on the
> assembly symbols in entry.S result in kernel stack overflow crash, hence
> it has to explicitly blacklist it, requiring a new _ASM_NOKPROBE() asm
> helper.
>
> Signed-off-by: Liao Chang <liaochang1@huawei.com>
Reviewed-by: Björn Töpel <bjorn@kernel.org>
@@ -81,6 +81,16 @@
.endr
.endm
+#ifdef CONFIG_KPROBES
+#define _ASM_NOKPROBE(entry) \
+ .pushsection "_kprobe_blacklist", "aw" ; \
+ .balign SZREG ; \
+ REG_ASM entry ; \
+ .popsection
+#else
+#define _ASM_NOKPROBE(entry)
+#endif
+
#endif /* __ASSEMBLY__ */
#endif /* _ASM_RISCV_ASM_H */
@@ -606,3 +606,15 @@ ENTRY(__user_rt_sigreturn)
scall
END(__user_rt_sigreturn)
#endif
+
+_ASM_NOKPROBE(handle_exception)
+_ASM_NOKPROBE(_restore_kernel_tpsp)
+_ASM_NOKPROBE(_save_context)
+_ASM_NOKPROBE(ret_from_exception)
+_ASM_NOKPROBE(ret_from_syscall)
+_ASM_NOKPROBE(__switch_to)
+_ASM_NOKPROBE(ret_from_syscall_rejected)
+_ASM_NOKPROBE(restore_all)
+_ASM_NOKPROBE(resume_kernel)
+_ASM_NOKPROBE(resume_userspace)
+_ASM_NOKPROBE(check_syscall_nr)
@@ -54,6 +54,7 @@ ENTRY(ftrace_stub)
#endif
ret
ENDPROC(ftrace_stub)
+_ASM_NOKPROBE(MCOUNT_NAME)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
ENTRY(return_to_handler)