Re: [PATCH RFC 4/4] KVM: MIPS: Define arch-specific kvm_flush_remote_tlbs()

From: maobibo
Date: Wed Mar 18 2020 - 22:21:17 EST




On 03/18/2020 11:28 PM, Peter Xu wrote:
On Wed, Mar 18, 2020 at 11:03:13AM +0800, maobibo wrote:


On 02/08/2020 06:35 AM, Peter Xu wrote:
Select HAVE_KVM_ARCH_TLB_FLUSH_ALL for MIPS to define its own
kvm_flush_remote_tlbs(). It's as simple as calling the
flush_shadow_all(kvm) hook. Then replace all the flush_shadow_all()
calls to use this KVM generic API to do TLB flush.

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---
arch/mips/kvm/Kconfig | 1 +
arch/mips/kvm/mips.c | 22 ++++++++++------------
2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig
index eac25aef21e0..8a06f660d39e 100644
--- a/arch/mips/kvm/Kconfig
+++ b/arch/mips/kvm/Kconfig
@@ -26,6 +26,7 @@ config KVM
select KVM_MMIO
select MMU_NOTIFIER
select SRCU
+ select HAVE_KVM_ARCH_TLB_FLUSH_ALL
---help---
Support for hosting Guest kernels.

diff --git a/arch/mips/kvm/mips.c b/arch/mips/kvm/mips.c
index 1d5e7ffda746..518020b466bf 100644
--- a/arch/mips/kvm/mips.c
+++ b/arch/mips/kvm/mips.c
@@ -194,13 +194,16 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
return 0;
}

+void kvm_flush_remote_tlbs(struct kvm *kvm)
+{
+ kvm_mips_callbacks->flush_shadow_all(kvm);
+}
+
Hi Peter,

Hi, Bibo,


Although I do not understand mip VZ fully, however it changes behavior of
MIPS VZ, since kvm_flush_remote_tlbs is also called in function
kvm_mmu_notifier_change_pte/kvm_mmu_notifier_invalidate_range_start

I'm not familiar with MIPS either, however... I would start to suspect
MIPS could be problematic with MMU notifiers when cpu_has_guestid is
not set. If that's the case, then this series might instead fix it.

yeap, from my viewpoint this series actually fix it when cpu_has_guestid is not set, previous kvm_flush_remote_tlbs function do nothing actually for MIPS VZ machine without cpu_has_guestid flag.


Thanks,