virt inclusion category: feature bugzilla: https://atomgit.com/openeuler/kernel/issues/10293 ---------------------------------------- Add __kvm_tlb_flush_vmid_nsh() and its range-based companion, which locally invalidate this VM's stage-2 context on the calling pCPU instead of broadcasting over the inner-shareable domain. Without FEAT_TLBIRANGE, or beyond what a single range instruction can cover, the range variant falls back to the whole-VMID local flush. VHE-only. No functional change. Suggested-by: Yanan Wang <wangyanan55@huawei.com> Signed-off-by: Jinqian Yang <yangjinqian1@huawei.com> --- arch/arm64/kvm/hyp/vhe/tlb.c | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/arch/arm64/kvm/hyp/vhe/tlb.c b/arch/arm64/kvm/hyp/vhe/tlb.c index 39f0965b4a50..12849fed7628 100644 --- a/arch/arm64/kvm/hyp/vhe/tlb.c +++ b/arch/arm64/kvm/hyp/vhe/tlb.c @@ -225,6 +225,58 @@ void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu) __tlb_switch_to_host(&cxt); } +#ifdef CONFIG_KVM_ARM_DIRECT_TLBI +void __kvm_tlb_flush_vmid_nsh(struct kvm_s2_mmu *mmu) +{ + struct tlb_inv_context cxt; + + dsb(nshst); + + /* Switch to requested VMID */ + __tlb_switch_to_guest(mmu, &cxt); + + __tlbi(vmalls12e1); + dsb(nsh); + isb(); + + __tlb_switch_to_host(&cxt); +} + +void __kvm_tlb_flush_vmid_range_nsh(struct kvm_s2_mmu *mmu, + phys_addr_t start, unsigned long pages) +{ + struct tlb_inv_context cxt; + unsigned long stride; + + /* + * Without FEAT_TLBIRANGE, or beyond what a single range + * instruction can cover, fall back to a whole-VMID local + * flush. + */ + if (!system_supports_tlb_range() || pages > MAX_TLBI_RANGE_PAGES) { + __kvm_tlb_flush_vmid_nsh(mmu); + return; + } + + stride = PAGE_SIZE; + start = round_down(start, stride); + + dsb(nshst); + + /* Switch to requested VMID */ + __tlb_switch_to_guest(mmu, &cxt); + + __flush_s2_tlb_range_op(ipas2e1, start, pages, stride, 0); + + dsb(nsh); + __tlbi(vmalle1); + dsb(nsh); + isb(); + + __tlb_switch_to_host(&cxt); +} +#endif /* CONFIG_KVM_ARM_DIRECT_TLBI */ + void __kvm_flush_cpu_context(struct kvm_s2_mmu *mmu) { struct tlb_inv_context cxt; -- 2.33.0