Skip to content

Commit fe71557

Browse files
tang-chenbonzini
authored andcommitted
kvm: Add arch specific mmu notifier for page invalidation
This will be used to let the guest run while the APIC access page is not pinned. Because subsequent patches will fill in the function for x86, place the (still empty) x86 implementation in the x86.c file instead of adding an inline function in kvm_host.h. Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 445b823 commit fe71557

6 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎arch/arm/include/asm/kvm_host.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ static inline int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
181181
return 0;
182182
}
183183

184+
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
185+
unsigned long address)
186+
{
187+
}
188+
184189
struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
185190
struct kvm_vcpu __percpu **kvm_get_running_vcpus(void);
186191

‎arch/arm64/include/asm/kvm_host.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ static inline int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
191191
return 0;
192192
}
193193

194+
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
195+
unsigned long address)
196+
{
197+
}
198+
194199
struct kvm_vcpu *kvm_arm_get_running_vcpu(void);
195200
struct kvm_vcpu __percpu **kvm_get_running_vcpus(void);
196201

‎arch/powerpc/include/asm/kvm_host.h‎

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

63+
static inline void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
64+
unsigned long address)
65+
{
66+
}
67+
6368
#define HPTEG_CACHE_NUM (1 << 15)
6469
#define HPTEG_HASH_BITS_PTE 13
6570
#define HPTEG_HASH_BITS_PTE_LONG 12

‎arch/x86/include/asm/kvm_host.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,8 @@ int kvm_cpu_has_interrupt(struct kvm_vcpu *vcpu);
10441044
int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
10451045
int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
10461046
void kvm_vcpu_reset(struct kvm_vcpu *vcpu);
1047+
void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
1048+
unsigned long address);
10471049

10481050
void kvm_define_shared_msr(unsigned index, u32 msr);
10491051
void kvm_set_shared_msr(unsigned index, u64 val, u64 mask);

‎arch/x86/kvm/x86.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,6 +6026,11 @@ static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu)
60266026
kvm_x86_ops->tlb_flush(vcpu);
60276027
}
60286028

6029+
void kvm_arch_mmu_notifier_invalidate_page(struct kvm *kvm,
6030+
unsigned long address)
6031+
{
6032+
}
6033+
60296034
/*
60306035
* Returns 1 to let __vcpu_run() continue the guest execution loop without
60316036
* exiting to the userspace. Otherwise, the value will be returned to the

‎virt/kvm/kvm_main.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ static void kvm_mmu_notifier_invalidate_page(struct mmu_notifier *mn,
296296
kvm_flush_remote_tlbs(kvm);
297297

298298
spin_unlock(&kvm->mmu_lock);
299+
300+
kvm_arch_mmu_notifier_invalidate_page(kvm, address);
301+
299302
srcu_read_unlock(&kvm->srcu, idx);
300303
}
301304

0 commit comments

Comments
 (0)