[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZVmKjfQD1zKMDOD-Zc4pVp+EGgb8h2veg=bXe1Pjn_Uw@mail.gmail.com>
Date: Thu, 27 Jun 2024 09:51:35 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Tiezhu Yang <yangtiezhu@...ngson.cn>, Jiri Olsa <jolsa@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>, Masami Hiramatsu <mhiramat@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>, Nathan Chancellor <nathan@...nel.org>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, bpf@...r.kernel.org,
Huacai Chen <chenhuacai@...nel.org>, WANG Xuerui <kernel@...0n.name>, loongarch@...ts.linux.dev
Subject: Re: [PATCH] LoongArch: uprobes: make UPROBE_SWBP_INSN/UPROBE_XOLBP_INSN
constant
On Thu, Jun 27, 2024 at 9:04 AM Oleg Nesterov <oleg@...hat.com> 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@...nel.org>
> Closes: https://lore.kernel.org/all/20240614174822.GA1185149@thelio-3990X/
> Suggested-by: Andrii Nakryiko <andrii@...nel.org>
> Signed-off-by: Oleg Nesterov <oleg@...hat.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@...nel.org>
> 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)
> 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
>
>
Powered by blists - more mailing lists