[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240229013924.cksuxebpylyeymzo@desk>
Date: Wed, 28 Feb 2024 17:39:24 -0800
From: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
To: Jiri Slaby <jirislaby@...nel.org>
Cc: Nikolay Borisov <nik.borisov@...e.com>,
Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
Daniel Sneddon <daniel.sneddon@...ux.intel.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/bugs: Use fixed addressing for VERW operand
On Tue, Feb 27, 2024 at 10:43:53AM +0100, Jiri Slaby wrote:
> On 27. 02. 24, 9:47, Nikolay Borisov wrote:
> >
> >
> > On 27.02.24 г. 1:52 ч., Pawan Gupta wrote:
> > > Macro used for MDS mitigation executes VERW with relative addressing for
> > > the operand. This is unnecessary and creates a problem for backports on
> > > older kernels that don't support relocations in alternatives. Relocation
> > > support was added by commit 270a69c4485d ("x86/alternative: Support
> > > relocations in alternatives"). Also asm for fixed addressing is much
> > > more cleaner than relative RIP addressing.
> > >
> > > Simplify the asm by using fixed addressing for VERW operand.
> > >
> > > Fixes: baf8361e5455 ("x86/bugs: Add asm helpers for executing VERW")
> > > Reported-by: Nikolay Borisov <nik.borisov@...e.com>
> > > Closes: https://lore.kernel.org/lkml/20558f89-299b-472e-9a96-171403a83bd6@suse.com/
> > > Signed-off-by: Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>
> > > ---
> > > arch/x86/include/asm/nospec-branch.h | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/include/asm/nospec-branch.h
> > > b/arch/x86/include/asm/nospec-branch.h
> > > index 2aa52cab1e46..ab19c7f1167b 100644
> > > --- a/arch/x86/include/asm/nospec-branch.h
> > > +++ b/arch/x86/include/asm/nospec-branch.h
> > > @@ -323,7 +323,7 @@
> > > * Note: Only the memory operand variant of VERW clears the CPU
> > > buffers.
> > > */
> > > .macro CLEAR_CPU_BUFFERS
> > > - ALTERNATIVE "", __stringify(verw _ASM_RIP(mds_verw_sel)),
> > > X86_FEATURE_CLEAR_CPU_BUF
> > > + ALTERNATIVE "", __stringify(verw mds_verw_sel),
> > > X86_FEATURE_CLEAR_CPU_BUF
> >
> > Actually thinking about it more and discussing with Jiri (cc'ed), will
> > this work with KASLR enabled?
>
> I might of course be wrong. We appear to rely on the asm+linker here.
You were right, with KASLR enabled, instructions with fixed addressing
in alternatives don't get relocated. I guess we will have to keep
rip-relative as is. Thanks for catching that.
Powered by blists - more mailing lists