Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86: Disable support for Shadow Stacks if TDP is disabled

Make TDP a hard requirement for Shadow Stacks, as there are no plans to
add Shadow Stack support to the Shadow MMU. E.g. KVM hasn't been taught
to understand the magic Writable=0,Dirty=1 combination that is required
for Shadow Stack accesses, and so enabling Shadow Stacks when using
shadow paging will put the guest into an infinite #PF loop (KVM thinks the
shadow page tables have a valid mapping, hardware says otherwise).

Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20250919223258.1604852-27-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

+8
+8
arch/x86/kvm/cpuid.c
··· 955 955 if (!tdp_enabled || !boot_cpu_has(X86_FEATURE_OSPKE)) 956 956 kvm_cpu_cap_clear(X86_FEATURE_PKU); 957 957 958 + /* 959 + * Shadow Stacks aren't implemented in the Shadow MMU. Shadow Stack 960 + * accesses require "magic" Writable=0,Dirty=1 protection, which KVM 961 + * doesn't know how to emulate or map. 962 + */ 963 + if (!tdp_enabled) 964 + kvm_cpu_cap_clear(X86_FEATURE_SHSTK); 965 + 958 966 kvm_cpu_cap_init(CPUID_7_EDX, 959 967 F(AVX512_4VNNIW), 960 968 F(AVX512_4FMAPS),