[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aNv-kJbDXYJpievg@google.com>
Date: Tue, 30 Sep 2025 09:00:16 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Juergen Gross <jgross@...e.com>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org, llvm@...ts.linux.dev,
xin@...or.com, "H. Peter Anvin" <hpa@...or.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <nick.desaulniers+lkml@...il.com>, Bill Wendling <morbo@...gle.com>,
Justin Stitt <justinstitt@...gle.com>
Subject: Re: [PATCH v2 09/12] x86/msr: Use the alternatives mechanism for WRMSR
On Tue, Sep 30, 2025, Juergen Gross wrote:
> When available use one of the non-serializing WRMSR variants (WRMSRNS
> with or without an immediate operand specifying the MSR register) in
> __wrmsrq().
>
> For the safe/unsafe variants make __wrmsrq() to be a common base
> function instead of duplicating the ALTERNATIVE*() macros. This
> requires to let native_wrmsr() use native_wrmsrq() instead of
> __wrmsrq(). While changing this, convert native_wrmsr() into an inline
> function.
>
> Replace the only call of wsrmsrns() with the now equivalent call to
> native_wrmsrq() and remove wsrmsrns().
>
> The paravirt case will be handled later.
...
> @@ -268,21 +357,6 @@ static inline int wrmsrq_safe(u32 msr, u64 val)
> return err;
> }
>
> -/* Instruction opcode for WRMSRNS supported in binutils >= 2.40 */
> -#define ASM_WRMSRNS _ASM_BYTES(0x0f,0x01,0xc6)
> -
> -/* Non-serializing WRMSR, when available. Falls back to a serializing WRMSR. */
> -static __always_inline void wrmsrns(u32 msr, u64 val)
FYI, a use of wrmsrns() is likely coming in through the KVM (x86) tree, commit
65391feb042b ("KVM: VMX: Add host MSR read/write helpers to consolidate preemption
handling").
Probably makes sense to spin v3 after the merge window? Or on linux-next? (I
can't tell what was used as the base, and I double-checked that the above commit
is in linux-next).
> -{
> - /*
> - * WRMSR is 2 bytes. WRMSRNS is 3 bytes. Pad WRMSR with a redundant
> - * DS prefix to avoid a trailing NOP.
> - */
> - asm volatile("1: " ALTERNATIVE("ds wrmsr", ASM_WRMSRNS, X86_FEATURE_WRMSRNS)
> - "2: " _ASM_EXTABLE_TYPE(1b, 2b, EX_TYPE_WRMSR)
> - : : "c" (msr), "a" ((u32)val), "d" ((u32)(val >> 32)));
> -}
> -
> static inline void wrmsr(u32 msr, u32 low, u32 high)
> {
> wrmsrq(msr, (u64)high << 32 | low);
> --
> 2.51.0
>
Powered by blists - more mailing lists