Skip to content

Commit 44aaa01

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Disable MMIO caching if MMIO value collides with L1TF
Disable MMIO caching if the MMIO value collides with the L1TF mitigation that usurps high PFN bits. In practice this should never happen as only CPUs with SME support can generate such a collision (because the MMIO value can theoretically get adjusted into legal memory), and no CPUs exist that support SME and are susceptible to L1TF. But, closing the hole is trivial. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210225204749.1512652-5-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent ec89e64 commit 44aaa01

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎arch/x86/kvm/mmu/spte.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,19 @@ u64 mark_spte_for_access_track(u64 spte)
245245
void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 access_mask)
246246
{
247247
BUG_ON((u64)(unsigned)access_mask != access_mask);
248-
WARN_ON(mmio_value & (shadow_nonpresent_or_rsvd_mask << SHADOW_NONPRESENT_OR_RSVD_MASK_LEN));
249248
WARN_ON(mmio_value & shadow_nonpresent_or_rsvd_lower_gfn_mask);
249+
250+
/*
251+
* Disable MMIO caching if the MMIO value collides with the bits that
252+
* are used to hold the relocated GFN when the L1TF mitigation is
253+
* enabled. This should never fire as there is no known hardware that
254+
* can trigger this condition, e.g. SME/SEV CPUs that require a custom
255+
* MMIO value are not susceptible to L1TF.
256+
*/
257+
if (WARN_ON(mmio_value & (shadow_nonpresent_or_rsvd_mask <<
258+
SHADOW_NONPRESENT_OR_RSVD_MASK_LEN)))
259+
mmio_value = 0;
260+
250261
shadow_mmio_value = mmio_value | SPTE_MMIO_MASK;
251262
shadow_mmio_access_mask = access_mask;
252263
}

0 commit comments

Comments
 (0)