]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: x86: Advertise support for LKGS
authorXin Li <xin@zytor.com>
Thu, 26 Jun 2025 17:35:21 +0000 (10:35 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 9 Jul 2025 16:32:25 +0000 (09:32 -0700)
Advertise support for LKGS (load into IA32_KERNEL_GS_BASE) to userspace
if the instruction is supported by the underlying CPU.

LKGS is introduced with FRED to completely eliminate the need to swapgs
explicilty.  It behaves like the MOV to GS instruction except that it
loads the base address into the IA32_KERNEL_GS_BASE MSR instead of the
GS segment’s descriptor cache, which is exactly what Linux kernel does
to load a user level GS base.  Thus there is no need to SWAPGS away
from the kernel GS base.

LKGS is an independent CPU feature that works correctly in a KVM guest
without requiring explicit enablement.

Signed-off-by: Xin Li (Intel) <xin@zytor.com>
Link: https://lore.kernel.org/r/20250626173521.2301088-1-xin@zytor.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/cpuid.c

index b2d006756e02a68362e3ab32c2fc7cc187dbbeea..bf4a43bd0a47bbb43016b98f3246d57ba9ba1748 100644 (file)
@@ -979,6 +979,7 @@ void kvm_set_cpu_caps(void)
                F(FSRS),
                F(FSRC),
                F(WRMSRNS),
+               X86_64_F(LKGS),
                F(AMX_FP16),
                F(AVX_IFMA),
                F(LAM),