lkml.org 
[lkml]   [2023]   [Aug]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86/static_call: Fix __static_call_fixup()
On Tue, Aug 15, 2023 at 05:10:32PM -0700, Josh Poimboeuf wrote:
> On Wed, Aug 16, 2023 at 01:08:09AM +0200, Peter Zijlstra wrote:
> > bool __static_call_fixup(void *tramp, u8 op, void *dest)
> > {
> > + /*
> > + * Not all .return_sites are a static_call trampoline (most are not).
> > + * Check if the next 3 bytes are still kernel text, if not, then this
>
> s/3/7 ?

Right, so what I meant was the 3 bytes after the return, which is 5+3,
but yeah, that can be said better.

>
> > + * definitely is not a trampoline and we need not worry further.
> > + *
> > + * This avoids the memcmp() below tripping over pagefaults etc..
> > + */
> > + if (!kernel_text_address(tramp+7))
> > + return false;
> > +
> > if (memcmp(tramp+5, tramp_ud, 3)) {
> > /* Not a trampoline site, not our problem. */
> > return false;
>
> kernel_text_address() can be quite heavyweight to call in a loop during
> module loading. Maybe that doesn't matter much. But it would be a lot
> faster to only call kernel_text_address() if tramp+7 is on the next
> page.

Oh, right, in those few configs where it doesn't use the tree. Sure can
do.

\
 
 \ /
  Last update: 2023-08-16 11:41    [W:0.048 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site