[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1 3/3] x86/msr: Convert a native_wrmsr() use to native_wrmsrq()


  • To: Ingo Molnar <mingo@xxxxxxxxxx>
  • From: Xin Li <xin@xxxxxxxxx>
  • Date: Fri, 16 May 2025 21:42:42 -0700
  • Autocrypt: addr=xin@xxxxxxxxx; keydata= xsDNBGUPz1cBDACS/9yOJGojBFPxFt0OfTWuMl0uSgpwk37uRrFPTTLw4BaxhlFL0bjs6q+0 2OfG34R+a0ZCuj5c9vggUMoOLdDyA7yPVAJU0OX6lqpg6z/kyQg3t4jvajG6aCgwSDx5Kzg5 Rj3AXl8k2wb0jdqRB4RvaOPFiHNGgXCs5Pkux/qr0laeFIpzMKMootGa4kfURgPhRzUaM1vy bsMsL8vpJtGUmitrSqe5dVNBH00whLtPFM7IbzKURPUOkRRiusFAsw0a1ztCgoFczq6VfAVu raTye0L/VXwZd+aGi401V2tLsAHxxckRi9p3mc0jExPc60joK+aZPy6amwSCy5kAJ/AboYtY VmKIGKx1yx8POy6m+1lZ8C0q9b8eJ8kWPAR78PgT37FQWKYS1uAroG2wLdK7FiIEpPhCD+zH wlslo2ETbdKjrLIPNehQCOWrT32k8vFNEMLP5G/mmjfNj5sEf3IOKgMTMVl9AFjsINLHcxEQ 6T8nGbX/n3msP6A36FDfdSEAEQEAAc0WWGluIExpIDx4aW5Aenl0b3IuY29tPsLBDQQTAQgA NxYhBIUq/WFSDTiOvUIqv2u9DlcdrjdRBQJlD89XBQkFo5qAAhsDBAsJCAcFFQgJCgsFFgID AQAACgkQa70OVx2uN1HUpgv/cM2fsFCQodLArMTX5nt9yqAWgA5t1srri6EgS8W3F+3Kitge tYTBKu6j5BXuXaX3vyfCm+zajDJN77JHuYnpcKKr13VcZi1Swv6Jx1u0II8DOmoDYLb1Q2ZW v83W55fOWJ2g72x/UjVJBQ0sVjAngazU3ckc0TeNQlkcpSVGa/qBIHLfZraWtdrNAQT4A1fa sWGuJrChBFhtK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l0dvUuevwMgQF3IljLmi/6APKYJHjkJpu1E6luZec/lRbetHuNFtbh3xgFIJx 2RpgVDP4xB3f8r0I+y6ua+p7fgOjDLyoFjubRGed0Be45JJQEn7A3CSb6Xu7NYobnxfkwAGZ Q81a2XtvNS7Aj6NWVoOQB5KbM4yosO5+Me1V1SkX2jlnn26JPEvbV3KRFcwV5RnDxm4OQTSk PYbAkjBbm+tuJ/Sm+5Yp5T/BnKz21FoCS8uvTiziHj2H7Cuekn6F8EYhegONm+RVg3vikOpn gao85i4HwQTK9/D1wgJIQkdwWXVMZ6q/OALaBp82vQ2U9sjTyFXgDjglgh00VRAHP7u1Rcu4 l75w1xInsg==
  • Cc: linux-kernel@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, tglx@xxxxxxxxxxxxx, bp@xxxxxxxxx, dave.hansen@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx, hpa@xxxxxxxxx, peterz@xxxxxxxxxxxxx, jgross@xxxxxxxx, boris.ostrovsky@xxxxxxxxxx, rafael@xxxxxxxxxx, lenb@xxxxxxxxxx
  • Delivery-date: Sat, 17 May 2025 04:43:42 +0000
  • Dkim-filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54H4ggxL509076
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 5/15/2025 10:54 AM, Xin Li wrote:
On 5/15/2025 8:27 AM, Ingo Molnar wrote:

* Xin Li (Intel) <xin@xxxxxxxxx> 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








 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.