From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 82444C74A5B for ; Thu, 30 Mar 2023 00:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LhAM4rrATf5+mzlsD76X+uoOdO/cjtHNXgi+fiBCn/A=; b=3/9keBuP/8F4n1 n1/U+NBlTsV3lPj+RY1W/pCBwpcVwvlvzFdsGdG5gtO6nnD5iovr+EY/34x3NuxZJr+gD0gVEM4nD VTe/O9ZT9B83H8gWjOYROWklqtSOul1UBVsHfzaVg9dg9TSWCG2129QkjPeHsStSkEVw2klb5u4/u w0Vy+Yx+CwthtY9klREeUoOFHOidzdbrqsKfhQziS147tdSHkqjRQUmhwArX6w2CkRuxBjL+QQPXq YAnnKD+ccz/OctV42mudLp4xZkaBcQtYgSlaTpA4r3OnrjI8LxGeciyQ4qmR1+IYOVvyoXb+VlPhT h57YoFRR447As7t3JoLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phgXU-002CpE-0l; Thu, 30 Mar 2023 00:53:16 +0000 Received: from out-33.mta1.migadu.com ([95.215.58.33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phgXQ-002Cnj-2Z for linux-arm-kernel@lists.infradead.org; Thu, 30 Mar 2023 00:53:15 +0000 Date: Thu, 30 Mar 2023 00:53:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1680137589; 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: in-reply-to:in-reply-to:references:references; bh=u129OKoERAusr1NcAeNxizNI/fvdAMSKczWd0d3woXA=; b=wgi8ze+4zyW4qXl5dkwHr7dgFhgMpyWcpSuhdRy1cLNy8ZfdJgYLxWHAL6obzqTQvtrGeA uwwf/fsHapyKjPPJa/AQV4ilwXvLvSVaIGdcOXpMllTRLWci+cP66IoWvGixTD/q0Xdy7m 3ZEzzgoIB8WDFdYOtDq7qCLIGTbFxBc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Raghavendra Rao Ananta Cc: Oliver Upton , Marc Zyngier , Ricardo Koller , Reiji Watanabe , James Morse , Alexandru Elisei , Suzuki K Poulose , Will Deacon , Paolo Bonzini , Catalin Marinas , Jing Zhang , Colton Lewis , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v2 4/7] KVM: arm64: Implement kvm_arch_flush_remote_tlbs_range() Message-ID: References: <20230206172340.2639971-1-rananta@google.com> <20230206172340.2639971-5-rananta@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230206172340.2639971-5-rananta@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230329_175313_612598_1ADD12E5 X-CRM114-Status: GOOD ( 20.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Feb 06, 2023 at 05:23:37PM +0000, Raghavendra Rao Ananta wrote: > Implement kvm_arch_flush_remote_tlbs_range() for arm64, > such that it can utilize the TLBI range based instructions > if supported. > > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/include/asm/kvm_host.h | 3 +++ > arch/arm64/kvm/mmu.c | 15 +++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index dee530d75b957..211fab0c1de74 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1002,6 +1002,9 @@ struct kvm *kvm_arch_alloc_vm(void); > #define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS > int kvm_arch_flush_remote_tlbs(struct kvm *kvm); > > +#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS_RANGE > +int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn, u64 pages); > + > static inline bool kvm_vm_is_protected(struct kvm *kvm) > { > return false; > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index e98910a8d0af6..409cb187f4911 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -91,6 +91,21 @@ int kvm_arch_flush_remote_tlbs(struct kvm *kvm) > return 0; > } > > +int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t start_gfn, u64 pages) > +{ > + phys_addr_t start, end; > + > + if (!system_supports_tlb_range()) > + return -EOPNOTSUPP; There's multiple layers of fallback throughout this series, as it would appear that deep in __kvm_tlb_flush_range() you're blasting the whole VMID if either the range is too large or the feature isn't supported. Is it possible to just normalize on a single spot to gate the use of range-based invalidations? I have a slight preference for doing it deep in the handler, as it keeps the upper layers of code a bit more readable. > + start = start_gfn << PAGE_SHIFT; > + end = (start_gfn + pages) << PAGE_SHIFT; > + > + kvm_call_hyp(__kvm_tlb_flush_range_vmid_ipa, &kvm->arch.mmu, > + start, end, KVM_PGTABLE_MAX_LEVELS - 1, 0); > + return 0; > +} > + > static bool kvm_is_device_pfn(unsigned long pfn) > { > return !pfn_is_map_memory(pfn); > -- > 2.39.1.519.gcb327c4b5f-goog > > -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel