Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29751870rwd; Wed, 5 Jul 2023 17:19:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlEu3ASqC/S72c8V5t4GJHwEANGDoL8R6BwOnoJYvoGjVj0+ENSsZH0PGBA9tr7NvQgjECEH X-Received: by 2002:a05:6a00:23d3:b0:67f:6226:58ac with SMTP id g19-20020a056a0023d300b0067f622658acmr355364pfc.14.1688602739881; Wed, 05 Jul 2023 17:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688602739; cv=none; d=google.com; s=arc-20160816; b=lQCe0Cwop9FZwjNyI3+VhwJg8WejkWJFbR+udSNUtVSbZIm5JUze458Ng7wLBauew6 AqzcJk4pcUyZEqx3z1YCCTejaqK/mVVGm/rjNwhb7NXD/uNT4K9Hfxi/20Yf8Ps1JYR0 TEr9Q5StrGuHoE1XozHg2GKyP0xBHvQ8hncj5L7jCm5577V7XnjGTDgPSNqutjAzoOGO trK616QQHR5Aare8dmcWSxmZbZe23qxj/soTCPerT5yfvrloaBwSgBMWnVAia+XBCG5k mK0myLsXH0MP+qkE2TJxjI0xY9wXJbZnU4dXJbJ05ArPqwaV17DUlKrqWl+H8QY3mK32 qUrQ== 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=kTd/qr4bksrZcC6BdjL1ZLMm9nyCEwUKcpATLihwv5k=; fh=8DYvN1HoUPZptB/Xd/6xc8xMsID3+Mdiw0JUBDhD+eY=; b=UNs199NWwuJ8gmvPwujWDhjFJ5h75OIMi3KnZhkE2M/fuyq425c14LoFguCN9gjpi+ j+FPabfsoaTUMiIugfB/Fk0b230Vm9h6ejffmwqChC5ZaRJg6p1m++euUbalEUcxj+Zy DZytdzc4VfEokYyTMm4i5zso0+H6mCMsKXtov/k3GvDy3N4vq/h2xkVDg5ZxT/xTTk4h UPHOvzWwDvfGvUBe2jw/biIELyRofjsuq8D/UHmw4W1RW9HX3bJiEWcL5mr2UeQAkTvh mmwoWETjG8tWN7oe025TcXNTpwjE8uZSKktpdDECIX2HpPEjcr0lwhzujKdDoopofRBE Bcgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Px8P2cXm; 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 e20-20020a63d954000000b0053efd7561e1si297368pgj.287.2023.07.05.17.18.47; Wed, 05 Jul 2023 17:18:59 -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=Px8P2cXm; 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 S232609AbjGFAFk (ORCPT + 99 others); Wed, 5 Jul 2023 20:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbjGFAFi (ORCPT ); Wed, 5 Jul 2023 20:05:38 -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 A3F5919A0 for ; Wed, 5 Jul 2023 17:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688601891; 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=kTd/qr4bksrZcC6BdjL1ZLMm9nyCEwUKcpATLihwv5k=; b=Px8P2cXmL4kAzwaBh3u1WZKnO0xzSM24m5iqzHheVM8t7KfHajn7LGctxK5ht/b0vsjLtu Vur9gkrThWgP8pSpzobwjSYRh36i00HK5bN0utbsBKjzagsAVFUcQsPsckEYMm+D8PWavp /on0x3Tkiz3Uw/hxBCTuj8SMYwT8GgA= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-W0yA9o32P3eIPDeAceHCNQ-1; Wed, 05 Jul 2023 20:04:50 -0400 X-MC-Unique: W0yA9o32P3eIPDeAceHCNQ-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3a337ddff03so171207b6e.0 for ; Wed, 05 Jul 2023 17:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688601890; x=1691193890; 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=kTd/qr4bksrZcC6BdjL1ZLMm9nyCEwUKcpATLihwv5k=; b=lg71VteGHVjhmdA3ZPWhzAf9EsIlT3niXG49xF1ULSkNKz5/mTDqZFAXooCafMHSRw nQmwElkN0FlFQC20KViILke67iWwdiWlzQkXKuYmngk6SknYkJ77K6N3S+n72M3xhECb HeYZNi+Y/mZqJ2GGOMXPVl6pZ9aJ2LaAtNYUHyr/0VWpOQum5mZKkWdMCSpSalab5QPM tkRSfAvO7uTWoitFuLq05C6bBz3apttfUYp7LYCKw8U5VHAQeR4CfjceBm0tIxoPJBOE IxOwO/jXB6QoysK2D2Fui7JxzH3xnxZkd06Yo2Kxb/hy8qBk+2G/M8YH1rdFvEH4nIbD Ek1Q== X-Gm-Message-State: ABy/qLZkqmq2caH80eXMEbG9rT9PSdZvm+yfLdcYx1r7MsgZzhhe5ViP UncftQeYYo7ZwZqHAYFKjdgHTUgAVn1AyyV3HIv6YtWhMCQHnIp8lKVJh3CPju9XWmNyDFhoNvR 1b2OX78lYHpe5GDgQx80YxysE X-Received: by 2002:aca:210c:0:b0:3a3:b98a:d7b3 with SMTP id 12-20020aca210c000000b003a3b98ad7b3mr156726oiz.15.1688601890052; Wed, 05 Jul 2023 17:04:50 -0700 (PDT) X-Received: by 2002:aca:210c:0:b0:3a3:b98a:d7b3 with SMTP id 12-20020aca210c000000b003a3b98ad7b3mr156713oiz.15.1688601889815; Wed, 05 Jul 2023 17:04:49 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id x11-20020a056a00270b00b00662610cf7a8sm83655pfv.172.2023.07.05.17.04.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jul 2023 17:04:48 -0700 (PDT) Message-ID: <60ba5bb4-6fad-0e51-2cd5-845610e6631d@redhat.com> Date: Thu, 6 Jul 2023 10:04:38 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RESEND PATCH v5 07/11] KVM: arm64: Define kvm_tlb_flush_vmid_range() Content-Language: en-US To: Raghavendra Rao Ananta Cc: Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose , 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 References: <20230621175002.2832640-1-rananta@google.com> <20230621175002.2832640-8-rananta@google.com> <1fe280a7-0f10-e124-00aa-b137df722c33@redhat.com> From: Gavin Shan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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/6/23 04:28, Raghavendra Rao Ananta wrote: > On Tue, Jul 4, 2023 at 5:31 PM Gavin Shan wrote: >> On 6/22/23 03:49, 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 >>> --- >>> arch/arm64/include/asm/kvm_pgtable.h | 10 ++++++++++ >>> arch/arm64/kvm/hyp/pgtable.c | 20 ++++++++++++++++++++ >>> 2 files changed, 30 insertions(+) >>> >> >> It may be reasonable to fold this to PATCH[08/11] since kvm_tlb_flush_vmid_range() is >> only called by ARM64's kvm_arch_flush_remote_tlbs_range(), which is added by PATCH[08/11]. >> In either way, the changes look good to me: >> > Ah, the patches 10 and 11 also call kvm_tlb_flush_vmid_range(), so > probably it's better to keep the definition isolated? > Thanks for your explanation. It's fine to have two separate patches in this case. I still need to spend some time to look at PATCH[11/11] whose subject includes typo (intructions -> instructions) Thanks, Gavin >> Reviewed-by: Gavin Shan >> >>> diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h >>> index 4cd6762bda805..1b12295a83595 100644 >>> --- a/arch/arm64/include/asm/kvm_pgtable.h >>> +++ b/arch/arm64/include/asm/kvm_pgtable.h >>> @@ -682,4 +682,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 3d61bd3e591d2..df8ac14d9d3d4 100644 >>> --- a/arch/arm64/kvm/hyp/pgtable.c >>> +++ b/arch/arm64/kvm/hyp/pgtable.c >>> @@ -631,6 +631,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,