Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp809610rdb; Tue, 19 Sep 2023 10:43:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGFhYNTlq1Ymvz8EG1G9c75JxKpQ0k6IQdTVdxesGhYh1sBVrVc04HKU94GDzpXenLAiTIe X-Received: by 2002:a17:90a:4a88:b0:274:99e8:1670 with SMTP id f8-20020a17090a4a8800b0027499e81670mr404130pjh.43.1695145416226; Tue, 19 Sep 2023 10:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695145416; cv=none; d=google.com; s=arc-20160816; b=ZfM5yy2RzfgQwtq88wo8qnW/wUWtMwTeUhixREs+l/mhr5ox41OklmL3CF46PI90Jn a9jia6/H9yFqBk4q9eVCG+5vWEZyLdB9Edk8vWNYgjcYTJstrtxtxyq4wMoEkk6Q4PcC 5kmiGd2BikATKHeodDhMb6dAEHIuwwj9SScrjFDu6ztZiUTP1mwer4NaDL2QCRYLZh7I btjG9IdInhWRWBdcbWvvH+rD1SGENRSpzmknhxx7oDq3KeouEZ9A9IgSIL6CcLepM2ep t2bHccBk9djyyOYlp38y+N4+ZrQE2hhXLMmcM6scGgYSNeurn1WZJ7hVF+XAzJ3e1Bf3 7XVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=8PD85chY99lMClL6FU3j7j6VxdIeKqMMRdnwnUAPw+M=; fh=MciVbPIBCtHAdIelLZxIOy7BiqudBAAto0Kp3PnUEyU=; b=NLsmfv1lV+QKAcaon94/gCL2dcK4U+DWkvarGSLTw5hB6TotmIsKVaMnMyCEnfJj4u ulfVIk4ULysqsC65A9x/xz2Z4VXebISQMjOTN5NktOHlP6TUZbRGCZ+dsorwpvn/zUoi VA8xvxx13sR30ZbBlaqmxmF3xqdBDvucuU7fIRnFeLQJqIn1tij88M9J8Z6eGXUhxiqD /R2DZv04WqMVZ6CBo5WY61nGQw9N3D1gHZJWFYeJgdqo+J/N+k5PXdMhrjREFm3W25H8 E7Ij61m7d454VYPTQihQV8t5GORCQYwFY5Mlzs83y28+mQQGj6TqOGRDuilSXWGymDXn fcxw== 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 mi15-20020a17090b4b4f00b00274b944508fsi6744242pjb.39.2023.09.19.10.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 10:43:36 -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 E91D6827040A; Tue, 19 Sep 2023 10:42:23 -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 S232613AbjISRmK (ORCPT + 99 others); Tue, 19 Sep 2023 13:42:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232359AbjISRlv (ORCPT ); Tue, 19 Sep 2023 13:41:51 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 701C5188 for ; Tue, 19 Sep 2023 10:41:34 -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 748B01FB; Tue, 19 Sep 2023 10:42:11 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F3E53F5A1; Tue, 19 Sep 2023 10:41:32 -0700 (PDT) From: Sudeep Holla Date: Tue, 19 Sep 2023 18:41:01 +0100 Subject: [PATCH RFT v2 13/18] firmware: arm_ffa: Don't set the memory region attributes for MEM_LEND MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230919-ffa_v1-1_notif-v2-13-6f3a3ca3923c@arm.com> References: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> In-Reply-To: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Jens Wiklander , Marc Bonnici , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez Cc: Joao Alves X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2038; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ZvoeIZd0Pqo3Ya9dsPGQ9xQvguOm3+9Cq7nXLi0CZSc=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlCd08kfIH+2N9tA2KqxNb8BJD9kXW6U1ibgai8 /fPN9BWhQeJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZQndPAAKCRAAQbq8MX7i mHf8EADWH21kGXFn2PLOkKMHCj83izRmm0b2DUKYAsLKj4jJSST/rdIujthnRARnmB/nKDcZbdr Wvmh6N77r5wlkLC6FHpUZZp10ILr7UyOupPEYPGvIPAaqUgaV8QfNRThMi0Tpz8CwWHGuCbDcIv LbYtc2XNQZHZVxb6fc00xhL/PXm0AiZ9HsHDsee5/wpxgB0xeyuWaCQHU8iUz3kMhLcxscSNM0x UCTtORQyk1gSInclvs74EKXZGySvUFtvbBwFvTYtld1xa6AY3dj8K1wxwjT0au363Rm6r4edYmR v6iSod8M95u35u/ykWZm1ycnWP5roZLQsXmvHH9SJS1vAC22oS37WTbfck0TvqiX3XlQYtRyjLg ackRNeRo8TWQvnw0beQygG/E510kwtQnRMhFQ0GkZBhzXQ9PtVX7kf5yh2sRm5/0ooXTP0mHa6U GyrLpGDjQb3SNNvreg0VzJZHWMeApNWM4E///nBGkxRNvTRkHog3xN5oM9vCZOVj4sjCa6VvTd5 SXnUnRSLdyIY5aVXBVzA7butjib9HvzW9HWFWT7sMJ+93xCDba6VsH4oZE9dMRonI1ozI4Eie0z 02bX1a3yZBtvp0wRljViU9nfor4vaJIyTM43HBb/r+F/AuyfBs6bwlAmT/OVkgZ+Yt7aed2Nbao d/FO/NqGhE8GZHQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 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]); Tue, 19 Sep 2023 10:42:24 -0700 (PDT) As per the FF-A specification: section "Usage of other memory region attributes", in a transaction to donate memory or lend memory to a single borrower, if the receiver is a PE or Proxy endpoint, the owner must not specify the attributes and the relayer will return INVALID_PARAMETERS if the attributes are set. Let us not set the memory region attributes for MEM_LEND. Fixes: 82a8daaecfd9 ("firmware: arm_ffa: Add support for MEM_LEND") Reported-by: Joao Alves Reported-by: Olivier Deprez Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8a5b5c274bb9..6312a7807d37 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -424,6 +424,19 @@ static u32 ffa_get_num_pages_sg(struct scatterlist *sg) return num_pages; } +static u8 ffa_memory_attributes_get(u32 func_id) +{ + /* + * For the memory lend or donate operation, if the receiver is a PE or + * a proxy endpoint, the owner/sender must not specify the attributes + */ + if (func_id == FFA_FN_NATIVE(MEM_LEND) || + func_id == FFA_MEM_LEND) + return 0; + + return FFA_MEM_NORMAL | FFA_MEM_WRITE_BACK | FFA_MEM_INNER_SHAREABLE; +} + static int ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, struct ffa_mem_ops_args *args) @@ -440,8 +453,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, mem_region->tag = args->tag; mem_region->flags = args->flags; mem_region->sender_id = drv_info->vm_id; - mem_region->attributes = FFA_MEM_NORMAL | FFA_MEM_WRITE_BACK | - FFA_MEM_INNER_SHAREABLE; + mem_region->attributes = ffa_memory_attributes_get(func_id); ep_mem_access = &mem_region->ep_mem_access[0]; for (idx = 0; idx < args->nattrs; idx++, ep_mem_access++) { -- 2.42.0