Skip to content

Commit 770d6aa

Browse files
committed
KVM: SVM: Explicitly require FLUSHBYASID to enable SEV support
Add a sanity check that FLUSHBYASID is available if SEV is supported in hardware, as SEV (and beyond) guests are bound to a single ASID, i.e. KVM can't "flush" by assigning a new, fresh ASID to the guest. If FLUSHBYASID isn't supported for some bizarre reason, KVM would completely fail to do TLB flushes for SEV+ guests (see pre_svm_run() and pre_sev_run()). Cc: Tom Lendacky <thomas.lendacky@amd.com> Link: https://lore.kernel.org/r/20231018193617.1895752-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 176bfc5 commit 770d6aa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,10 +2191,13 @@ void __init sev_hardware_setup(void)
21912191
/*
21922192
* SEV must obviously be supported in hardware. Sanity check that the
21932193
* CPU supports decode assists, which is mandatory for SEV guests to
2194-
* support instruction emulation.
2194+
* support instruction emulation. Ditto for flushing by ASID, as SEV
2195+
* guests are bound to a single ASID, i.e. KVM can't rotate to a new
2196+
* ASID to effect a TLB flush.
21952197
*/
21962198
if (!boot_cpu_has(X86_FEATURE_SEV) ||
2197-
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)))
2199+
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)) ||
2200+
WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_FLUSHBYASID)))
21982201
goto out;
21992202

22002203
/* Retrieve SEV CPUID information */

0 commit comments

Comments
 (0)