Skip to content

Commit fb1522e

Browse files
Jérôme Glissetorvalds
authored andcommitted
KVM: update to new mmu_notifier semantic v2
Calls to mmu_notifier_invalidate_page() were replaced by calls to mmu_notifier_invalidate_range() and are now bracketed by calls to mmu_notifier_invalidate_range_start()/end() Remove now useless invalidate_page callback. Changed since v1 (Linus Torvalds) - remove now useless kvm_arch_mmu_notifier_invalidate_page() Signed-off-by: Jérôme Glisse <jglisse@redhat.com> Tested-by: Mike Galbraith <efault@gmx.de> Tested-by: Adam Borowski <kilobyte@angband.pl> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Radim Krčmář <rkrcmar@redhat.com> Cc: kvm@vger.kernel.org Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a81461b commit fb1522e

File tree

7 files changed

+0
-77
lines changed

7 files changed

+0
-77
lines changed

arch/arm/include/asm/kvm_host.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,6 @@ int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
225225
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
226226
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
227227

228-
/* We do not have shadow page tables, hence the empty hooks */
229-
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
230-
unsigned long address)
231-
{
232-
}
233-
234228
struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
235229
struct kvm_vcpu __percpu **kvm_get_running_vcpus(void);
236230
void kvm_arm_halt_guest(struct kvm *kvm);

arch/arm64/include/asm/kvm_host.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,6 @@ void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
326326
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
327327
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
328328

329-
/* We do not have shadow page tables, hence the empty hooks */
330-
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
331-
unsigned long address)
332-
{
333-
}
334-
335329
struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
336330
struct kvm_vcpu * __percpu *kvm_get_running_vcpus(void);
337331
void kvm_arm_halt_guest(struct kvm *kvm);

arch/mips/include/asm/kvm_host.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,6 @@ void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
938938
int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
939939
int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
940940

941-
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
942-
unsigned long address)
943-
{
944-
}
945-
946941
/* Emulation */
947942
int kvm_get_inst(u32 *opc, struct kvm_vcpu *vcpu, u32 *out);
948943
enum emulation_result update_pc(struct kvm_vcpu *vcpu, u32 cause);

arch/powerpc/include/asm/kvm_host.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ extern int kvm_age_hva(struct kvm *kvm, unsigned long start, unsigned long end);
6767
extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
6868
extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
6969

70-
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
71-
unsigned long address)
72-
{
73-
}
74-
7570
#define HPTEG_CACHE_NUM (1 << 15)
7671
#define HPTEG_HASH_BITS_PTE 13
7772
#define HPTEG_HASH_BITS_PTE_LONG 12

arch/x86/include/asm/kvm_host.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,8 +1375,6 @@ int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
13751375
int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
13761376
void kvm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event);
13771377
void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu);
1378-
void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
1379-
unsigned long address);
13801378

13811379
void kvm_define_shared_msr(unsigned index, u32 msr);
13821380
int kvm_set_shared_msr(unsigned index, u64 val, u64 mask);

arch/x86/kvm/x86.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6734,17 +6734,6 @@ void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu)
67346734
}
67356735
EXPORT_SYMBOL_GPL(kvm_vcpu_reload_apic_access_page);
67366736

6737-
void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
6738-
unsigned long address)
6739-
{
6740-
/*
6741-
* The physical address of apic access page is stored in the VMCS.
6742-
* Update it when it becomes invalid.
6743-
*/
6744-
if (address == gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT))
6745-
kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD);
6746-
}
6747-
67486737
/*
67496738
* Returns 1 to let vcpu_run() continue the guest execution loop without
67506739
* exiting to the userspace. Otherwise, the value will be returned to the

virt/kvm/kvm_main.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -322,47 +322,6 @@ static inline struct kvm *mmu_notifier_to_kvm(struct mmu_notifier *mn)
322322
return container_of(mn, struct kvm, mmu_notifier);
323323
}
324324

325-
static void kvm_mmu_notifier_invalidate_page(struct mmu_notifier *mn,
326-
struct mm_struct *mm,
327-
unsigned long address)
328-
{
329-
struct kvm *kvm = mmu_notifier_to_kvm(mn);
330-
int need_tlb_flush, idx;
331-
332-
/*
333-
* When ->invalidate_page runs, the linux pte has been zapped
334-
* already but the page is still allocated until
335-
* ->invalidate_page returns. So if we increase the sequence
336-
* here the kvm page fault will notice if the spte can't be
337-
* established because the page is going to be freed. If
338-
* instead the kvm page fault establishes the spte before
339-
* ->invalidate_page runs, kvm_unmap_hva will release it
340-
* before returning.
341-
*
342-
* The sequence increase only need to be seen at spin_unlock
343-
* time, and not at spin_lock time.
344-
*
345-
* Increasing the sequence after the spin_unlock would be
346-
* unsafe because the kvm page fault could then establish the
347-
* pte after kvm_unmap_hva returned, without noticing the page
348-
* is going to be freed.
349-
*/
350-
idx = srcu_read_lock(&kvm->srcu);
351-
spin_lock(&kvm->mmu_lock);
352-
353-
kvm->mmu_notifier_seq++;
354-
need_tlb_flush = kvm_unmap_hva(kvm, address) | kvm->tlbs_dirty;
355-
/* we've to flush the tlb before the pages can be freed */
356-
if (need_tlb_flush)
357-
kvm_flush_remote_tlbs(kvm);
358-
359-
spin_unlock(&kvm->mmu_lock);
360-
361-
kvm_arch_mmu_notifier_invalidate_page(kvm, address);
362-
363-
srcu_read_unlock(&kvm->srcu, idx);
364-
}
365-
366325
static void kvm_mmu_notifier_change_pte(struct mmu_notifier *mn,
367326
struct mm_struct *mm,
368327
unsigned long address,
@@ -510,7 +469,6 @@ static void kvm_mmu_notifier_release(struct mmu_notifier *mn,
510469
}
511470

512471
static const struct mmu_notifier_ops kvm_mmu_notifier_ops = {
513-
.invalidate_page = kvm_mmu_notifier_invalidate_page,
514472
.invalidate_range_start = kvm_mmu_notifier_invalidate_range_start,
515473
.invalidate_range_end = kvm_mmu_notifier_invalidate_range_end,
516474
.clear_flush_young = kvm_mmu_notifier_clear_flush_young,

0 commit comments

Comments
 (0)