Skip to content

Commit db0d70e

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Move kvm_arch_flush_shadow_{all,memslot}() to mmu.c
Move x86's implementation of kvm_arch_flush_shadow_{all,memslot}() into mmu.c, and make kvm_mmu_zap_all() static as it was globally visible only for kvm_arch_flush_shadow_all(). This will allow refactoring kvm_arch_flush_shadow_memslot() to call kvm_mmu_zap_all() directly without having to expose kvm_mmu_zap_all_fast() outside of mmu.c. Keeping everything in mmu.c will also likely simplify supporting TDX, which intends to do zap only relevant SPTEs on memslot updates. No functional change intended. Suggested-by: Yan Zhao <[email protected]> Tested-by: Yongwei Ma <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 3cca6b2 commit db0d70e

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,6 @@ void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
18531853
const struct kvm_memory_slot *memslot);
18541854
void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
18551855
const struct kvm_memory_slot *memslot);
1856-
void kvm_mmu_zap_all(struct kvm *kvm);
18571856
void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen);
18581857
void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned long kvm_nr_mmu_pages);
18591858

arch/x86/kvm/mmu/mmu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6678,7 +6678,7 @@ void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
66786678
*/
66796679
}
66806680

6681-
void kvm_mmu_zap_all(struct kvm *kvm)
6681+
static void kvm_mmu_zap_all(struct kvm *kvm)
66826682
{
66836683
struct kvm_mmu_page *sp, *node;
66846684
LIST_HEAD(invalid_list);
@@ -6703,6 +6703,17 @@ void kvm_mmu_zap_all(struct kvm *kvm)
67036703
write_unlock(&kvm->mmu_lock);
67046704
}
67056705

6706+
void kvm_arch_flush_shadow_all(struct kvm *kvm)
6707+
{
6708+
kvm_mmu_zap_all(kvm);
6709+
}
6710+
6711+
void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
6712+
struct kvm_memory_slot *slot)
6713+
{
6714+
kvm_page_track_flush_slot(kvm, slot);
6715+
}
6716+
67066717
void kvm_mmu_invalidate_mmio_sptes(struct kvm *kvm, u64 gen)
67076718
{
67086719
WARN_ON_ONCE(gen & KVM_MEMSLOT_GEN_UPDATE_IN_PROGRESS);

arch/x86/kvm/x86.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12802,17 +12802,6 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
1280212802
kvm_arch_free_memslot(kvm, old);
1280312803
}
1280412804

12805-
void kvm_arch_flush_shadow_all(struct kvm *kvm)
12806-
{
12807-
kvm_mmu_zap_all(kvm);
12808-
}
12809-
12810-
void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
12811-
struct kvm_memory_slot *slot)
12812-
{
12813-
kvm_page_track_flush_slot(kvm, slot);
12814-
}
12815-
1281612805
static inline bool kvm_guest_apic_has_interrupt(struct kvm_vcpu *vcpu)
1281712806
{
1281812807
return (is_guest_mode(vcpu) &&

0 commit comments

Comments
 (0)