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

H. Peter Anvin
2024-07-05T11:34:31Z

On July 5, 2024 2:28:05 AM PDT, Peter Zijlstra <peterz@infradead.org> wrote:
>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.

We normally use DS as the padding prefix.