hulk 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, single pages still get an exact local invalidation and larger ranges fall back to the whole VMID. VHE-only. No functional change. Signed-off-by: Jinqian Yang <yangjinqian1@huawei.com> --- arch/arm64/kvm/hyp/vhe/tlb.c | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/arch/arm64/kvm/hyp/vhe/tlb.c b/arch/arm64/kvm/hyp/vhe/tlb.c index 23325e9f3cc3..2e81d94ebd04 100644 --- a/arch/arm64/kvm/hyp/vhe/tlb.c +++ b/arch/arm64/kvm/hyp/vhe/tlb.c @@ -187,6 +187,59 @@ void __kvm_tlb_flush_vmid(struct kvm_s2_mmu *mmu) __tlb_switch_to_host(&cxt); } +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 a single page still gets an exact + * invalidation, larger ranges fall back to the whole VMID. + */ + if (pages == 1 && !system_supports_tlb_range()) { + __kvm_tlb_flush_vmid_ipa_nsh(mmu, start, 3); + return; + } + 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); +} + void __kvm_flush_cpu_context(struct kvm_s2_mmu *mmu) { struct tlb_inv_context cxt; -- 2.33.0