From: Sean Christopherson <seanjc@google.com>
To: Alexandre Chartre <alexandre.chartre@oracle.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
pbonzini@redhat.com, xiaoyao.li@intel.com, x86@kernel.org,
konrad.wilk@oracle.com, boris.ostrovsky@oracle.com,
Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH] kvm/x86: ARCH_CAPABILITIES should not be advertised on AMD
Date: Thu, 26 Jun 2025 07:02:00 -0700 [thread overview]
Message-ID: <aF1S2EIJWN47zLDG@google.com> (raw)
In-Reply-To: <20250626125720.3132623-1-alexandre.chartre@oracle.com>
+Jim
For the scope, "KVM: x86:"
On Thu, Jun 26, 2025, Alexandre Chartre wrote:
> KVM emulates the ARCH_CAPABILITIES on x86 for both vmx and svm.
> However the IA32_ARCH_CAPABILITIES MSR is an Intel-specific MSR
> so it makes no sense to emulate it on AMD.
>
> The AMD documentation specifies that this MSR is not defined on
> the AMD architecture. So emulating this MSR on AMD can even cause
> issues (like Windows BSOD) as the guest OS might not expect this
> MSR to exist on such architecture.
>
> Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
> ---
>
> A similar patch was submitted some years ago but it looks like it felt
> through the cracks:
> https://lore.kernel.org/kvm/20190307093143.77182-1-xiaoyao.li@linux.intel.com/
It didn't fall through the cracks, we deliberately elected to emulate the MSR in
common code so that KVM's advertised CPUID support would match KVM's emulation.
On Thu, 2019-03-07 at 19:15 +0100, Paolo Bonzini wrote:
> On 07/03/19 18:37, Sean Christopherson wrote:
> > On Thu, Mar 07, 2019 at 05:31:43PM +0800, Xiaoyao Li wrote:
> > > At present, we report F(ARCH_CAPABILITIES) for x86 arch(both vmx and svm)
> > > unconditionally, but we only emulate this MSR in vmx. It will cause #GP
> > > while guest kernel rdmsr(MSR_IA32_ARCH_CAPABILITIES) in an AMD host.
> > >
> > > Since MSR IA32_ARCH_CAPABILITIES is an intel-specific MSR, it makes no
> > > sense to emulate it in svm. Thus this patch chooses to only emulate it
> > > for vmx, and moves the related handling to vmx related files.
> >
> > What about emulating the MSR on an AMD host for testing purpsoes? It
> > might be a useful way for someone without Intel hardware to test spectre
> > related flows.
> >
> > In other words, an alternative to restricting emulation of the MSR to
> > Intel CPUS would be to move MSR_IA32_ARCH_CAPABILITIES handling into
> > kvm_{get,set}_msr_common(). Guest access to MSR_IA32_ARCH_CAPABILITIES
> > is gated by X86_FEATURE_ARCH_CAPABILITIES in the guest's CPUID, e.g.
> > RDMSR will naturally #GP fault if userspace passes through the host's
> > CPUID on a non-Intel system.
>
> This is also better because it wouldn't change the guest ABI for AMD
> processors. Dropping CPUID flags is generally not a good idea.
>
> Paolo
I don't necessarily disagree about emulating ARCH_CAPABILITIES being pointless,
but Paolo's point about not changing ABI for existing setups still stands. This
has been KVM's behavior for 6 years (since commit 0cf9135b773b ("KVM: x86: Emulate
MSR_IA32_ARCH_CAPABILITIES on AMD hosts"); 7 years, if we go back to when KVM
enumerated support without emulating the MSR (commit 1eaafe91a0df ("kvm: x86:
IA32_ARCH_CAPABILITIES is always supported").
And it's not like KVM is forcing userspace to enumerate support for
ARCH_CAPABILITIES, e.g. QEMU's named AMD configs don't enumerate support. So
while I completely agree KVM's behavior is odd and annoying for userspace to deal
with, this is probably something that should be addressed in userspace.
> I am resurecting this change because some recent Windows updates (like OS Build
> 26100.4351) crashes on AMD KVM guests (BSOD with Stop code: UNSUPPORTED PROCESSOR)
> just because the ARCH_CAPABILITIES is available.
>
> ---
> arch/x86/kvm/svm/svm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index ab9b947dbf4f..600d2029156e 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -5469,6 +5469,9 @@ static __init void svm_set_cpu_caps(void)
>
> /* Don't advertise Bus Lock Detect to guest if SVM support is absent */
> kvm_cpu_cap_clear(X86_FEATURE_BUS_LOCK_DETECT);
> +
> + /* Don't advertise ARCH_CAPABILITIES on AMD */
> + kvm_cpu_cap_clear(X86_FEATURE_ARCH_CAPABILITIES);
Strictly speaking, I think we'd want to update svm_has_emulated_msr() as well.
> }
>
> static __init int svm_hardware_setup(void)
> --
> 2.43.5
>
next prev parent reply other threads:[~2025-06-26 14:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 12:57 Alexandre Chartre
2025-06-26 14:02 ` Sean Christopherson [this message]
2025-06-26 15:31 ` Konrad Rzeszutek Wilk
2025-06-26 15:44 ` Sean Christopherson
2025-06-26 16:08 ` Jim Mattson
2025-06-26 19:22 ` Alexandre Chartre
2025-06-27 5:41 ` Xiaoyao Li
2025-06-27 6:23 ` Alexandre Chartre
2025-06-27 20:57 ` Konrad Rzeszutek Wilk
2025-07-07 20:25 ` Sean Christopherson
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=aF1S2EIJWN47zLDG@google.com \
--to=seanjc@google.com \
--cc=alexandre.chartre@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jmattson@google.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
/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
all inboxes | Powered by JetHome®