virt inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10293 ---------------------------------------- Enable the directed TLBI path in the two remote TLB flush functions: `kvm_arch_flush_remote_tlbs()` and `kvm_arch_flush_remote_tlbs_range()`. When `kvm_tlbi_direct_enabled()` returns true, these functions send `KVM_REQ_DIRECT_TLBI` requests to the affected vCPUs instead of using the traditional broadcast TLBI path. Each vCPU processes the request before entering the guest and performs a local TLBI on its Stage-2 translation context. Suggested-by: Yanan Wang <wangyanan55@huawei.com> Signed-off-by: Jinqian Yang <yangjinqian1@huawei.com> --- arch/arm64/kvm/mmu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 07b923f42270..5a9af931e6dc 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -19,6 +19,7 @@ #include <asm/kvm_ras.h> #include <asm/kvm_asm.h> #include <asm/kvm_emulate.h> +#include <asm/kvm_tlbi.h> #include <asm/virt.h> #ifdef CONFIG_HISI_VIRTCCA_CODA #include <asm/kvm_tmi.h> @@ -206,6 +207,12 @@ bool kvm_arch_has_assigned_device(struct kvm *kvm) */ int kvm_arch_flush_remote_tlbs(struct kvm *kvm) { +#ifdef CONFIG_KVM_ARM_DIRECT_TLBI + if (kvm_tlbi_direct_enabled(kvm)) { + kvm_tlbi_request_flush(kvm); + return 0; + } +#endif kvm_call_hyp(__kvm_tlb_flush_vmid, &kvm->arch.mmu); return 0; } @@ -213,6 +220,13 @@ int kvm_arch_flush_remote_tlbs(struct kvm *kvm) int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t gfn, u64 nr_pages) { +#ifdef CONFIG_KVM_ARM_DIRECT_TLBI + if (kvm_tlbi_direct_enabled(kvm)) { + kvm_tlbi_request_flush_range(kvm, gfn << PAGE_SHIFT, + nr_pages << PAGE_SHIFT); + return 0; + } +#endif kvm_tlb_flush_vmid_range(&kvm->arch.mmu, gfn << PAGE_SHIFT, nr_pages << PAGE_SHIFT); return 0; -- 2.33.0