Re: [PATCH v2 12/39] x86/ibt,ftrace: Search for __fentry__ location

From: Naveen N. Rao
Date: Wed Mar 09 2022 - 06:48:42 EST


Peter Zijlstra wrote:
On Thu, Mar 03, 2022 at 09:34:13AM -0500, Steven Rostedt wrote:
On Thu, 3 Mar 2022 14:04:52 +0100
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> > @@ -1596,7 +1596,7 @@ static int check_ftrace_location(struct kprobe *p)
> > {
> > unsigned long ftrace_addr;
> > > > - ftrace_addr = ftrace_location((unsigned long)p->addr);
> > + ftrace_addr = ftrace_location_range((unsigned long)p->addr, (unsigned long)p->addr); > > Yes, although perhaps a new helper. I'll go ponder during lunch.

Is there more places to add that to make it worth creating a helper?

This is what I ended up with, I've looked at all ftrace_location() sites
there are, seems to work too, both the built-in boot time ftrace tests
and the selftests work splat-less.

I should update the Changelog some though.

Naveen also mentioned register_ftrace_direct() could be further cleaned
up, but I didn't want to do too much in once go.

Not a problem, I can send those as cleanups atop this series.


---

Subject: x86/ibt,ftrace: Search for __fentry__ location
From: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Wed Feb 23 10:01:38 CET 2022

Have ftrace_location() search the symbol for the __fentry__ location
when it isn't at func+0 and use this for {,un}register_ftrace_direct().

This avoids a whole bunch of assumptions about __fentry__ being at
func+0.

Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---

This version looks good to me.
Acked-by: Naveen N. Rao <naveen.n.rao@xxxxxxxxxxxxxxxxxx>


Thanks,
Naveen