Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1429469rwl; Wed, 29 Mar 2023 18:12:04 -0700 (PDT) X-Google-Smtp-Source: AK7set8n3pOSJ/aOmCIWtvzuoMPKdQUbIeKSJG/5W0nqofZiI01TX4OF59mROUczDtZeJZmA/R6G X-Received: by 2002:a05:6a20:ba1:b0:db:bf57:35a6 with SMTP id i33-20020a056a200ba100b000dbbf5735a6mr16963364pzh.17.1680138724288; Wed, 29 Mar 2023 18:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680138724; cv=none; d=google.com; s=arc-20160816; b=X3VdXUY/FCh5cDe/ugf/z3+8LIU37JEo06KGG7vcropvWs0dm775wW6QnuWSQFOf8I JK2gEUTsJnz4odbR1ax+9uj0Pmko6LPv+y4S3+ji9NtWYhciaqx2cHgUdVqy/vfMab5T XwUKq13S1kf9f7virxJLXyjjKL6ZLc2ezqJ1N5Z0AU2rOueBZ3Td4i3vV/EgmzPY5rpH l80Ub8WwAqgJ7uKCfN3gxfCQ5nODurOKJg3+hNLGY3wHzMIlN3GLAFQRXINWwz6u5C0A ZYB4ISNQAzVeJGmMY9x7V4CqQFhSk5pHhVq1MURO6KOwnvXgzSDqUud6sObhE/tAiaYh hJBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=u129OKoERAusr1NcAeNxizNI/fvdAMSKczWd0d3woXA=; b=BPAcC7NQS/M4KkorOcXfUwJOix4NL5NuyEmuA5Urj0qGcvoRSWQ2RAyPP/C+Jzn7lG MQWAI3nVlyyU4qJFzte0N/EploBj8FQ/GKI5EIkxcQhJ8NUBrbxJH3soSuPgnAa0yiEA s/ZNuWxidUbDxaL1mRzDuog8FDw7YFniNsBXvnuGBowzWv8ljDv4+J+JncAdAZ4P8PM4 769IRPOZLHtzEjx2T8ji8VGTZXlxT07GpFcbzevQRlUwB2OpIFJS1PROwUKf0UPgRZ4c zuZNFwsNTXTBElK8XJMWddaj+kxNova2m0XgzU4xl7BTcG0HsJwSrCJOau/8awajx6q+ 2L2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wgi8ze+4; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020aa78888000000b00625ea7dae84si22982073pfe.161.2023.03.29.18.11.51; Wed, 29 Mar 2023 18:12:04 -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=@linux.dev header.s=key1 header.b=wgi8ze+4; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjC3AxP (ORCPT + 99 others); Wed, 29 Mar 2023 20:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbjC3AxO (ORCPT ); Wed, 29 Mar 2023 20:53:14 -0400 Received: from out-55.mta1.migadu.com (out-55.mta1.migadu.com [95.215.58.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3130D4C3A for ; Wed, 29 Mar 2023 17:53:13 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230206172340.2639971-5-rananta@google.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 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