[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AD99CE51-62B3-494D-9107-7C9093126138@zytor.com>
Date: Wed, 03 Jul 2024 09:06:55 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Andrew Cooper <andrew.cooper3@...rix.com>, Borislav Petkov <bp@...en8.de>,
dave.hansen@...el.com
CC: xin@...or.com, linux-kernel@...r.kernel.org, tglx@...utronix.de,
mingo@...hat.com, dave.hansen@...ux.intel.com, x86@...nel.org,
peterz@...radead.org, nik.borisov@...e.com,
houwenlong.hwl@...group.com
Subject: Re: [PATCH v1 2/4] x86/fred: Write to FRED MSRs with wrmsrns()
On July 3, 2024 9:00:53 AM PDT, Andrew Cooper <andrew.cooper3@...rix.com> wrote:
>On 03/07/2024 4:54 pm, Borislav Petkov wrote:
>> Dave Hansen <dave.hansen@...el.com> wrote:
>>> On 7/3/24 01:54, Xin Li (Intel) wrote:
>>> > Do FRED MSR writes with wrmsrns() rather than wrmsrl().
>>>
>>> A longer changelog would be appreciated here. The wrmsrns() is
>>> presumably to avoid the WRMSR serialization overhead and the CR4 write
>>> provides all of the serialization that we need.
>> Also, all those wrmsrns() writes better be behind a CPUID check.
>
>They're not, in Linux.
>
>For the $N'th time, here is the primitive that Linux wants to stea^w
>borrow for this to be sane.
>
>/* 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));
>}
>
>~Andrew
I believe tglx declared to use them unconditionally since FRED depends on WRMSRNS (and the kernel enforces that.)
Using an alternative would make wrmsrns() a more useful construct in general, though.
Powered by blists - more mailing lists