@@ -1049,6 +1049,22 @@ static void pte_list_clear_concurrently(u64 *spte, unsigned long *pte_list)
return;
}
+static void pte_list_free_desc(unsigned long *pte_list)
+{
+ struct pte_list_desc *desc, *next;
+ unsigned long pte_value = *pte_list;
+
+ if (!(pte_value & 1))
+ return;
+
+ desc = (struct pte_list_desc *)(pte_value & ~1ul);
+ do {
+ next = desc->more;
+ mmu_free_pte_list_desc(desc);
+ desc = next;
+ } while (desc);
+}
+
typedef void (*pte_list_walk_fn) (u64 *spte);
static void pte_list_walk(unsigned long *pte_list, pte_list_walk_fn fn)
{
@@ -1786,6 +1802,16 @@ unmap_memslot_rmap_nolock(struct kvm *kvm, struct kvm_memory_slot *slot)
walk_memslot_rmap_nolock(slot, unmap_invalid_rmap_nolock, kvm);
}
+static void free_rmap_desc_nolock(unsigned long *rmapp, void *data)
+{
+ pte_list_free_desc(rmapp);
+}
+
+void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot)
+{
+ walk_memslot_rmap_nolock(slot, free_rmap_desc_nolock, NULL);
+}
+
#ifdef MMU_DEBUG
static int is_empty_shadow_page(u64 *spt)
{
@@ -130,4 +130,5 @@ struct rmap_operations {
};
void init_memslot_rmap_ops(struct kvm_memory_slot *slot);
+void free_meslot_rmap_desc_nolock(struct kvm_memory_slot *slot);
#endif
It frees pte-list-descs used by memslot rmap after update memslot is completed Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> --- arch/x86/kvm/mmu.c | 26 ++++++++++++++++++++++++++ arch/x86/kvm/mmu.h | 1 + 2 files changed, 27 insertions(+), 0 deletions(-)