Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6543440rwp; Tue, 18 Jul 2023 01:55:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOtBqvVW0r5QLL7f0RzSF1ATKyGxmVwgLVbCI7nPheSvFcBgixWcqnn2b24G2f2rdoZFlt X-Received: by 2002:a17:90a:68c1:b0:262:e589:678f with SMTP id q1-20020a17090a68c100b00262e589678fmr16369400pjj.10.1689670530289; Tue, 18 Jul 2023 01:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689670530; cv=none; d=google.com; s=arc-20160816; b=yg8MO8AetHirTPgc7SIg34Ym1C240RNzf7sF5EFJjcqyLNCUW/DjFv41rmMgID7N90 lQnTBfzCHr+ZStOiz9OvJLnab8K/CakPWYC8oAJ70TchO8xc4m9/kfO5MCWUMlCEoBB3 Te5aQCppsREjY2P2gvbbjHGOm1B2Hgdh+lKbmM6sJK7YyGAGsEP2kOcE3VmXbnLcZK1S fc5OyAI56O7wrjPIsZcdtcmFPCth+b+j3DSBJgJ+EblFmICUZs/lgWuTVw87r0QBw9Kc tIjV+h01cFzbFG3FR/DORTrMEYYU0Azq+zoWPY0tW2JFiVX+vwDrxtbtLVXOOtHprkTU 8H+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=48OfsAs+5NoliWawjnL6mrqynpB+mYbsWNJ2N0teO4w=; fh=dtmyRp41a7HNsguMu6kfLz6FF6pPWBN5buE6e7Npe+E=; b=ZSxDQkJNrEcGocXGoVg0ffGkMCbvgZhrelJjISnDZVjW2aWEHtsyOcvhpxLAj1Ag2o 6bO5PS26ClAex+tB0XoIg6q9MuZP5lhrBdxLbdjz45MQa4Ph8FHDDy1eCkphD3TVmg9Z E6SiTIjL0UBadnE742zILBK0EZ1MgsKxvvMy2XpqltXsmfB1dkrE3/oMd0CC6h6x+Z7S 0ccVAnpinzGwpI1zA4tEByCExQKc7Hn/XycBoz4YLuTjVJZItaoT/FDOF+EgsBhARMLj 5IJOPVcnwYqFFaikbZ761EXtRQoKBTAEoaqVzXkMw4WeHAfcS+0tAQki64ldAaUPf5ay Em/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcNcd7BU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a17090264cf00b001aafb271d13si1299761pli.235.2023.07.18.01.55.17; Tue, 18 Jul 2023 01:55:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcNcd7BU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231971AbjGRIkJ (ORCPT + 99 others); Tue, 18 Jul 2023 04:40:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbjGRIkF (ORCPT ); Tue, 18 Jul 2023 04:40:05 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53BEE4C for ; Tue, 18 Jul 2023 01:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689669568; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=48OfsAs+5NoliWawjnL6mrqynpB+mYbsWNJ2N0teO4w=; b=ZcNcd7BUBnlW5ef07InP4qh+CXmP3//x42h+6KkHe8zJOK0n9oT9g0y6W/ehB+qHMatmcw Kf0/QgsUyWPFa8xrIeo741jLcPHKMcKOuRT/pD7KMZ08fjj2lXPIs25ToXrdu6zX7iyncC ZauNHXYSMNIJlWS18hN+GSvlY76wO7Q= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-aKfWN3w6MUGih3J2TmV6YQ-1; Tue, 18 Jul 2023 04:39:26 -0400 X-MC-Unique: aKfWN3w6MUGih3J2TmV6YQ-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-543c2538071so743624a12.1 for ; Tue, 18 Jul 2023 01:39:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689669566; x=1692261566; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=48OfsAs+5NoliWawjnL6mrqynpB+mYbsWNJ2N0teO4w=; b=TsG/R3V5OyuQ8qY4BrQCXIJw++0siAaWG1cI574PWcxU0qOZVrVFm/c+Tl/aPi+yQX HMkRXn8waYZKDTGS7Ga7c+OMff+FaxT+aVJq5eLvYbgwmECFHpUTCe+LBVJF+h2j7TT0 dPusr8asbytczbMgnLk0L+zVi57g3jExVmMNxhJNNBn7EXzttzbNV9pEJh+erNAUp6oL 1wxUFj97izJwUj3evRHIZF1Z8+f2uPzmkZqZHiZu/r//Kkhd+MwzkagOy1LkUyCH9RCj 47ByVpW3blJl5KWFVGaKZ4mk+8E/NqZL+BqZlPzO+NEtVbVjHTbj5U2g16RghLuoBgoG 2LZA== X-Gm-Message-State: ABy/qLbVevdDi0+Z97jZWFbF93+Feumkg6RLDlln3kgTi8eOSsuMFZ/T WvO6EZDH4VM6WKkJg1NKl4xWA4+CZJzNyOYXXaqIOm+/0Qpx1F5m/stjso06NSNF35zmDhnJlzu lT72aL8UBkcOBp6SS+My060NY X-Received: by 2002:a05:6a21:338e:b0:123:149b:a34f with SMTP id yy14-20020a056a21338e00b00123149ba34fmr11522159pzb.1.1689669565972; Tue, 18 Jul 2023 01:39:25 -0700 (PDT) X-Received: by 2002:a05:6a21:338e:b0:123:149b:a34f with SMTP id yy14-20020a056a21338e00b00123149ba34fmr11522141pzb.1.1689669565640; Tue, 18 Jul 2023 01:39:25 -0700 (PDT) Received: from [10.66.61.39] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id p9-20020a639509000000b0055bbc746272sm1140176pgd.17.2023.07.18.01.39.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jul 2023 01:39:25 -0700 (PDT) Message-ID: <148fecc6-7ad5-1039-4466-7c1e5a9df911@redhat.com> Date: Tue, 18 Jul 2023 16:39:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v6 07/11] KVM: arm64: Define kvm_tlb_flush_vmid_range() Content-Language: en-US To: Raghavendra Rao Ananta , Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Colton Lewis , David Matlack , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Gavin Shan References: <20230715005405.3689586-1-rananta@google.com> <20230715005405.3689586-8-rananta@google.com> From: Shaoqin Huang In-Reply-To: <20230715005405.3689586-8-rananta@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/15/23 08:54, Raghavendra Rao Ananta wrote: > Implement the helper kvm_tlb_flush_vmid_range() that acts > as a wrapper for range-based TLB invalidations. For the > given VMID, use the range-based TLBI instructions to do > the job or fallback to invalidating all the TLB entries. > > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Gavin Shan Reviewed-by: Shaoqin Huang > --- > arch/arm64/include/asm/kvm_pgtable.h | 10 ++++++++++ > arch/arm64/kvm/hyp/pgtable.c | 20 ++++++++++++++++++++ > 2 files changed, 30 insertions(+) > > diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h > index 8294a9a7e566..5e8b1ff07854 100644 > --- a/arch/arm64/include/asm/kvm_pgtable.h > +++ b/arch/arm64/include/asm/kvm_pgtable.h > @@ -754,4 +754,14 @@ enum kvm_pgtable_prot kvm_pgtable_stage2_pte_prot(kvm_pte_t pte); > * kvm_pgtable_prot format. > */ > enum kvm_pgtable_prot kvm_pgtable_hyp_pte_prot(kvm_pte_t pte); > + > +/** > + * kvm_tlb_flush_vmid_range() - Invalidate/flush a range of TLB entries > + * > + * @mmu: Stage-2 KVM MMU struct > + * @addr: The base Intermediate physical address from which to invalidate > + * @size: Size of the range from the base to invalidate > + */ > +void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu, > + phys_addr_t addr, size_t size); > #endif /* __ARM64_KVM_PGTABLE_H__ */ > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index aa740a974e02..5d14d5d5819a 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -670,6 +670,26 @@ static bool stage2_has_fwb(struct kvm_pgtable *pgt) > return !(pgt->flags & KVM_PGTABLE_S2_NOFWB); > } > > +void kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu, > + phys_addr_t addr, size_t size) > +{ > + unsigned long pages, inval_pages; > + > + if (!system_supports_tlb_range()) { > + kvm_call_hyp(__kvm_tlb_flush_vmid, mmu); > + return; > + } > + > + pages = size >> PAGE_SHIFT; > + while (pages > 0) { > + inval_pages = min(pages, MAX_TLBI_RANGE_PAGES); > + kvm_call_hyp(__kvm_tlb_flush_vmid_range, mmu, addr, inval_pages); > + > + addr += inval_pages << PAGE_SHIFT; > + pages -= inval_pages; > + } > +} > + > #define KVM_S2_MEMATTR(pgt, attr) PAGE_S2_MEMATTR(attr, stage2_has_fwb(pgt)) > > static int stage2_set_prot_attr(struct kvm_pgtable *pgt, enum kvm_pgtable_prot prot, -- Shaoqin