From: Sean Christopherson <seanjc@google.com>
To: Jim Mattson <jmattson@google.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, nikunj@amd.com, yosry@kernel.org
Subject: Re: [PATCH v2 4/4] KVM: selftests: Add coverage for the EFER_LMSLE_MBZ defeature
Date: Mon, 28 Sep 2026 17:41:26 -0700 [thread overview]
Message-ID: <arsJNv9HrFGMJSho@google.com> (raw)
In-Reply-To: <f0ce99261caf71e88cd0d51a4053abb77454e8bf.1790208413.git.jmattson@google.com>
On Wed, Sep 23, 2026, Jim Mattson wrote:
> + /*
> + * Per AMD APM vol. 2, if CPUID.80000008H:EBX[bit 20] is set, "64-bit
Please tell your LLM not to quote specific volumes/sections in code comments.
It's a-ok for changelogs to reference specific sections, because those are
naturally timestamped (and can even explicitly call out the APM/SDM version).
But code/comments are usually read without the context of when the code/comment
was added, i.e. are much more likely to become stale in practice.
> + /*
> + * EFER_LMSLE_MBZ, CPUID.80000008H:EBX[bit 20], is a "defeature" bit,
> + * i.e. is set when the CPU does *not* support long mode segment
> + * limits. KVM enumerates the defeature if and only if KVM refuses to
> + * set EFER.LMSLE, i.e. if the CPU doesn't support LMSLE, or if KVM
> + * doesn't support nested SVM. Derive the expectation from raw CPUID
> + * and kvm_amd's "nested" module param rather than from
> + * kvm_cpu_has(X86_FEATURE_SVM), so that the assertion doesn't simply
> + * compare KVM's enumeration to itself.
> + *
> + * Note, kvm_amd's "nested" is an "int" module param, i.e. reads back
> + * as '1'/'0' and not as 'Y'/'N'. Query the param if and only if the
> + * CPU supports SVM, i.e. if and only if kvm_amd is the module in
> + * play. Checking the vendor string wouldn't suffice, e.g. Zhaoxin
> + * and Centaur CPUs are "GenuineIntel"-adjacent at best, but run VMX
> + * and thus load kvm_intel.
Happily, that support is actually already in kvm-x86, i.e. there's now a
host_cpu_is_intel_compatible sitting in the "selftests" branch. That's mildly
annoying as I don't want to take this series through "selftests", but that's
easy enough to deal with, by deliberately touching the same code so I don't
forget to tell Paolo about a semantic-only conflict.
I also want to add a helper for "nested" so that we don't end up with similar
checks sprinkled here and there, but with a scary comment instructing developers
to use kvm_cpu_has(X86_FEATURE_{VMX,SVM}) (I want to avoid having two common ways
of doing one thing).
I'll send a v3 (assuming my code works) with this:
/*
* EFER_LMSLE_MBZ, CPUID.80000008H:EBX[bit 20], is a "defeature" bit,
* i.e. is set when the CPU does *not* support long mode segment
* limits. KVM enumerates the defeature if and only if KVM refuses to
* set EFER.LMSLE, i.e. if the CPU doesn't support LMSLE, or if KVM
* doesn't support nested SVM. Derive the expectation from raw CPUID
* and kvm_amd's "nested" module param rather than from
* kvm_cpu_has(X86_FEATURE_SVM), so that the assertion doesn't simply
* compare KVM's enumeration to itself.
*/
lmsle_mbz = this_cpu_has(X86_FEATURE_EFER_LMSLE_MBZ) ||
!this_cpu_has(X86_FEATURE_SVM) ||
!kvm_is_nested_virtualization_enabled();
prev parent reply other threads:[~2026-09-29 0:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 0:25 [PATCH v2 0/4] KVM: x86: Honor EFER_LMSLE_MBZ Jim Mattson
2026-09-24 0:25 ` [PATCH v2 1/4] KVM: x86: Advertise EFER_LMSLE_MBZ when KVM disallows EFER.LMSLE Jim Mattson
2026-09-24 0:25 ` [PATCH v2 2/4] KVM: x86: Honor the guest's EFER_LMSLE_MBZ Jim Mattson
2026-09-24 0:25 ` [PATCH v2 3/4] KVM: selftests: Rename svm_nested_clear_efer_svme to svm_nested_efer_test Jim Mattson
2026-09-24 0:25 ` [PATCH v2 4/4] KVM: selftests: Add coverage for the EFER_LMSLE_MBZ defeature Jim Mattson
2026-09-29 0:41 ` Sean Christopherson [this message]
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=arsJNv9HrFGMJSho@google.com \
--to=seanjc@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=yosry@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.