On 06/29/2024 11:03 PM, Oleg Nesterov wrote:
LoongArch defines UPROBE_SWBP_INSN as a function call and this breaks arch_uprobe_trampoline() which uses it to initialize a static variable. Add the new "__builtin_constant_p" helper, __emit_break(), and redefine the current users of larch_insn_gen_break() to use it. The patch adds check_emit_break() into kprobes.c and uprobes.c to test this change. They can be removed if LoongArch boots at least once, but otoh these 2 __init functions will be discarded by free_initmem(). Fixes: ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe") Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx> Closes: https://lore.kernel.org/all/20240614174822.GA1185149@thelio-3990X/ Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx> Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Tested on LoongArch machine with Loongson-3A5000 and Loongson-3A6000 CPU, based on 6.10-rc3, KPROBE_BP_INSN == larch_insn_gen_break(BRK_KPROBE_BP) KPROBE_SSTEPBP_INSN == larch_insn_gen_break(BRK_KPROBE_SSTEPBP) UPROBE_SWBP_INSN == larch_insn_gen_break(BRK_UPROBE_BP) UPROBE_XOLBP_INSN == larch_insn_gen_break(BRK_UPROBE_XOLBP) The two functions check_emit_break() can be removed in arch/loongarch/kernel/kprobes.c and arch/loongarch/kernel/uprobes.c Tested-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> Thanks, Tiezhu