kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: AMD's IBPB is not equivalent to Intel's IBPB
@ 2024-04-11 20:58 Jim Mattson
  2024-04-12  1:32 ` Venkatesh Srinivas
  0 siblings, 1 reply; 8+ messages in thread
From: Jim Mattson @ 2024-04-11 20:58 UTC (permalink / raw)
  To: kvm, Sean Christopherson, Paolo Bonzini; +Cc: Jim Mattson

From Intel's documention [1], "CPUID.(EAX=07H,ECX=0):EDX[26]
enumerates support for indirect branch restricted speculation (IBRS)
and the indirect branch predictor barrier (IBPB)." Further, from [2],
"Software that executed before the IBPB command cannot control the
predicted targets of indirect branches (4) executed after the command
on the same logical processor," where footnote 4 reads, "Note that
indirect branches include near call indirect, near jump indirect and
near return instructions. Because it includes near returns, it follows
that **RSB entries created before an IBPB command cannot control the
predicted targets of returns executed after the command on the same
logical processor.**" [emphasis mine]

On the other hand, AMD's "IBPB may not prevent return branch
predictions from being specified by pre-IBPB branch targets" [3].

Since Linux sets the synthetic feature bit, X86_FEATURE_IBPB, on AMD
CPUs that implement the weaker version of IBPB, it is incorrect to
infer from this and X86_FEATURE_IBRS that the CPU supports the
stronger version of IBPB indicated by CPUID.(EAX=07H,ECX=0):EDX[26].

Stop making this inference.

[1] https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/cpuid-enumeration-and-architectural-msrs.html
[2] https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/speculative-execution-side-channel-mitigations.html#Footnotes
[3] https://www.amd.com/en/resources/product-security/bulletin/amd-sb-1040.html

Fixes: 0c54914d0c52 ("KVM: x86: use Intel speculation bugs and features as derived in generic x86 code")
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/cpuid.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index bfc0bfcb2bc6..66f2761b2836 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -677,8 +677,6 @@ void kvm_set_cpu_caps(void)
 	kvm_cpu_cap_set(X86_FEATURE_TSC_ADJUST);
 	kvm_cpu_cap_set(X86_FEATURE_ARCH_CAPABILITIES);
 
-	if (boot_cpu_has(X86_FEATURE_IBPB) && boot_cpu_has(X86_FEATURE_IBRS))
-		kvm_cpu_cap_set(X86_FEATURE_SPEC_CTRL);
 	if (boot_cpu_has(X86_FEATURE_STIBP))
 		kvm_cpu_cap_set(X86_FEATURE_INTEL_STIBP);
 	if (boot_cpu_has(X86_FEATURE_AMD_SSBD))
-- 
2.44.0.683.g7961c838ac-goog


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

end of thread, other threads:[~2024-08-16 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-11 20:58 [PATCH] KVM: x86: AMD's IBPB is not equivalent to Intel's IBPB Jim Mattson
2024-04-12  1:32 ` Venkatesh Srinivas
2024-04-12  2:57   ` Jim Mattson
2024-05-07 20:32     ` Jim Mattson
2024-05-08 15:42       ` Sean Christopherson
2024-08-16 14:25     ` Sean Christopherson
2024-08-16 17:12       ` Jim Mattson
2024-08-16 21:26         ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).