lkml.org 
[lkml]   [2023]   [Aug]   [15]   [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 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 ?

> + * 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.

--
Josh

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