Skip to content

Commit daa5b6c

Browse files
Ben Gardonbonzini
authored andcommitted
kvm: x86/mmu: Don't clear write flooding count for direct roots
Direct roots don't have a write flooding count because the guest can't affect that paging structure. Thus there's no need to clear the write flooding count on a fast CR3 switch for direct roots. Tested by running kvm-unit-tests and KVM selftests on an Intel Haswell machine. This series introduced no new failures. This series can be viewed in Gerrit at: https://linux-review.googlesource.com/c/virt/kvm/kvm/+/2538 Signed-off-by: Ben Gardon <bgardon@google.com> Message-Id: <20201014182700.2888246-20-bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 95fb5b0 commit daa5b6c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

arch/x86/kvm/mmu/mmu.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3892,7 +3892,13 @@ static void __kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd,
38923892
*/
38933893
vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY);
38943894

3895-
__clear_sp_write_flooding_count(to_shadow_page(vcpu->arch.mmu->root_hpa));
3895+
/*
3896+
* If this is a direct root page, it doesn't have a write flooding
3897+
* count. Otherwise, clear the write flooding count.
3898+
*/
3899+
if (!new_role.direct)
3900+
__clear_sp_write_flooding_count(
3901+
to_shadow_page(vcpu->arch.mmu->root_hpa));
38963902
}
38973903

38983904
void kvm_mmu_new_pgd(struct kvm_vcpu *vcpu, gpa_t new_pgd, bool skip_tlb_flush,

0 commit comments

Comments
 (0)