Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3221597rwd; Mon, 29 May 2023 07:22:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4L2xtigHtwHr0YD6CoRzHpuV4KXgPrQk/6YJsCAfojQv/UxgzIPHm6QR1AtMNTJ1clTFq5 X-Received: by 2002:a05:6a00:4ace:b0:64d:284e:f309 with SMTP id ds14-20020a056a004ace00b0064d284ef309mr8152099pfb.8.1685370149738; Mon, 29 May 2023 07:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685370149; cv=none; d=google.com; s=arc-20160816; b=PtNs5rYInlztXLDWl5jKBYXBREuCosLBV94GdUaLYXbjqqNtr4jFCxCVPjRRmnHgm3 uWt9gIjcVc6VAsJ9XchbhpZgGJb9dhpLdXwxqBrF6vSUX/Cf8GDHriiWB6CQiVPiKNEt rn5zux+V9Pz9vrddRa7+FVtM9Vassttbv5Q2DwNLFY8ceDZLrGjJQCO0DP7f0eXKvkMG QnR+B9BOXQbG1PpPaOiDLY9ewqZhJcfRkB3dm8kLjPp8Gx6yyhs2wLMY1Zx+4wqwKkmB kwkQ75OovmMaq+wqEYYabYEaZoUwn0+uzsQ/AkVnYLJ6iJvLD4fWIuXpMYZoQ0PdCnT6 gpsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=ATG0O9Tpl/Ay3iS5MC9vf83cvhP2xwZwkz2oXqL5HWg=; b=H/wXFhJay1gFddFnXc/zXkpepiN0urLShkApnze4MtPB61Msw9Hqlw3Gyq6emnJb3b jyQ3Nb9AAPLTHutDYYy1PPD0z/GL4BMHm/K6bEnw696VaOkGs6OifOyl/CeWuZjlAwxs 37AfBK4R18NUA7jWGAPouIpRIc0aLQWpTWZhi/ScYutZ1KE7J3mCpNYu1jaaGKYEzpKk DAr/W6/OLO14r1gAHzROIHwRl8k4XgAqOv4Ld9jUe9o377ZtI5ZLFmwlITv+AgFD2PRG WGFHmIQ2fs3K/71gi6VtRH4pQYSlrufjoiGAaL2XvFMHGlxDBSU35HxPg2VWh1WvVEtQ UCew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WbYjX4Zw; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a633407000000b00518cf8916e2si9681341pga.415.2023.05.29.07.22.16; Mon, 29 May 2023 07:22:29 -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=@kernel.org header.s=k20201202 header.b=WbYjX4Zw; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230132AbjE2OBU (ORCPT + 99 others); Mon, 29 May 2023 10:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjE2OBQ (ORCPT ); Mon, 29 May 2023 10:01:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 537E010D; Mon, 29 May 2023 07:00:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E9AB860FBB; Mon, 29 May 2023 14:00:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ECFAC4339B; Mon, 29 May 2023 14:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685368831; bh=XTBuiKvnDD+l/iubLGvNKu/2fkBSZnZrXeAb5inRLRI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WbYjX4Zwsf0EAitGQnaZHT6xoQMhz2CsSKVLKNYcfvdNl2loHnXayL4CryrhtohjM SpaAVrn7JVYf2ozdw6dE/lwZdpjMWrowHOiuX1w+bF+WwmYjqxdkAvYIj6gkqr+MqG EXfaFHunYOy1xVQlObW/54+2rM2M5CFFZRgKdgVGGtpJcePAw9aai4fITNNOC8/DJd X9AQ8oxQWYxkkj3ESzIjt6snYhfMlq3d5RDq6+3KYTZIce51/nDLmV4JuxP/od+AwL QSMztInsXC3XRah1c0265NbpPdovFjcrXyqiCYsoSavLX+Ld9plUsfzIrLosxu3KuU Itv1sMk/Iek3g== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q3dQD-001581-2d; Mon, 29 May 2023 15:00:29 +0100 Date: Mon, 29 May 2023 15:00:28 +0100 Message-ID: <87v8gbjkzn.wl-maz@kernel.org> From: Marc Zyngier To: Raghavendra Rao Ananta Cc: Oliver Upton , James Morse , Suzuki K Poulose , Ricardo Koller , Paolo Bonzini , 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 v4 3/6] KVM: arm64: Implement kvm_arch_flush_remote_tlbs_range() In-Reply-To: <20230519005231.3027912-4-rananta@google.com> References: <20230519005231.3027912-1-rananta@google.com> <20230519005231.3027912-4-rananta@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: rananta@google.com, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, ricarkol@google.com, pbonzini@redhat.com, jingzhangos@google.com, coltonlewis@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,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 Fri, 19 May 2023 01:52:28 +0100, Raghavendra Rao Ananta wrote: > > Implement kvm_arch_flush_remote_tlbs_range() for arm64 > to invalidate the given range in the TLB. > > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/include/asm/kvm_host.h | 3 +++ > arch/arm64/kvm/hyp/nvhe/tlb.c | 4 +--- > arch/arm64/kvm/mmu.c | 11 +++++++++++ > 3 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 81ab41b84f436..343fb530eea9c 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1081,6 +1081,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/hyp/nvhe/tlb.c b/arch/arm64/kvm/hyp/nvhe/tlb.c > index d4ea549c4b5c4..d2c7c1bc6d441 100644 > --- a/arch/arm64/kvm/hyp/nvhe/tlb.c > +++ b/arch/arm64/kvm/hyp/nvhe/tlb.c > @@ -150,10 +150,8 @@ void __kvm_tlb_flush_vmid_range(struct kvm_s2_mmu *mmu, > return; > } > > - dsb(ishst); > - > /* Switch to requested VMID */ > - __tlb_switch_to_guest(mmu, &cxt); > + __tlb_switch_to_guest(mmu, &cxt, false); This hunk is in the wrong patch, isn't it? > > __flush_tlb_range_op(ipas2e1is, start, pages, stride, 0, 0, false); > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index d0a0d3dca9316..e3673b4c10292 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -92,6 +92,17 @@ 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; > + > + start = start_gfn << PAGE_SHIFT; > + end = (start_gfn + pages) << PAGE_SHIFT; > + > + kvm_call_hyp(__kvm_tlb_flush_vmid_range, &kvm->arch.mmu, start, end); So that's the point that I think is not right. It is the MMU code that should drive the invalidation method, and not the HYP code. The HYP code should be as dumb as possible, and the logic should be kept in the MMU code. So when a range invalidation is forwarded to HYP, it's a *valid* range invalidation. not something that can fallback to VMID-wide invalidation. Thanks, M. -- Without deviation from the norm, progress is not possible.