Skip to content

Commit 1628380

Browse files
committed
KVM: Kill off the old hva-based MMU notifier callbacks
Signed-off-by: Sean Christopherson <[email protected]>
1 parent 862b51d commit 1628380

File tree

6 files changed

+4
-99
lines changed

6 files changed

+4
-99
lines changed

arch/arm64/include/asm/kvm_host.h

-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ int __kvm_arm_vcpu_set_events(struct kvm_vcpu *vcpu,
582582
struct kvm_vcpu_events *events);
583583

584584
#define KVM_ARCH_WANT_MMU_NOTIFIER
585-
#define KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
586585

587586
void kvm_arm_halt_guest(struct kvm *kvm);
588587
void kvm_arm_resume_guest(struct kvm *kvm);

arch/mips/include/asm/kvm_host.h

-1
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,6 @@ enum kvm_mips_fault_result kvm_trap_emul_gva_fault(struct kvm_vcpu *vcpu,
967967
bool write);
968968

969969
#define KVM_ARCH_WANT_MMU_NOTIFIER
970-
#define KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
971970

972971
/* Emulation */
973972
int kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu, u32 *out);

arch/powerpc/include/asm/kvm_host.h

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
#include <linux/mmu_notifier.h>
5656

5757
#define KVM_ARCH_WANT_MMU_NOTIFIER
58-
#define KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
5958

6059
#define HPTEG_CACHE_NUM (1 << 15)
6160
#define HPTEG_HASH_BITS_PTE 13

arch/x86/include/asm/kvm_host.h

-1
Original file line numberDiff line numberDiff line change
@@ -1718,7 +1718,6 @@ asmlinkage void kvm_spurious_fault(void);
17181718
_ASM_EXTABLE(666b, 667b)
17191719

17201720
#define KVM_ARCH_WANT_MMU_NOTIFIER
1721-
#define KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
17221721

17231722
int kvm_cpu_has_injectable_intr(struct kvm_vcpu *v);
17241723
int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu);

include/linux/kvm_host.h

-8
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu);
219219
#endif
220220

221221
#ifdef KVM_ARCH_WANT_MMU_NOTIFIER
222-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
223222
struct kvm_gfn_info {
224223
struct kvm_memory_slot *slot;
225224
gfn_t start;
@@ -231,13 +230,6 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_info *info);
231230
bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_info *info);
232231
bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_info *info);
233232
bool kvm_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_info *info);
234-
#else
235-
int kvm_unmap_hva_range(struct kvm *kvm,
236-
unsigned long start, unsigned long end, unsigned flags);
237-
int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
238-
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
239-
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
240-
#endif /* KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS */
241233
#endif
242234

243235
enum {

virt/kvm/kvm_main.c

+4-87
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ static void kvm_mmu_notifier_invalidate_range(struct mmu_notifier *mn,
451451
srcu_read_unlock(&kvm->srcu, idx);
452452
}
453453

454-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
455454
typedef bool (*hva_handler_t)(struct kvm *kvm, struct kvm_gfn_info *info);
456455

457456
static __always_inline int __kvm_handle_hva_range(struct kvm *kvm,
@@ -541,50 +540,24 @@ static __always_inline int kvm_handle_hva_range_no_flush(struct mmu_notifier *mn
541540

542541
return ret;
543542
}
544-
#endif /* KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS */
545-
546543
static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
547544
struct mm_struct *mm,
548545
unsigned long address,
549546
pte_t pte)
550547
{
551-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
552-
kvm_handle_hva_range(mn, address, address + 1, pte, kvm_set_spte_gfn);
553-
#else
554-
struct kvm *kvm = mmu_notifier_to_kvm(mn);
555-
int idx;
556-
557548
trace_kvm_set_spte_hva(address);
558549

559-
idx = srcu_read_lock(&kvm->srcu);
560-
561-
KVM_MMU_LOCK(kvm);
562-
563-
kvm->mmu_notifier_seq++;
564-
565-
if (kvm_set_spte_hva(kvm, address, pte))
566-
kvm_flush_remote_tlbs(kvm);
567-
568-
KVM_MMU_UNLOCK(kvm);
569-
srcu_read_unlock(&kvm->srcu, idx);
570-
#endif
550+
kvm_handle_hva_range(mn, address, address + 1, pte, kvm_set_spte_gfn);
571551
}
572552

573553
static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
574554
const struct mmu_notifier_range *range)
575555
{
576-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
577556
bool blockable = mmu_notifier_range_blockable(range);
578-
#endif
579557
struct kvm *kvm = mmu_notifier_to_kvm(mn);
580-
#ifndef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
581-
int need_tlb_flush = 0, idx;
582558

583559
trace_kvm_unmap_hva_range(range->start, range->end);
584560

585-
idx = srcu_read_lock(&kvm->srcu);
586-
#endif
587-
588561
KVM_MMU_LOCK(kvm);
589562
/*
590563
* The count increase must become visible at unlock time as no
@@ -611,21 +584,10 @@ static int kvm_mmu_notifier_invalidate_range_start(struct mmu_notifier *mn,
611584
max(kvm->mmu_notifier_range_end, range->end);
612585
}
613586

614-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
615587
__kvm_handle_hva_range(kvm, range->start, range->end, __pte(0),
616588
kvm_unmap_gfn_range, true, blockable);
617-
#else
618-
need_tlb_flush = kvm_unmap_hva_range(kvm, range->start, range->end,
619-
range->flags);
620-
/* we've to flush the tlb before the pages can be freed */
621-
if (need_tlb_flush || kvm->tlbs_dirty)
622-
kvm_flush_remote_tlbs(kvm);
623-
#endif
624589

625590
KVM_MMU_UNLOCK(kvm);
626-
#ifndef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
627-
srcu_read_unlock(&kvm->srcu, idx);
628-
#endif
629591

630592
return 0;
631593
}
@@ -659,42 +621,18 @@ static int kvm_mmu_notifier_clear_flush_young(struct mmu_notifier *mn,
659621
unsigned long start,
660622
unsigned long end)
661623
{
662-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
663-
return kvm_handle_hva_range(mn, start, end, __pte(0), kvm_age_gfn);
664-
#else
665-
struct kvm *kvm = mmu_notifier_to_kvm(mn);
666-
int young, idx;
667-
668624
trace_kvm_age_hva(start, end);
669625

670-
idx = srcu_read_lock(&kvm->srcu);
671-
KVM_MMU_LOCK(kvm);
672-
673-
young = kvm_age_hva(kvm, start, end);
674-
if (young)
675-
kvm_flush_remote_tlbs(kvm);
676-
677-
KVM_MMU_UNLOCK(kvm);
678-
srcu_read_unlock(&kvm->srcu, idx);
679-
680-
return young;
681-
#endif
626+
return kvm_handle_hva_range(mn, start, end, __pte(0), kvm_age_gfn);
682627
}
683628

684629
static int kvm_mmu_notifier_clear_young(struct mmu_notifier *mn,
685630
struct mm_struct *mm,
686631
unsigned long start,
687632
unsigned long end)
688633
{
689-
#ifndef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
690-
struct kvm *kvm = mmu_notifier_to_kvm(mn);
691-
int young, idx;
692-
693634
trace_kvm_age_hva(start, end);
694635

695-
idx = srcu_read_lock(&kvm->srcu);
696-
KVM_MMU_LOCK(kvm);
697-
#endif
698636
/*
699637
* Even though we do not flush TLB, this will still adversely
700638
* affect performance on pre-Haswell Intel EPT, where there is
@@ -708,38 +646,17 @@ static int kvm_mmu_notifier_clear_young(struct mmu_notifier *mn,
708646
* cadence. If we find this inaccurate, we might come up with a
709647
* more sophisticated heuristic later.
710648
*/
711-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
712649
return kvm_handle_hva_range_no_flush(mn, start, end, kvm_age_gfn);
713-
#else
714-
young = kvm_age_hva(kvm, start, end);
715-
KVM_MMU_UNLOCK(kvm);
716-
srcu_read_unlock(&kvm->srcu, idx);
717-
718-
return young;
719-
#endif
720650
}
721651

722652
static int kvm_mmu_notifier_test_young(struct mmu_notifier *mn,
723653
struct mm_struct *mm,
724654
unsigned long address)
725655
{
726-
#ifdef KVM_ARCH_WANT_NEW_MMU_NOTIFIER_APIS
727-
return kvm_handle_hva_range_no_flush(mn, address, address + 1,
728-
kvm_test_age_gfn);
729-
#else
730-
struct kvm *kvm = mmu_notifier_to_kvm(mn);
731-
int young, idx;
732-
733656
trace_kvm_test_age_hva(address);
734657

735-
idx = srcu_read_lock(&kvm->srcu);
736-
KVM_MMU_LOCK(kvm);
737-
young = kvm_test_age_hva(kvm, address);
738-
KVM_MMU_UNLOCK(kvm);
739-
srcu_read_unlock(&kvm->srcu, idx);
740-
741-
return young;
742-
#endif
658+
return kvm_handle_hva_range_no_flush(mn, address, address + 1,
659+
kvm_test_age_gfn);
743660
}
744661

745662
static void kvm_mmu_notifier_release(struct mmu_notifier *mn,

0 commit comments

Comments
 (0)