提交 9202aee8 编写于 作者: S Sean Christopherson 提交者: Paolo Bonzini

KVM: x86/mmu: Rename pte_list_{destroy,remove}() to show they zap SPTEs

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: NSean Christopherson <seanjc@google.com>
Message-Id: <20220715224226.3749507-7-seanjc@google.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 f8480721
...@@ -957,15 +957,16 @@ static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head) ...@@ -957,15 +957,16 @@ static void __pte_list_remove(u64 *spte, struct kvm_rmap_head *rmap_head)
} }
} }
static void pte_list_remove(struct kvm *kvm, struct kvm_rmap_head *rmap_head, static void kvm_zap_one_rmap_spte(struct kvm *kvm,
u64 *sptep) struct kvm_rmap_head *rmap_head, u64 *sptep)
{ {
mmu_spte_clear_track_bits(kvm, sptep); mmu_spte_clear_track_bits(kvm, sptep);
__pte_list_remove(sptep, rmap_head); __pte_list_remove(sptep, rmap_head);
} }
/* Return true if rmap existed, false otherwise */ /* Return true if at least one SPTE was zapped, false otherwise */
static bool pte_list_destroy(struct kvm *kvm, struct kvm_rmap_head *rmap_head) static bool kvm_zap_all_rmap_sptes(struct kvm *kvm,
struct kvm_rmap_head *rmap_head)
{ {
struct pte_list_desc *desc, *next; struct pte_list_desc *desc, *next;
int i; int i;
...@@ -1386,7 +1387,7 @@ static bool kvm_vcpu_write_protect_gfn(struct kvm_vcpu *vcpu, u64 gfn) ...@@ -1386,7 +1387,7 @@ static bool kvm_vcpu_write_protect_gfn(struct kvm_vcpu *vcpu, u64 gfn)
static bool __kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head, static bool __kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
const struct kvm_memory_slot *slot) const struct kvm_memory_slot *slot)
{ {
return pte_list_destroy(kvm, rmap_head); return kvm_zap_all_rmap_sptes(kvm, rmap_head);
} }
static bool kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head, static bool kvm_zap_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
...@@ -1417,7 +1418,7 @@ static bool kvm_set_pte_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head, ...@@ -1417,7 +1418,7 @@ static bool kvm_set_pte_rmap(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
need_flush = true; need_flush = true;
if (pte_write(pte)) { if (pte_write(pte)) {
pte_list_remove(kvm, rmap_head, sptep); kvm_zap_one_rmap_spte(kvm, rmap_head, sptep);
goto restart; goto restart;
} else { } else {
new_spte = kvm_mmu_changed_pte_notifier_make_spte( new_spte = kvm_mmu_changed_pte_notifier_make_spte(
...@@ -1596,7 +1597,7 @@ static void __rmap_add(struct kvm *kvm, ...@@ -1596,7 +1597,7 @@ static void __rmap_add(struct kvm *kvm,
rmap_count = pte_list_add(cache, spte, rmap_head); rmap_count = pte_list_add(cache, spte, rmap_head);
if (rmap_count > RMAP_RECYCLE_THRESHOLD) { if (rmap_count > RMAP_RECYCLE_THRESHOLD) {
pte_list_destroy(kvm, rmap_head); kvm_zap_all_rmap_sptes(kvm, rmap_head);
kvm_flush_remote_tlbs_with_address( kvm_flush_remote_tlbs_with_address(
kvm, sp->gfn, KVM_PAGES_PER_HPAGE(sp->role.level)); kvm, sp->gfn, KVM_PAGES_PER_HPAGE(sp->role.level));
} }
...@@ -6406,7 +6407,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm, ...@@ -6406,7 +6407,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
if (sp->role.direct && if (sp->role.direct &&
sp->role.level < kvm_mmu_max_mapping_level(kvm, slot, sp->gfn, sp->role.level < kvm_mmu_max_mapping_level(kvm, slot, sp->gfn,
pfn, PG_LEVEL_NUM)) { pfn, PG_LEVEL_NUM)) {
pte_list_remove(kvm, rmap_head, sptep); kvm_zap_one_rmap_spte(kvm, rmap_head, sptep);
if (kvm_available_flush_tlb_with_range()) if (kvm_available_flush_tlb_with_range())
kvm_flush_remote_tlbs_with_address(kvm, sp->gfn, kvm_flush_remote_tlbs_with_address(kvm, sp->gfn,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册