From patchwork Tue Sep 19 17:41:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13391640 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 2CBBCCE79A9 for ; Tue, 19 Sep 2023 17:42:47 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fKHgAqWEiRQO6U/CyURnpSV9Pwmoo37vRQC8IySKCDw=; b=QNBE0EiaCAjQQu jMDVG2fdbb9soXdrL8tbm5l4805GdhvxCuPXZdCiqOQlLi2fObEowX7n/qOFskxN+NKsSx8gImDor K9HbmschvoxahnlM+phJhyrH48GRpFMPO5Pqf4FtUm6R7V/A481YEfvyxLDdT1U50s0DCeSRwKRTp vevY1pzzOWHIHHd+LvSek9tT0G/DHwU6Van1r+S1nVriGFF7bAELISDVO3VS0p05rRUg65TDRCZXr 0ajs6yLKYHGhgWuHMluXtE7M53EgvwINuyBHJ59PTtkHiYLq5Irjr9eACfPmUEUhRxMqPaqYVIEJC pNfEH/B1dhqy3ZFzJPZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qieju-000xmZ-0i; Tue, 19 Sep 2023 17:42:22 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiej8-000xFM-1h for linux-arm-kernel@lists.infradead.org; Tue, 19 Sep 2023 17:41:36 +0000 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230919_104134_656469_49190347 X-CRM114-Status: GOOD ( 11.95 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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++) {