Re: [PATCH v1 2/4] x86/fred: Write to FRED MSRs with wrmsrns()

Peter Zijlstra
2024-07-05T09:28:25Z

On Wed, Jul 03, 2024 at 05:00:53PM +0100, Andrew Cooper wrote:

> /* Non-serialising WRMSR, when available.  Falls back to a serialising WRMSR. */
> static inline void wrmsrns(uint32_t msr, uint32_t lo, uint32_t hi)
> {
>     /*
>      * WRMSR is 2 bytes.  WRMSRNS is 3 bytes.  Pad WRMSR with a redundant CS
>      * prefix to avoid a trailing NOP.
>      */
>     alternative_input(".byte 0x2e; wrmsr",
>                       ".byte 0x0f,0x01,0xc6", X86_FEATURE_WRMSRNS,
>                       "c" (msr), "a" (lo), "d" (hi));
> }

FWIW, I favour this variant.