Skip to content

Commit 94f50cc

Browse files
sean-jcgregkh
authored andcommitted
KVM: x86/mmu: Rename pte_list_{destroy,remove}() to show they zap SPTEs
[ Upstream commit 9202aee ] Rename pte_list_remove() and pte_list_destroy() to kvm_zap_one_rmap_spte() and kvm_zap_all_rmap_sptes() respectively to document that (a) they zap SPTEs and (b) to better document how they differ (remove vs. destroy does not exactly scream "one vs. all"). No functional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20220715224226.3749507-7-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Stable-dep-of: 2abd528 ("KVM: x86: Check for invalid/obsolete root *after* making MMU pages available") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kenta Akagi <k@mgml.me> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fde1c38 commit 94f50cc

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,16 @@ static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head)
999999
}
10001000
}
10011001

1002-
static void pte_list_remove(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
1003-
u64 *sptep)
1002+
static void kvm_zap_one_rmap_spte(struct kvm *kvm,
1003+
struct kvm_rmap_head *rmap_head, u64 *sptep)
10041004
{
10051005
mmu_spte_clear_track_bits(kvm, sptep);
10061006
__pte_list_remove(sptep, rmap_head);
10071007
}
10081008

1009-
/* Return true if rmap existed, false otherwise */
1010-
static bool pte_list_destroy(struct kvm *kvm, struct kvm_rmap_head *rmap_head)
1009+
/* Return true if at least one SPTE was zapped, false otherwise */
1010+
static bool kvm_zap_all_rmap_sptes(struct kvm *kvm,
1011+
struct kvm_rmap_head *rmap_head)
10111012
{
10121013
struct pte_list_desc *desc, *next;
10131014
int i;
@@ -1434,7 +1435,7 @@ static bool rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn)
14341435
static bool kvm_zap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
14351436
const struct kvm_memory_slot *slot)
14361437
{
1437-
return pte_list_destroy(kvm, rmap_head);
1438+
return kvm_zap_all_rmap_sptes(kvm, rmap_head);
14381439
}
14391440

14401441
static bool kvm_unmap_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
@@ -1465,7 +1466,7 @@ static bool kvm_set_pte_rmapp(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
14651466
need_flush = 1;
14661467

14671468
if (pte_write(pte)) {
1468-
pte_list_remove(kvm, rmap_head, sptep);
1469+
kvm_zap_one_rmap_spte(kvm, rmap_head, sptep);
14691470
goto restart;
14701471
} else {
14711472
new_spte = kvm_mmu_changed_pte_notifier_make_spte(
@@ -1639,7 +1640,7 @@ static void rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
16391640
rmap_count = pte_list_add(vcpu, spte, rmap_head);
16401641

16411642
if (rmap_count > RMAP_RECYCLE_THRESHOLD) {
1642-
pte_list_destroy(vcpu->kvm, rmap_head);
1643+
kvm_zap_all_rmap_sptes(vcpu->kvm, rmap_head);
16431644
kvm_flush_remote_tlbs_with_address(
16441645
vcpu->kvm, sp->gfn, KVM_PAGES_PER_HPAGE(sp->role.level));
16451646
}
@@ -5873,7 +5874,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
58735874
!kvm_is_reserved_pfn(pfn) &&
58745875
sp->role.level < kvm_mmu_max_mapping_level(kvm, slot, sp->gfn,
58755876
pfn, PG_LEVEL_NUM)) {
5876-
pte_list_remove(kvm, rmap_head, sptep);
5877+
kvm_zap_one_rmap_spte(kvm, rmap_head, sptep);
58775878

58785879
if (kvm_available_flush_tlb_with_range())
58795880
kvm_flush_remote_tlbs_with_address(kvm, sp->gfn,

0 commit comments

Comments
 (0)