Re: [PATCH v6] arm64: kprobe: Enable OPTPROBE for arm64

From: Google
Date: Tue Jan 14 2025 - 01:32:49 EST


On Tue, 14 Jan 2025 11:56:38 +0800
Yicong Yang <yangyicong@xxxxxxxxxx> wrote:

> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index 62b5b08d809d..45287e185ce3 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -425,6 +425,24 @@ void opt_pre_handler(struct kprobe *p, struct pt_regs *regs)
> > }
> > NOKPROBE_SYMBOL(opt_pre_handler);
> >
> > +void optprobe_optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs)
> > +{
> > + if (kprobe_disabled(&op->kp))
> > + return;
> > +
> > + guard(preempt)();
> > +
> > + if (kprobe_running()) {
> > + kprobes_inc_nmissed_count(&op->kp);
> > + } else {
> > + __this_cpu_write(current_kprobe, &op->kp);
> > + get_kprobe_ctlblk()->kprobe_status = KPROBE_HIT_ACTIVE;
> > + opt_pre_handler(&op->kp, regs);
> > + __this_cpu_write(current_kprobe, NULL);
> > + }
> > +}
> > +NOKPROBE_SYMBOL(optprobe_optimized_callback)
> > +
>
> should we make this function arch specific rather than in the framework? it's only
> used in the arm64 code in this patch currently.

Good catch. This should be in arch/arm64 at least in this patch.
If we consolidate the optprobe callback, it should be done in
a different patch.

>
> Thanks.
>
> > /* Free optimized instructions and optimized_kprobe */
> > static void free_aggr_kprobe(struct kprobe *p)
> > {
> >
>


--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>