Skip to content

Commit 566a0be

Browse files
committed
KVM: MIPS: let generic code call prepare_flush_shadow
Since all calls to kvm_flush_remote_tlbs must be preceded by kvm_mips_callbacks->prepare_flush_shadow, repurpose kvm_arch_flush_remote_tlb to invoke it. This makes it possible to use the TLB flushing mechanism provided by the generic MMU notifier code. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5194552 commit 566a0be

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

arch/mips/include/asm/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,4 +1142,7 @@ static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
11421142
static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
11431143
static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {}
11441144

1145+
#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLB
1146+
int kvm_arch_flush_remote_tlb(struct kvm *kvm);
1147+
11451148
#endif /* __MIPS_KVM_HOST_H__ */

arch/mips/kvm/mips.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,6 @@ void kvm_arch_flush_shadow_all(struct kvm *kvm)
204204
{
205205
/* Flush whole GPA */
206206
kvm_mips_flush_gpa_pt(kvm, 0, ~0);
207-
208-
/* Let implementation do the rest */
209-
kvm_mips_callbacks->prepare_flush_shadow(kvm);
210207
kvm_flush_remote_tlbs(kvm);
211208
}
212209

@@ -995,11 +992,15 @@ void kvm_arch_sync_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot)
995992

996993
}
997994

995+
int kvm_arch_flush_remote_tlb(struct kvm *kvm)
996+
{
997+
kvm_mips_callbacks->prepare_flush_shadow(kvm);
998+
return 1;
999+
}
1000+
9981001
void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm,
9991002
const struct kvm_memory_slot *memslot)
10001003
{
1001-
/* Let implementation handle TLB/GVA invalidation */
1002-
kvm_mips_callbacks->prepare_flush_shadow(kvm);
10031004
kvm_flush_remote_tlbs(kvm);
10041005
}
10051006

arch/mips/kvm/mmu.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ int kvm_unmap_hva_range(struct kvm *kvm, unsigned long start, unsigned long end,
490490
unsigned flags)
491491
{
492492
handle_hva_to_gpa(kvm, start, end, &kvm_unmap_hva_handler, NULL);
493-
494-
kvm_mips_callbacks->prepare_flush_shadow(kvm);
495493
kvm_flush_remote_tlbs(kvm);
496494
return 0;
497495
}
@@ -533,10 +531,8 @@ int kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
533531
int ret;
534532

535533
ret = handle_hva_to_gpa(kvm, hva, end, &kvm_set_spte_handler, &pte);
536-
if (ret) {
537-
kvm_mips_callbacks->prepare_flush_shadow(kvm);
534+
if (ret)
538535
kvm_flush_remote_tlbs(kvm);
539-
}
540536
return 0;
541537
}
542538

0 commit comments

Comments
 (0)