public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: "Jürgen Groß" <jgross@suse.com>
To: Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, virtualization@lists.linux.dev
Subject: Re: [PATCH 0/8] x86/msr: Consolidate native/paravirt MSR functions
Date: Sat, 21 Mar 2026 07:23:26 +0100	[thread overview]
Message-ID: <4c26ba32-d15f-496f-9f83-211c51a58673@suse.com> (raw)
In-Reply-To: <20260320233319.GZab3ZP1lTfxOmQ4YF@fat_crate.local>


[-- Attachment #1.1.1: Type: text/plain, Size: 2972 bytes --]

On 21.03.26 00:33, Borislav Petkov wrote:
> On Fri, Mar 20, 2026 at 12:03:30PM -0700, Dave Hansen wrote:
>> This is old cruft, but it appears that having two copies of these
>> MSR functions is enabling warnings to creep in[1].
>>
>> I know there's also been some work to pare down the XXL code, but
>> it's obviously not merged yet and this is a good baby step.
>>
>> Create helpers that both paravirt and native can use in common code
>> and remove the paravirt implementations of the helpers. This reduces
>> the amount of logic that is duplicated in the paravirt code.
>>
>> The other thing I really like about this is that it puts the
>> raw=>{native,paravirt} switch in one compact place in the code.
>>
>> Conceptually:
>>   -   native: The bare-metal implementation. Might not be usable under
>> 	     paravirt XXL.
>>   -      raw: The lowest-level function that is always usable. Might
>> 	     be native or paravirt under the hood.
> 
> I went through the patchset twice and I kinda get what you're trying to do but
> the "raw" thing is confusing as hell.
> 
> To me "raw" means, the lowest level of the functionality - something like
> __<function_name> with the two underscores. Or three, depending on the
> indirection levels.
> 
> And those do *only* *raw* instructions - no more indirections.
> 
> But then how can "raw" be the lowest level and then still have something else
> underneath - native_ and paravirt_?
> 
> I *think* this is only a naming issue and with "raw_" you probably wanna say
> "native_or_paravirt_" depending on the ifdeffery... but shorter...
> 
> If so, I wouldn't call it "raw". I'd say
> 
> xx_read_msr()
> xx_write_msr()
> 
> to denote that the "xx" resolves to either of the two types. But a better
> name. I can't think of a good one now but I know that "raw" isn't it...
> 
> Hmmm.
> 

I'd like to suggest to do a major cleanup of the MSR interfaces. We have too
many of them doing similar things. Some are capable to do tracing, some aren't.
Some are paravirt capable, some aren't. And the names of those functions don't
reflect that at all. We even have multiple functions or macros doing exactly
the same thing, but having different names.

And in future it will be even more complicated due to the write MSR interfaces
needing serializing and non-serializing variants.

My idea would be to have something like:

msr_read()
msr_read_notrace()
msr_write_sync()
msr_write_nosync()
msr_write_sync_notrace()
msr_write_nosync_notrace()

All of those should be paravirt capable and they should be the only "official"
interfaces. They will depend on low-level primitives, but those should be used
only by the official access functions and maybe in some very special places.

I think this should be the first step towards a MSR access consolidation, as
it allows any internal optimizations and changes without further bothering most
of the users.


Juergen

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

  parent reply	other threads:[~2026-03-21  6:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-20 19:03 [PATCH 0/8] x86/msr: Consolidate native/paravirt MSR functions Dave Hansen
2026-03-20 19:03 ` [PATCH 1/8] x86/msr: Use "raw_" names for calls to native_* functions Dave Hansen
2026-03-20 19:03 ` [PATCH 2/8] x86/msr: Consolidate rdmsr() definitions Dave Hansen
2026-03-20 19:03 ` [PATCH 3/8] x86/msr: Consolidate rdmsr_safe() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 4/8] x86/msr: Consolidate rdmsrq() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 5/8] x86/msr: Consolidate {rd,wr}msr[q]_safe() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 6/8] x86/msr: Consolidate rdpmc() implementations Dave Hansen
2026-03-20 19:03 ` [PATCH 7/8] x86/msr: Remove old crusty comment Dave Hansen
2026-03-20 19:03 ` [PATCH 8/8] x86/msr: Remove duplicate #include Dave Hansen
2026-03-20 23:33 ` [PATCH 0/8] x86/msr: Consolidate native/paravirt MSR functions Borislav Petkov
2026-03-20 23:39   ` Dave Hansen
2026-03-21  6:23   ` Jürgen Groß [this message]
2026-03-23 15:22     ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4c26ba32-d15f-496f-9f83-211c51a58673@suse.com \
    --to=jgross@suse.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=virtualization@lists.linux.dev \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox