On Tue, Aug 19, 2025 at 09:15:15PM +0200, Peter Zijlstra wrote:
> On Sun, Jul 20, 2025 at 01:21:20PM +0200, Jiri Olsa wrote:
> 
> > +static bool __is_optimized(uprobe_opcode_t *insn, unsigned long vaddr)
> > +{
> > +   struct __packed __arch_relative_insn {
> > +           u8 op;
> > +           s32 raddr;
> > +   } *call = (struct __arch_relative_insn *) insn;
> 
> Not something you need to clean up now I suppose, but we could do with
> unifying this thing. we have a bunch of instances around.

found two below, maybe we could use 'union text_poke_insn' instead like below?

jirka


---
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6079d15dab8c..7fd03897d776 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -109,14 +109,10 @@ const int kretprobe_blacklist_size = 
ARRAY_SIZE(kretprobe_blacklist);
 static nokprobe_inline void
 __synthesize_relative_insn(void *dest, void *from, void *to, u8 op)
 {
-       struct __arch_relative_insn {
-               u8 op;
-               s32 raddr;
-       } __packed *insn;
-
-       insn = (struct __arch_relative_insn *)dest;
-       insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
-       insn->op = op;
+       union text_poke_insn *insn = dest;
+
+       insn->disp = (s32)((long)(to) - ((long)(from) + 5));
+       insn->opcode = op;
 }
 
 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 0a8c0a4a5423..bac14f3165c3 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -1046,14 +1046,11 @@ static int copy_from_vaddr(struct mm_struct *mm, 
unsigned long vaddr, void *dst,
 
 static bool __is_optimized(uprobe_opcode_t *insn, unsigned long vaddr)
 {
-       struct __packed __arch_relative_insn {
-               u8 op;
-               s32 raddr;
-       } *call = (struct __arch_relative_insn *) insn;
+       union text_poke_insn *call = (union text_poke_insn *) insn;
 
        if (!is_call_insn(insn))
                return false;
-       return __in_uprobe_trampoline(vaddr + 5 + call->raddr);
+       return __in_uprobe_trampoline(vaddr + 5 + call->disp);
 }
 
 static int is_optimized(struct mm_struct *mm, unsigned long vaddr)

Reply via email to