public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Xin Li <xin@zytor.com>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org,
	linux-acpi@vger.kernel.org, tglx@linutronix.de, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	peterz@infradead.org, jgross@suse.com,
	boris.ostrovsky@oracle.com, rafael@kernel.org, lenb@kernel.org
Subject: Re: [PATCH v1 3/3] x86/msr: Convert a native_wrmsr() use to native_wrmsrq()
Date: Fri, 16 May 2025 21:42:42 -0700	[thread overview]
Message-ID: <b8f741d6-47a1-4cc8-a5b2-45ee86fcb773@zytor.com> (raw)
In-Reply-To: <68dba45c-a677-4f6d-b7ec-e896aef3d27b@zytor.com>

On 5/15/2025 10:54 AM, Xin Li wrote:
> On 5/15/2025 8:27 AM, Ingo Molnar wrote:
>>
>> * Xin Li (Intel) <xin@zytor.com> wrote:
>>
>>> Convert a native_wrmsr() use to native_wrmsrq() to zap meaningless type
>>> conversions when a u64 MSR value is splitted into two u32.
>>>
>>
>> BTW., at this point we should probably just replace
>> sev_es_wr_ghcb_msr() calls with direct calls to:
>>
>>     native_wrmsrq(MSR_AMD64_SEV_ES_GHCB, ...);
>>
>> as sev_es_wr_ghcb_msr() is now basically an open-coded native_wrmsrq().
>>
> 
> I thought about it, however it looks to me that current code prefers not
> to spread MSR_AMD64_SEV_ES_GHCB in 17 callsites.  And anyway it's a 
> __always_inline function.
> 
> But as you have asked, I will make the change unless someone objects.

Hi Ingo,

I took a further look and found that we can't simply replace
sev_es_wr_ghcb_msr() with native_wrmsrq(MSR_AMD64_SEV_ES_GHCB, ...).

There are two sev_es_wr_ghcb_msr() definitions.  One is defined in
arch/x86/boot/compressed/sev.h and it references boot_wrmsr() defined in
arch/x86/boot/msr.h to do MSR write.

The other one is defined in arch/x86/include/asm/sev-internal.h, which
uses native_wrmsrq() from arch/x86/include/asm/msr.h to write MSR.

Because:
1) arch/x86/boot/startup/sev-shared.c is included in both
         arch/x86/boot/compressed/sev.c
    and
         arch/x86/boot/startup/sev-startup.c

2) arch/x86/boot/startup/sev-shared.c has several references to
    sev_es_wr_ghcb_msr(),

sev_es_wr_ghcb_msr() is converted to boot_wrmsr() when included in
arch/x86/boot/compressed/sev.c or native_wrmsrq() when included in
arch/x86/boot/startup/sev-startup.c.

It would change the compressed code to use native_wrmsrq() if we remove
sev_es_wr_ghcb_msr() from arch/x86/include/asm/sev-internal.h and use 
native_wrmsrq() directly in the startup code.

We probably should get rid of boot_wrmsr() and use native_wrmsrq() in
the compressed code because they are indeed the same thing.  But as we
are so close to the v6.16 merge window, I don't think it's a good idea
to make the change right now.

So maybe I should just drop this patch and we can do the job after the 
coming merge window.

But if you think it's not a bad idea to replace native_wrmsr() with
native_wrmsrq() right now, I can keep this original patch.

Thanks!
     Xin






  reply	other threads:[~2025-05-17  4:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12  8:45 [PATCH v1 0/3] MSR fixes and cleanups after last round of MSR cleanups Xin Li (Intel)
2025-05-12  8:45 ` [PATCH v1 1/3] x86/msr: Remove a superfluous inclusion of <asm/asm.h> Xin Li (Intel)
2025-05-12  8:45 ` [PATCH v1 2/3] x86/xen/msr: Fix uninitialized symbol 'err' Xin Li (Intel)
2025-05-15 15:29   ` Ingo Molnar
2025-05-15 18:11     ` Xin Li
2025-05-16 13:19       ` Ingo Molnar
2025-05-16 13:42       ` Jürgen Groß
2025-05-17 16:23         ` Xin Li
2025-05-17 16:57         ` [PATCH v1A " Xin Li (Intel)
2025-05-17 18:51           ` Jürgen Groß
2025-05-12  8:45 ` [PATCH v1 3/3] x86/msr: Convert a native_wrmsr() use to native_wrmsrq() Xin Li (Intel)
2025-05-15 15:27   ` Ingo Molnar
2025-05-15 17:54     ` Xin Li
2025-05-17  4:42       ` Xin Li [this message]
2025-05-17  7:12         ` Ingo Molnar
2025-05-17  7:26           ` Xin Li
2025-05-17 13:21             ` Ingo Molnar
2025-05-17 16:25               ` Xin Li
2025-05-19 17:05   ` Xin Li

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=b8f741d6-47a1-4cc8-a5b2-45ee86fcb773@zytor.com \
    --to=xin@zytor.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.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