Thread (21 messages) 21 messages, 7 authors, 2024-07-01

Re: [PATCH] LoongArch: uprobes: make UPROBE_SWBP_INSN/UPROBE_XOLBP_INSN constant

From: Andrii Nakryiko <hidden>
Date: 2024-06-27 16:51:48
Also in: bpf, lkml, loongarch

On Thu, Jun 27, 2024 at 9:04 AM Oleg Nesterov [off-list ref] wrote:
LoongArch defines UPROBE_SWBP_INSN as a function call and this breaks
arch_uprobe_trampoline() which uses it to initialize a static variable.

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/ (local)
Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 arch/loongarch/include/asm/uprobes.h | 6 ++++--
 arch/loongarch/kernel/uprobes.c      | 8 ++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
LGTM.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

quoted hunk ↗ jump to hunk
diff --git a/arch/loongarch/include/asm/uprobes.h b/arch/loongarch/include/asm/uprobes.h
index c8f59983f702..18221eb9a8b0 100644
--- a/arch/loongarch/include/asm/uprobes.h
+++ b/arch/loongarch/include/asm/uprobes.h
@@ -6,13 +6,15 @@

 typedef u32 uprobe_opcode_t;

+#define __emit_break(imm)      (uprobe_opcode_t)((imm) | (break_op << 15))
+
 #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)
this looks correct (but based on pure code inspection)
quoted hunk ↗ jump to hunk
 struct arch_uprobe {
        unsigned long   resume_era;
diff --git a/arch/loongarch/kernel/uprobes.c b/arch/loongarch/kernel/uprobes.c
index 87abc7137b73..90462d94c28f 100644
--- a/arch/loongarch/kernel/uprobes.c
+++ b/arch/loongarch/kernel/uprobes.c
@@ -7,6 +7,14 @@

 #define UPROBE_TRAP_NR UINT_MAX

+static __init int check_emit_break(void)
+{
+       BUG_ON(UPROBE_SWBP_INSN  != larch_insn_gen_break(BRK_UPROBE_BP));
+       BUG_ON(UPROBE_XOLBP_INSN != larch_insn_gen_break(BRK_UPROBE_XOLBP));
+       return 0;
+}
+arch_initcall(check_emit_break);
+
I wouldn't even bother with this, but whatever.
 int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe,
                             struct mm_struct *mm, unsigned long addr)
 {
--
2.25.1.362.g51ebf55
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help