[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e434cbe0-8d1c-c7fe-e169-01268bd4541c@loongson.cn>
Date: Wed, 18 Mar 2020 11:03:13 +0800
From: maobibo <maobibo@...ngson.cn>
To: Peter Xu <peterx@...hat.com>, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org
Cc: Sean Christopherson <sean.j.christopherson@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>,
linux-mips@...r.kernel.org, Vitaly Kuznetsov <vkuznets@...hat.com>
Subject: Re: [PATCH RFC 4/4] KVM: MIPS: Define arch-specific
kvm_flush_remote_tlbs()
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@...hat.com>
> ---
> 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,
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
regards
bibo, mao
> void kvm_arch_flush_shadow_all(struct kvm *kvm)
> {
> /* Flush whole GPA */
> kvm_mips_flush_gpa_pt(kvm, 0, ~0);
> -
> - /* Let implementation do the rest */
> - kvm_mips_callbacks->flush_shadow_all(kvm);
> + kvm_flush_remote_tlbs(kvm);
> }
>
> void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
> @@ -215,8 +218,7 @@ void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
> /* Flush slot from GPA */
> kvm_mips_flush_gpa_pt(kvm, slot->base_gfn,
> slot->base_gfn + slot->npages - 1);
> - /* Let implementation do the rest */
> - kvm_mips_callbacks->flush_shadow_all(kvm);
> + kvm_flush_remote_tlbs(kvm);
> spin_unlock(&kvm->mmu_lock);
> }
>
> @@ -258,7 +260,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
> new->base_gfn + new->npages - 1);
> /* Let implementation do the rest */
> if (needs_flush)
> - kvm_mips_callbacks->flush_shadow_all(kvm);
> + kvm_flush_remote_tlbs(kvm);
> spin_unlock(&kvm->mmu_lock);
> }
> }
> @@ -1001,9 +1003,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
> if (flush) {
> slots = kvm_memslots(kvm);
> memslot = id_to_memslot(slots, log->slot);
> -
> - /* Let implementation handle TLB/GVA invalidation */
> - kvm_mips_callbacks->flush_shadow_all(kvm);
> + kvm_flush_remote_tlbs(kvm);
> }
>
> mutex_unlock(&kvm->slots_lock);
> @@ -1024,9 +1024,7 @@ int kvm_vm_ioctl_clear_dirty_log(struct kvm *kvm, struct kvm_clear_dirty_log *lo
> if (flush) {
> slots = kvm_memslots(kvm);
> memslot = id_to_memslot(slots, log->slot);
> -
> - /* Let implementation handle TLB/GVA invalidation */
> - kvm_mips_callbacks->flush_shadow_all(kvm);
> + kvm_flush_remote_tlbs(kvm);
> }
>
> mutex_unlock(&kvm->slots_lock);
>
Powered by blists - more mailing lists