]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: x86: Advertise EferLmsleUnsupported to userspace
authorJim Mattson <jmattson@google.com>
Wed, 1 Oct 2025 00:14:07 +0000 (17:14 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 14 Oct 2025 22:49:10 +0000 (15:49 -0700)
commit4793f990ea1523309a58d8fb5237b3a815e6f537
treeb868bf38fcd7b3c49a6eb2c55ee573a7ba89878d
parent7c8b465a1c91f674655ea9cec5083744ec5f796a
KVM: x86: Advertise EferLmsleUnsupported to userspace

CPUID.80000008H:EBX.EferLmsleUnsupported[bit 20] is a defeature
bit. When this bit is clear, EFER.LMSLE is supported. When this bit is
set, EFER.LMLSE is unsupported. KVM has never _emulated_ EFER.LMSLE, so
KVM cannot truly support a 0-setting of this bit.

However, KVM has allowed the guest to enable EFER.LMSLE in hardware
since commit eec4b140c924 ("KVM: SVM: Allow EFER.LMSLE to be set with
nested svm"), i.e. KVM partially virtualizes long-mode segment limits _if_
they are supported by the underlying hardware.

Pass through the bit in KVM_GET_SUPPORTED_CPUID to advertise the
unavailability of EFER.LMSLE to userspace based on the raw underlying
hardware.  Attempting to enable EFER.LSMLE on such CPUs simply doesn't
work, e.g. immediately crashes on VMRUN.

Signed-off-by: Jim Mattson <jmattson@google.com>
Reviewed-by: Nikunj A Dadhania <nikunj@amd.com>
Reviewed-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://lore.kernel.org/r/20251001001529.1119031-2-jmattson@google.com
[sean: add context about partial virtualization, use PASSTHROUGH_F]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/include/asm/cpufeatures.h
arch/x86/kvm/cpuid.c