]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
LoongArch: Make the users of larch_insn_gen_break() constant
authorOleg Nesterov <oleg@redhat.com>
Sat, 20 Jul 2024 14:41:07 +0000 (22:41 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 20 Jul 2024 14:41:07 +0000 (22:41 +0800)
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.

Fixes: ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/all/20240614174822.GA1185149@thelio-3990X/
Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/inst.h
arch/loongarch/include/asm/uprobes.h
arch/loongarch/kernel/kprobes.c

index c3993fd88abaab16a52c18e90c280ca33b28ec5a..944482063f14e32f57fbd9aa82488bb7418a6617 100644 (file)
@@ -532,6 +532,9 @@ static inline void emit_##NAME(union loongarch_instruction *insn,   \
 
 DEF_EMIT_REG0I15_FORMAT(break, break_op)
 
+/* like emit_break(imm) but returns a constant expression */
+#define __emit_break(imm)      ((u32)((imm) | (break_op << 15)))
+
 #define DEF_EMIT_REG0I26_FORMAT(NAME, OP)                              \
 static inline void emit_##NAME(union loongarch_instruction *insn,      \
                               int offset)                              \
index c8f59983f702dfaca208c25047d591b434bacf58..99a0d198927f8b8494ebf6e096985612602390e2 100644 (file)
@@ -9,10 +9,10 @@ typedef u32 uprobe_opcode_t;
 #define MAX_UINSN_BYTES                8
 #define UPROBE_XOL_SLOT_BYTES  MAX_UINSN_BYTES
 
-#define UPROBE_SWBP_INSN       larch_insn_gen_break(BRK_UPROBE_BP)
+#define UPROBE_SWBP_INSN       __emit_break(BRK_UPROBE_BP)
 #define UPROBE_SWBP_INSN_SIZE  LOONGARCH_INSN_SIZE
 
-#define UPROBE_XOLBP_INSN      larch_insn_gen_break(BRK_UPROBE_XOLBP)
+#define UPROBE_XOLBP_INSN      __emit_break(BRK_UPROBE_XOLBP)
 
 struct arch_uprobe {
        unsigned long   resume_era;
index 17b040bd6067c511fd1ae879aad6edc8c71696ff..8ba391cfabb00d5e5b94be644d1210c7d4d00aef 100644 (file)
@@ -4,8 +4,8 @@
 #include <linux/preempt.h>
 #include <asm/break.h>
 
-#define KPROBE_BP_INSN         larch_insn_gen_break(BRK_KPROBE_BP)
-#define KPROBE_SSTEPBP_INSN    larch_insn_gen_break(BRK_KPROBE_SSTEPBP)
+#define KPROBE_BP_INSN         __emit_break(BRK_KPROBE_BP)
+#define KPROBE_SSTEPBP_INSN    __emit_break(BRK_KPROBE_SSTEPBP)
 
 DEFINE_PER_CPU(struct kprobe *, current_kprobe);
 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);