Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2496961rdb; Wed, 4 Oct 2023 03:08:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmmkWfm5N/jDL1KZ+0Bnkmg1vxGoGMTuMewrIAUtd82hjEOVcsqs/Qfgf94g7SGB4lGNB2 X-Received: by 2002:a05:6a00:3a02:b0:68f:ece2:ac2a with SMTP id fj2-20020a056a003a0200b0068fece2ac2amr1978524pfb.27.1696414119736; Wed, 04 Oct 2023 03:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696414119; cv=none; d=google.com; s=arc-20160816; b=VoKvkIkiuBhP5IOGP9aYk6XYIysPD8PMVD42ijm1N/WRcgOzHEfk7+Zeeq3EuBt6Mc wwabo1s4oeOhW/O8hfEMQYltfV5rBc3SFdVo1vQ6bi3EsePnsqvK+Qe8TePNG0Sqd8aU 0q+8b7LKNFQHK5ukjHfRuet6cmi2908caTyam9MreIBTEknwo4bRfckt+yS2ZjiiGfAf x+PifGCq7xsqMPRZADR0I9g0e32JiV0DA7CSv1osM5hQdrHhw9ZeXaDzDATb8VfCWlPq P0vcGCb8H3iFrTzGXnKMkCwGVRffZdJkIVm9oOPXEoqqv+s6R/ETgJcWIhDKjKlhAEC+ g0bQ== 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=PS3IIPl/TBeih8n9ZjdQCXM2/xLtPERjdI1nqsRsWvY=; fh=doE3cohm9qieao8///P11DI06Iru1zfEseUXHC2o4GA=; b=SFXUcEgf/IJP2/P/3hglkmUtp3Daub+u2zljgLzoOx45oWKSLnL4KVG8uJIeAgCKjS 0FGn3EA/LXoDZ4+TjkCHSUrrB/wfVrg7RUoW1Qu/BqDwZS0Vb5sHFAu63VT3Bq9wLENk a0ZugCorIAHA1pdF7x5cdE/y+IM8/1MJX+Zh5lJznLKNaXHi46hAixLg8jY42+fTLOGK PyfWEJI8l0OR8NmYP8TOdve16X/dokfkm+8M0AHbMIuBQIO6NE4fkGfh+yvcAtwidOha hjHgLSKLS+V8xEVYbswIDPuu/DCJZUgPuU22zKk+Qv7+VB/r3WwHo1c9rM/XsrFU4MHS vUew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XLoXlDhR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c186-20020a6335c3000000b00578e1e96ea9si3632827pga.146.2023.10.04.03.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 03:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XLoXlDhR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D879081A0C18; Wed, 4 Oct 2023 03:08:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232887AbjJDKIa (ORCPT + 99 others); Wed, 4 Oct 2023 06:08:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232746AbjJDKI3 (ORCPT ); Wed, 4 Oct 2023 06:08:29 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483F083 for ; Wed, 4 Oct 2023 03:08:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C75C7C433C7; Wed, 4 Oct 2023 10:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696414105; bh=6qYp2LojNwwY4f+xcvEJJ2LuWLAJTtJzHufvOhFm4/w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XLoXlDhR9ul8ZdEa9doNURyGHAVujrshxTfWf5blahBr9mLLkLXB5SIi3hovPQ5tR U+AZ1nb5JChZKwrFRnB0HA8Ao41WMlG6DoJ+N186slwsM0JNkUjyNYL5m2ZBLqHbAn dTvc8LaIGN+MTE/k3NAUI465+hJfVZcBsZnSbx1LuIiWw5MKWi4dRQI9ZoLjMFfs8v QePWLKw+hlohM2vusVmniLK8kI7zBjiPQz2uYgC0Y/7x1xd2V93Nzq7/p23oD+9Guj KiN8OQT92J4ALOEvvl/spLDsCdVurpchZ46MNxd3q0pq1IqGlMEk24ZO82oqvjUV9v +/mQ0qWF22Arw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1qnynn-0010u0-Ca; Wed, 04 Oct 2023 11:08:23 +0100 Date: Wed, 04 Oct 2023 11:08:23 +0100 Message-ID: <86leciog2w.wl-maz@kernel.org> From: Marc Zyngier To: Sudeep Holla Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Bonnici , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez , Oliver Upton , Will Deacon , Quentin Perret Subject: Re: [PATCH v3 14/17] KVM: arm64: FFA: Remove access of endpoint memory access descriptor array In-Reply-To: <20230929-ffa_v1-1_notif-v3-14-c8e4f15190c8@arm.com> References: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> <20230929-ffa_v1-1_notif-v3-14-c8e4f15190c8@arm.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/29.1 (aarch64-unknown-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: sudeep.holla@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, marc.bonnici@arm.com, jens.wiklander@linaro.org, coboy.chen@mediatek.com, lpieralisi@kernel.org, olivier.deprez@arm.com, oliver.upton@linux.dev, will@kernel.org, qperret@google.com 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=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 04 Oct 2023 03:08:37 -0700 (PDT) On Fri, 29 Sep 2023 16:03:03 +0100, Sudeep Holla wrote: > > FF-A v1.1 removes the fixed location of endpoint memory access descriptor > array within the memory transaction descriptor structure. In preparation > to remove the ep_mem_access member from the ffa_mem_region structure, > provide the accessor to fetch the offset and use the same in FF-A proxy > implementation. > > The accessor take the boolean argument that indicates if the memory access > descriptor versions is v1(old format) or not. Currently it is set true as > FF-A proxy supports only v1.0 > > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: Will Deacon > Cc: Quentin Perret > Signed-off-by: Sudeep Holla > --- > arch/arm64/kvm/hyp/nvhe/ffa.c | 8 ++++++-- > include/linux/arm_ffa.h | 6 ++++++ > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > index 6e4dba9eadef..5f956f53e6bf 100644 > --- a/arch/arm64/kvm/hyp/nvhe/ffa.c > +++ b/arch/arm64/kvm/hyp/nvhe/ffa.c > @@ -423,6 +423,7 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id, > DECLARE_REG(u32, fraglen, ctxt, 2); > DECLARE_REG(u64, addr_mbz, ctxt, 3); > DECLARE_REG(u32, npages_mbz, ctxt, 4); > + struct ffa_mem_region_attributes *ep_mem_access; > struct ffa_composite_mem_region *reg; > struct ffa_mem_region *buf; > u32 offset, nr_ranges; > @@ -452,7 +453,8 @@ static __always_inline void do_ffa_mem_xfer(const u64 func_id, > buf = hyp_buffers.tx; > memcpy(buf, host_buffers.tx, fraglen); > > - offset = buf->ep_mem_access[0].composite_off; > + ep_mem_access = (void *)buf + ffa_mem_desc_offset(buf, 0, true); > + offset = ep_mem_access->composite_off; > if (!offset || buf->ep_count != 1 || buf->sender_id != HOST_FFA_ID) { > ret = FFA_RET_INVALID_PARAMETERS; > goto out_unlock; > @@ -504,6 +506,7 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res, > DECLARE_REG(u32, handle_lo, ctxt, 1); > DECLARE_REG(u32, handle_hi, ctxt, 2); > DECLARE_REG(u32, flags, ctxt, 3); > + struct ffa_mem_region_attributes *ep_mem_access; > struct ffa_composite_mem_region *reg; > u32 offset, len, fraglen, fragoff; > struct ffa_mem_region *buf; > @@ -528,7 +531,8 @@ static void do_ffa_mem_reclaim(struct arm_smccc_res *res, > len = res->a1; > fraglen = res->a2; > > - offset = buf->ep_mem_access[0].composite_off; > + ep_mem_access = (void *)buf + ffa_mem_desc_offset(buf, 0, true); > + offset = ep_mem_access->composite_off; > /* > * We can trust the SPMD to get this right, but let's at least > * check that we end up with something that doesn't look _completely_ > diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h > index 748d0a83a4bc..7be240e37f36 100644 > --- a/include/linux/arm_ffa.h > +++ b/include/linux/arm_ffa.h > @@ -357,6 +357,12 @@ struct ffa_mem_region { > #define CONSTITUENTS_OFFSET(x) \ > (offsetof(struct ffa_composite_mem_region, constituents[x])) > > +static inline u32 > +ffa_mem_desc_offset(struct ffa_mem_region *buf, int count, bool mem_desc_v1) > +{ > + return COMPOSITE_OFFSET(0); > +} If the goal of this patch is to introduce some versioning, why not define this last parameter as an actual version number, PSCI style (with a minor and major, each on a 16bit field)? Even the name is pretty misleading, as both FFA versions are v1 (v1.0 vs v1.1...). Thanks, M. -- Without deviation from the norm, progress is not possible.