[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<LV3PR12MB92650FB81DEA468D566CC2CE94A0A@LV3PR12MB9265.namprd12.prod.outlook.com>
Date: Wed, 10 Dec 2025 21:39:54 +0000
From: "Kaplan, David" <David.Kaplan@....com>
To: Borislav Petkov <bp@...en8.de>
CC: Peter Zijlstra <peterz@...radead.org>, Josh Poimboeuf
<jpoimboe@...nel.org>, Jason Baron <jbaron@...mai.com>, Steven Rostedt
<rostedt@...dmis.org>, Ard Biesheuvel <ardb@...nel.org>, Thomas Gleixner
<tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Dave Hansen
<dave.hansen@...ux.intel.com>, "x86@...nel.org" <x86@...nel.org>, "H. Peter
Anvin" <hpa@...or.com>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] x86/static_call: Remove text_mutex from
__static_call_fixup()
[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Borislav Petkov <bp@...en8.de>
> Sent: Wednesday, December 10, 2025 1:55 PM
> To: Kaplan, David <David.Kaplan@....com>
> Cc: Peter Zijlstra <peterz@...radead.org>; Josh Poimboeuf
> <jpoimboe@...nel.org>; Jason Baron <jbaron@...mai.com>; Steven Rostedt
> <rostedt@...dmis.org>; Ard Biesheuvel <ardb@...nel.org>; Thomas Gleixner
> <tglx@...utronix.de>; Ingo Molnar <mingo@...hat.com>; Dave Hansen
> <dave.hansen@...ux.intel.com>; x86@...nel.org; H. Peter Anvin
> <hpa@...or.com>; linux-kernel@...r.kernel.org
> Subject: Re: [PATCH] x86/static_call: Remove text_mutex from
> __static_call_fixup()
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hey,
>
> On Thu, Nov 06, 2025 at 11:53:20AM -0600, David Kaplan wrote:
> > __static_call_fixup() is only called from apply_returns() which modifies
> > text either on boot when only one CPU is active, or on module load. In
> > both cases, it does not modify live code. This is why this function passes
> > 'true' for the modinit argument to __static_call_transform() which causes
> > __static_call_transform() to use text_poke_early().
> >
> > text_poke_early() does not require that the text_mutex is held, as this
> > function is only used when free of any races with other CPUs. Therefore
> > __static_call_fixup() does not need to take the mutex so remove it.
> >
> > Signed-off-by: David Kaplan <david.kaplan@....com>
> > ---
> > arch/x86/kernel/static_call.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/arch/x86/kernel/static_call.c b/arch/x86/kernel/static_call.c
> > index 378c388d1b31..748fc98d416f 100644
> > --- a/arch/x86/kernel/static_call.c
> > +++ b/arch/x86/kernel/static_call.c
> > @@ -212,10 +212,8 @@ bool __static_call_fixup(void *tramp, u8 op, void
> *dest)
> > return false;
> > }
> >
> > - mutex_lock(&text_mutex);
> > if (op == RET_INSN_OPCODE || dest == &__x86_return_thunk)
> > __static_call_transform(tramp, RET, NULL, true);
> > - mutex_unlock(&text_mutex);
> >
> > return true;
> > }
> >
>
> can you please elaborate here what the actual problem was?
>
> I know it had to do with dynamic mitigations, I guess something about
> lockdep complaining... can you paste the splat here?
>
Yeah, the full splat can be found in https://lore.kernel.org/lkml/d255d8a9-8e45-485e-9853-80c343bbb73b@suse.com/
The problem was that patching under dynamic mitigations is done under NMI context, so it complained about taking a mutex in NMI context.
Thing is, dynamic mitigation patching happens with all CPUs stopped and synchronized at a safe point. This allows for using text_poke_early(), as we do during boot. This particular code path also always ends up at text_poke_early(), which does not require the text_mutex being held. So taking it seems unnecessary (unless I've missed something in my analysis).
--David Kaplan
Powered by blists - more mailing lists