Re: [PATCH v3 09/16] x86/msr: Use the alternatives mechanism for WRMSR

From: Jürgen Groß

Date: Thu Feb 19 2026 - 01:41:50 EST


On 19.02.26 00:36, H. Peter Anvin wrote:
On February 18, 2026 1:37:42 PM PST, Dave Hansen <dave.hansen@xxxxxxxxx> wrote:
On 2/18/26 13:00, Sean Christopherson wrote:
On Wed, Feb 18, 2026, 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().
Silently using a non-serializing version (or not) seems dangerous (not for KVM,
but for the kernel at-large), unless the rule is going to be that MSR writes need
to be treated as non-serializing by default.

Yeah, there's no way we can do this in general. It'll work for 99% of
the MSRs on 99% of the systems for a long time. Then the one new system
with WRMSRNS is going to have one hell of a heisenbug that'll take years
off some poor schmuck's life.

We should really encourage *new* code to use wrmsrns() when it can at
least for annotation that it doesn't need serialization. But I don't
think we should do anything to old, working code.

Correct. We need to do this on a user by user basis.

Then I'd prefer to introduce a new wrmsr_sync() function for the serializing
variant and to switch all current users which are not known to tolerate the
non-serializing form to it. The main advantage of that approach would be to
be able to use the immediate form where possible automatically.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature