Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp459024rdb; Fri, 6 Oct 2023 08:25:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbnvK7xMccMdmKj+bBOQiU6e3dpinf1HA23ko9h6COazHTvvB2irBa7sXqVHBFBvhnNuIm X-Received: by 2002:a05:6a00:a92:b0:690:422f:4f17 with SMTP id b18-20020a056a000a9200b00690422f4f17mr9544086pfl.4.1696605944782; Fri, 06 Oct 2023 08:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696605944; cv=none; d=google.com; s=arc-20160816; b=civqGf6jL2XxRET3Egkv527F3rI3N+vh6eFYcbCtiTztVF+VL6/1C+CMiZPNvchMZZ Sn/CQWw6BJd1QXlN+sQubqpUJNRssXakUt/wGzJcJo5SQJjs448xyCkgF5xTGO9cxNTn RgizYGpfCmfR9jd3rXwmjhWncpXzozCzieZuWhO6naV/6UWdHLvuJd4YCBcIJceX+9R6 ol1mBdO1OsnmHpoWI3l6G7oqDvEu+o6DfCvB1WdJnd88lBjtVFjVLl5fmrx0KNUqdf4D ZgE+NSCPO97yWVhbL9tgWjxcxLcHrcrpHFr1NDro8CKHfzBGdzatlTS2XtoWwL3+FAPj V7dQ== 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:date; bh=+MqEK65xvK806bfyL3AII0p1Vrm9WW8s4y2yAuw/VRs=; fh=OpkS4bzU6O5FUVQuJWCry3s0h2oG7pMQcipNNO1hM8c=; b=Kb9fi56zf54YidKvhBrxpI4D0WJa/NKO/JmNo1tNcBrtQ4XUt5S3t2i3JdTuqIDhB7 2UXh0mw6Teg9ZjJZQIpE2LTzUlwTXyNVuHA/YGwMrhH+8bx088GT6C0/k7qTO3rQcwTP FkIHfVLK5RxzigJ1GXln2j3T2pJZDYyPce2r+HNLojOHXJ8Ze4z60X+lHabTUJ9VgXX1 Z2JW1Mi6G1NPa2xFQb1lkyxLRZ+XYzbnaJ0dcdGBM8S3FLejjUNrUiyf2cx6YvHqqey0 QpkjbPtqf4h8B46f8hj7ywNwpGizRzCH66XyQTAi7JxSmSmP0i+IoKrsCnceZFO2nsEU hi2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q4-20020a056a00088400b0068fcc3406acsi1752694pfj.141.2023.10.06.08.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 08:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AF49180968AD; Fri, 6 Oct 2023 08:25:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232750AbjJFPZb (ORCPT + 99 others); Fri, 6 Oct 2023 11:25:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbjJFPZa (ORCPT ); Fri, 6 Oct 2023 11:25:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 975F89C for ; Fri, 6 Oct 2023 08:25:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5A401C15; Fri, 6 Oct 2023 08:26:07 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9AC943F5A1; Fri, 6 Oct 2023 08:25:26 -0700 (PDT) Date: Fri, 6 Oct 2023 16:25:24 +0100 From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , Will Deacon Cc: Oliver Upton , Marc Bonnici , Sudeep Holla , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez , Quentin Perret Subject: Re: [PATCH v4 14/17] KVM: arm64: FFA: Remove access of endpoint memory access descriptor array Message-ID: <20231006152524.revw6utl5zezffgr@bogus> References: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> <20231005-ffa_v1-1_notif-v4-14-cddd3237809c@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231005-ffa_v1-1_notif-v4-14-cddd3237809c@arm.com> X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 06 Oct 2023 08:25:41 -0700 (PDT) X-Spam-Level: ** On Thu, Oct 05, 2023 at 03:45:07PM +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 FF-A version as the argument from which the memory > access descriptor format can be determined. v1.0 uses the old format while > v1.1 onwards use the new format specified in the v1.1 specification. > > Cc: Marc Zyngier > Cc: Oliver Upton > Cc: Will Deacon > Cc: Quentin Perret > Signed-off-by: Sudeep Holla > --- > arch/arm64/kvm/hyp/nvhe/ffa.c | 10 ++++++++-- > include/linux/arm_ffa.h | 6 ++++++ > 2 files changed, 14 insertions(+), 2 deletions(-) > Hi Marc, Does this look better with respect to FF-A version passed as parameter. Since this case needs both major and minor(to handle difference between v1.0 and v1.1), I am passing the full version(both major and minor) in the compact form. If you happy, please ack. I would like to take it with other FF-A changes. Regards, Sudeep > diff --git a/arch/arm64/kvm/hyp/nvhe/ffa.c b/arch/arm64/kvm/hyp/nvhe/ffa.c > index 6e4dba9eadef..320f2eaa14a9 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,9 @@ 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, FFA_VERSION_1_0); > + 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 +507,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 +532,9 @@ 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, FFA_VERSION_1_0); > + 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..2444d596b703 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, u32 ffa_version) > +{ > + return COMPOSITE_OFFSET(0); > +} > + > struct ffa_mem_ops_args { > bool use_txbuf; > u32 nattrs; > > -- > 2.42.0 > -- Regards, Sudeep