linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uprobe: Do not use UPROBE_SWBP_INSN as static initializer
@ 2024-06-18 19:43 Jiri Olsa
  2024-06-20 19:00 ` Andrii Nakryiko
  2024-06-27 16:02 ` [PATCH] LoongArch: uprobes: make UPROBE_SWBP_INSN/UPROBE_XOLBP_INSN constant Oleg Nesterov
  0 siblings, 2 replies; 21+ messages in thread
From: Jiri Olsa @ 2024-06-18 19:43 UTC (permalink / raw)
  To: Steven Rostedt, Masami Hiramatsu, Andrii Nakryiko
  Cc: Oleg Nesterov, Nathan Chancellor, linux-kernel,
	linux-trace-kernel, bpf

Nathan reported compilation fail for loongarch arch:

  kernel/events/uprobes.c: In function 'arch_uprobe_trampoline':
  arch/loongarch/include/asm/uprobes.h:12:33: error: initializer element is not constant
     12 | #define UPROBE_SWBP_INSN        larch_insn_gen_break(BRK_UPROBE_BP)
        |                                 ^~~~~~~~~~~~~~~~~~~~
  kernel/events/uprobes.c:1479:39: note: in expansion of macro 'UPROBE_SWBP_INSN'
   1479 |         static uprobe_opcode_t insn = UPROBE_SWBP_INSN;

Loongarch defines UPROBE_SWBP_INSN as function call, so we can't
use it to initialize static variable.

Cc: Oleg Nesterov <oleg@redhat.com>
Fixes: ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 kernel/events/uprobes.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 2816e65729ac..6986bd993702 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1476,8 +1476,9 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area)
 
 void * __weak arch_uprobe_trampoline(unsigned long *psize)
 {
-	static uprobe_opcode_t insn = UPROBE_SWBP_INSN;
+	static uprobe_opcode_t insn;
 
+	insn = insn ?: UPROBE_SWBP_INSN;
 	*psize = UPROBE_SWBP_INSN_SIZE;
 	return &insn;
 }
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-07-01 15:01 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-18 19:43 [PATCH] uprobe: Do not use UPROBE_SWBP_INSN as static initializer Jiri Olsa
2024-06-20 19:00 ` Andrii Nakryiko
2024-06-20 19:38   ` Oleg Nesterov
2024-06-20 21:30     ` Andrii Nakryiko
2024-06-21 12:01       ` Oleg Nesterov
2024-06-21 13:17         ` Jiri Olsa
2024-06-27 13:44           ` Jiri Olsa
2024-06-27 14:20             ` Masami Hiramatsu
2024-06-27 15:29               ` Oleg Nesterov
2024-06-27 16:02 ` [PATCH] LoongArch: uprobes: make UPROBE_SWBP_INSN/UPROBE_XOLBP_INSN constant Oleg Nesterov
2024-06-27 16:51   ` Andrii Nakryiko
2024-06-27 17:38     ` Oleg Nesterov
2024-06-28  4:30       ` Masami Hiramatsu
2024-06-29 12:48       ` Tiezhu Yang
2024-06-29 13:38         ` Oleg Nesterov
2024-06-29 13:48           ` Huacai Chen
2024-06-29 15:03             ` [PATCH] LoongArch: make the users of larch_insn_gen_break() constant Oleg Nesterov
2024-06-30  1:43               ` Huacai Chen
2024-06-30  6:29                 ` Oleg Nesterov
2024-07-01  6:22               ` Tiezhu Yang
2024-07-01 15:01                 ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).