Skip to content

Commit dd9eaad

Browse files
committed
KVM: x86/mmu: Add a helper to walk and zap rmaps for a memslot
Add a dedicated helper to walk and zap rmaps for a given memslot so that the code can be shared between KVM-initiated zaps and mmu_notifier invalidations. No functional change intended. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 5b1fb11 commit dd9eaad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,16 @@ static __always_inline bool walk_slot_rmaps_4k(struct kvm *kvm,
15731573
return walk_slot_rmaps(kvm, slot, fn, PG_LEVEL_4K, PG_LEVEL_4K, flush_on_yield);
15741574
}
15751575

1576+
static bool __kvm_rmap_zap_gfn_range(struct kvm *kvm,
1577+
const struct kvm_memory_slot *slot,
1578+
gfn_t start, gfn_t end, bool can_yield,
1579+
bool flush)
1580+
{
1581+
return __walk_slot_rmaps(kvm, slot, __kvm_zap_rmap,
1582+
PG_LEVEL_4K, KVM_MAX_HUGEPAGE_LEVEL,
1583+
start, end - 1, can_yield, true, flush);
1584+
}
1585+
15761586
typedef bool (*rmap_handler_t)(struct kvm *kvm, struct kvm_rmap_head *rmap_head,
15771587
struct kvm_memory_slot *slot, gfn_t gfn,
15781588
int level);
@@ -6602,9 +6612,8 @@ static bool kvm_rmap_zap_gfn_range(struct kvm *kvm, gfn_t gfn_start, gfn_t gfn_e
66026612
if (WARN_ON_ONCE(start >= end))
66036613
continue;
66046614

6605-
flush = __walk_slot_rmaps(kvm, memslot, __kvm_zap_rmap,
6606-
PG_LEVEL_4K, KVM_MAX_HUGEPAGE_LEVEL,
6607-
start, end - 1, true, true, flush);
6615+
flush = __kvm_rmap_zap_gfn_range(kvm, memslot, start,
6616+
end, true, flush);
66086617
}
66096618
}
66106619

0 commit comments

Comments
 (0)