Skip to content

Commit 7edc3a6

Browse files
kaihuangbonzini
authored andcommitted
KVM, x86/mmu: Fix the comment around kvm_tdp_mmu_zap_leafs()
Now kvm_tdp_mmu_zap_leafs() only zaps leaf SPTEs but not any non-root pages within that GFN range anymore, so the comment around it isn't right. Fix it by shifting the comment from tdp_mmu_zap_leafs() instead of duplicating it, as tdp_mmu_zap_leafs() is static and is only called by kvm_tdp_mmu_zap_leafs(). Opportunistically tweak the blurb about SPTEs being cleared to (a) say "zapped" instead of "cleared" because "cleared" will be wrong if/when KVM allows a non-zero value for non-present SPTE (i.e. for Intel TDX), and (b) to clarify that a flush is needed if and only if a SPTE has been zapped since MMU lock was last acquired. Fixes: f47e5bb ("KVM: x86/mmu: Zap only TDP MMU leafs in zap range and mmu_notifier unmap") Suggested-by: Sean Christopherson <seanjc@google.com> Reviewed-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Kai Huang <kai.huang@intel.com> Message-Id: <20220728030452.484261-1-kai.huang@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 6fac42f commit 7edc3a6

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,6 @@ bool kvm_tdp_mmu_zap_sp(struct kvm *kvm, struct kvm_mmu_page *sp)
924924
}
925925

926926
/*
927-
* Zap leafs SPTEs for the range of gfns, [start, end). Returns true if SPTEs
928-
* have been cleared and a TLB flush is needed before releasing the MMU lock.
929-
*
930927
* If can_yield is true, will release the MMU lock and reschedule if the
931928
* scheduler needs the CPU or there is contention on the MMU lock. If this
932929
* function cannot yield, it will not release the MMU lock or reschedule and
@@ -969,10 +966,9 @@ static bool tdp_mmu_zap_leafs(struct kvm *kvm, struct kvm_mmu_page *root,
969966
}
970967

971968
/*
972-
* Tears down the mappings for the range of gfns, [start, end), and frees the
973-
* non-root pages mapping GFNs strictly within that range. Returns true if
974-
* SPTEs have been cleared and a TLB flush is needed before releasing the
975-
* MMU lock.
969+
* Zap leaf SPTEs for the range of gfns, [start, end), for all roots. Returns
970+
* true if a TLB flush is needed before releasing the MMU lock, i.e. if one or
971+
* more SPTEs were zapped since the MMU lock was last acquired.
976972
*/
977973
bool kvm_tdp_mmu_zap_leafs(struct kvm *kvm, int as_id, gfn_t start, gfn_t end,
978974
bool can_yield, bool flush)

0 commit comments

Comments
 (0)