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 E0897C54EBD for ; Mon, 9 Jan 2023 23:42:28 +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=B9kLuAN/BLJ3psusmuQVcMbECsakbbJmDeN+qFsEz/Q=; b=ae3nzukdbU9pOL /4xc6rOdtjHCMksXepZfJqOUbAi8+czk7MFFOjJF15R2YQalnLX/v0CjG0iP98whzJAQFDV8roTV5 gsb8yBtodfkmvr5oF914ZhFpS+aPy5iMSHVLthuDxLhQQO1cFmhj5KNv0ox/rnsvHvUxLy3xlftOz hW24dWZum5tZoSMUSJVyPBh4hKj7+B9aJlJhulFwGDvX8ivhzOBkb8FFZA1kBuF1uLCaPq2QJt+HE mBA7nF2M5tZcmk0l1DWA6nrGYG2yueDyDGrgRuC5I1S6N290pzg/Eaen6g6B9kLqLmNK2atsrcJoh vTR63wEQe+2cj4Hprelg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pF1lV-004eBa-Nf; Mon, 09 Jan 2023 23:41:17 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pF1lS-004eAm-Dd for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2023 23:41:16 +0000 Received: by mail-pj1-x102f.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so11496766pjj.4 for ; Mon, 09 Jan 2023 15:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=yJ7r4VJ0GFzUkp84DlniKC/ADesB2+RyryWjunDppAY=; b=YvL/R5uN59b8Oco6nvSc4oNoDO3miEM4rJitbnSySSpJWFkVPZEOlTHZLYh6w8RdnL ipIQI0SijUmLEM1TZ+LdgAlDYUpFz6vlQDI23WfcJ+NE1oAYSPB+xkO2+m3O7wdJLOqo Do897VYzZORy/Iby0sJ0/6DZJ61HL0Nnpf9vcegPR2CZ0abKcMSZ9hoirzi+WbHbhHLJ H/EEpaVjTESLuuMG+SbEeSAvJc4zGVYq2YddpPE/+fzVgcMKYRSIvsXrG6/C56aT73g8 gpbPKJh3ATQVASmPXVAJvkpVKffENsxvgh5UnPhJ6mJjBRQ7/EWwnEavRdgOuGof4OIX 0ZIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yJ7r4VJ0GFzUkp84DlniKC/ADesB2+RyryWjunDppAY=; b=wKaDf2BIPJ/ZDa4Gjc1Oq3AGTQRVR7UQeG42gzf8vaaf/wrvhBxhH+FxR1vfctvDE+ 50J9aNmhb9LtX9xOcI+KD3E4xWohuDBxKQpjVmVmqYDAQzrZ66QfEI9tGOzEhp7RfjMo hmRI94pm0HpJE5D01HJJL3YKf3a6fHeqEsbbI3yF/+S1xZidqZqael4n/t3C6PNXmEu0 v64CbDlga5vU1CMWIQCUknZlIIJoG29d5CJCSvZHxMn47HERCPznhYx0xIPyPG77S9Pw +F89LSQEvVoMtLaYjcb2xRX2xGnqS7989Z54RZJXmP/LbTtRVSblda7iQ2Jiq5YfFnbd K2Gw== X-Gm-Message-State: AFqh2kpOtsbSBcGO0OXzBV7dqVsGS8J58qex25p7mT/KRZ2h48Eo99eL aMC6x1UgTU1WGc5kCTPcxw/RnQ== X-Google-Smtp-Source: AMrXdXu6spkhFc1u6USGxG9WJvsK4rqSAtSutoxwGglqpclqT4M1fyXN+pidEm9POsve9oQG7e472A== X-Received: by 2002:a05:6a20:e61a:b0:ac:a4fd:f5bf with SMTP id my26-20020a056a20e61a00b000aca4fdf5bfmr82389323pzb.50.1673307671315; Mon, 09 Jan 2023 15:41:11 -0800 (PST) Received: from google.com (223.103.125.34.bc.googleusercontent.com. [34.125.103.223]) by smtp.gmail.com with ESMTPSA id z7-20020a63e547000000b00476d1385265sm5605289pgj.25.2023.01.09.15.41.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 15:41:10 -0800 (PST) Date: Mon, 9 Jan 2023 15:41:06 -0800 From: David Matlack To: Raghavendra Rao Ananta Cc: Oliver Upton , Marc Zyngier , Ricardo Koller , Reiji Watanabe , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Catalin Marinas , Will Deacon , 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: [RFC PATCH 3/6] KVM: Define kvm_flush_remote_tlbs_range Message-ID: References: <20230109215347.3119271-1-rananta@google.com> <20230109215347.3119271-4-rananta@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230109215347.3119271-4-rananta@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230109_154114_504640_B9DDD851 X-CRM114-Status: GOOD ( 22.62 ) 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, Jan 09, 2023 at 09:53:44PM +0000, Raghavendra Rao Ananta wrote: > Define kvm_flush_remote_tlbs_range() to limit the TLB flush only > to a certain range of addresses. Replace this with the existing > call to kvm_flush_remote_tlbs() in the MMU notifier path. > Architectures such as arm64 can define this to flush only the > necessary addresses, instead of the entire range. > > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/kvm/mmu.c | 10 ++++++++++ > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 7 ++++++- > 3 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 39d9a334efb57..70f76bc909c5d 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -91,6 +91,16 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) > kvm_call_hyp(__kvm_tlb_flush_vmid, &kvm->arch.mmu); > } > > +void kvm_flush_remote_tlbs_range(struct kvm *kvm, unsigned long start, unsigned long end) > +{ > + struct kvm_s2_mmu *mmu = &kvm->arch.mmu; > + > + if (system_supports_tlb_range()) > + kvm_call_hyp(__kvm_tlb_flush_range_vmid_ipa, mmu, start, end, 0); > + else > + kvm_flush_remote_tlbs(kvm); > +} > + > static bool kvm_is_device_pfn(unsigned long pfn) > { > return !pfn_is_map_memory(pfn); > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index f51eb9419bfc3..a76cede9dc3bb 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1359,6 +1359,7 @@ int kvm_vcpu_yield_to(struct kvm_vcpu *target); > void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu, bool usermode_vcpu_not_eligible); > > void kvm_flush_remote_tlbs(struct kvm *kvm); > +void kvm_flush_remote_tlbs_range(struct kvm *kvm, unsigned long start, unsigned long end); > > #ifdef KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE > int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 03e6a38094c17..f538ecc984f5b 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -376,6 +376,11 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) > ++kvm->stat.generic.remote_tlb_flush; > } > EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); > + > +void kvm_flush_remote_tlbs_range(struct kvm *kvm, unsigned long start, unsigned long end) It's ambiguous what start/end represent. Case in point, __kvm_handle_hva_range() is passing in HVAs but then patch 4 passes in GFNs. Probably kvm_flush_tlbs_range() should accept GFN and there can be a helper wrapper that does the HVA-to-GFN conversion. > +{ > + kvm_flush_remote_tlbs(kvm); > +} FYI I also proposed a common kvm_flush_remote_tlbs() in my Common MMU series [1]. Could I interest you in grabbing patches 29-33 from that series, which has the same end result (common kvm_flush_remote_tlbs_range()) but also hooks up the KVM/x86 range-based flushing, and folding them into this series? [1] https://lore.kernel.org/kvm/20221208193857.4090582-33-dmatlack@google.com/ > #endif > > static void kvm_flush_shadow_all(struct kvm *kvm) > @@ -637,7 +642,7 @@ static __always_inline int __kvm_handle_hva_range(struct kvm *kvm, > } > > if (range->flush_on_ret && ret) > - kvm_flush_remote_tlbs(kvm); > + kvm_flush_remote_tlbs_range(kvm, range->start, range->end - 1); > > if (locked) { > KVM_MMU_UNLOCK(kvm); > -- > 2.39.0.314.g84b9a713c41-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel