public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: synthesize TSA CPUID bits via SCATTERED_F()
@ 2026-02-08 16:42 Carlos López
  2026-02-08 18:28 ` Borislav Petkov
  2026-02-09 10:02 ` Binbin Wu
  0 siblings, 2 replies; 19+ messages in thread
From: Carlos López @ 2026-02-08 16:42 UTC (permalink / raw)
  To: seanjc, bp, kvm
  Cc: Carlos López, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Dave Hansen, maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT),
	H. Peter Anvin, open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)

KVM incorrectly synthesizes TSA_SQ_NO and TSA_L1_NO when running
on AMD Family 19h CPUs by using SYNTHESIZED_F(), which unconditionally
enables features for KVM-only CPUID leaves (as is the case with
CPUID_8000_0021_ECX), regardless of the kernel's synthesis logic in
tsa_init(). This is due to the following logic in kvm_cpu_cap_init():

    if (leaf < NCAPINTS)
        kvm_cpu_caps[leaf] &= kernel_cpu_caps[leaf];

This can cause an unexpected failure on Family 19h CPUs during SEV-SNP
guest setup, when userspace issues SNP_LAUNCH_UPDATE, as setting these
bits in the CPUID page on vulnerable CPUs is explicitly rejected by SNP
firmware.

Switch to SCATTERED_F(), so that the bits are only set if the features
have been force-set by the kernel in tsa_init(), or if they are reported
in the raw CPUID.

Fixes: 31272abd5974 ("KVM: SVM: Advertise TSA CPUID bits to guests")
Signed-off-by: Carlos López <clopez@suse.de>
---
 arch/x86/kvm/cpuid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 88a5426674a1..819c176e02ff 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1230,8 +1230,8 @@ void kvm_set_cpu_caps(void)
 	);
 
 	kvm_cpu_cap_init(CPUID_8000_0021_ECX,
-		SYNTHESIZED_F(TSA_SQ_NO),
-		SYNTHESIZED_F(TSA_L1_NO),
+		SCATTERED_F(TSA_SQ_NO),
+		SCATTERED_F(TSA_L1_NO),
 	);
 
 	kvm_cpu_cap_init(CPUID_8000_0022_EAX,

base-commit: 0de4a0eec25b9171f2a2abb1a820e125e6797770
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2026-02-11 16:28 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08 16:42 [PATCH] KVM: x86: synthesize TSA CPUID bits via SCATTERED_F() Carlos López
2026-02-08 18:28 ` Borislav Petkov
2026-02-08 20:50   ` Jim Mattson
2026-02-08 21:13     ` Borislav Petkov
2026-02-09  5:48       ` Jim Mattson
2026-02-09 11:40         ` Carlos López
2026-02-09 15:06           ` Sean Christopherson
2026-02-09 15:32             ` Borislav Petkov
2026-02-09 16:29               ` Sean Christopherson
2026-02-09 17:45                 ` Borislav Petkov
2026-02-09 21:12                   ` Sean Christopherson
2026-02-10 20:07                     ` Borislav Petkov
2026-02-10 23:48                       ` Sean Christopherson
2026-02-11 13:32                         ` Borislav Petkov
2026-02-11 15:54                           ` Sean Christopherson
2026-02-11 16:17                             ` Borislav Petkov
2026-02-11 16:28                               ` Sean Christopherson
2026-02-09 10:02 ` Binbin Wu
2026-02-09 11:43   ` Carlos López

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox