{"id":2228252,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228252/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260424173151.371134-13-harsimransingh.tungal@arm.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.1/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20260424173151.371134-13-harsimransingh.tungal@arm.com>","date":"2026-04-24T17:31:51","name":"[12/12] efi_loader: align FF-A cache maintenance with runtime path","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"fd43a76bc27927cde11b99ef5dcf17eb342aa887","submitter":{"id":88701,"url":"http://patchwork.ozlabs.org/api/1.1/people/88701/?format=json","name":"Harsimran Singh Tungal","email":"harsimransingh.tungal@arm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260424173151.371134-13-harsimransingh.tungal@arm.com/mbox/","series":[{"id":501471,"url":"http://patchwork.ozlabs.org/api/1.1/series/501471/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=501471","date":"2026-04-24T17:31:50","name":"arm64: FF-A runtime transport for EFI variables","version":1,"mbox":"http://patchwork.ozlabs.org/series/501471/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2228252/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228252/checks/","tags":{},"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256\n header.s=foss header.b=htak67co;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=fail (p=none dis=none) header.from=arm.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=arm.com header.i=@arm.com header.b=\"htak67co\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=none dis=none) header.from=arm.com","phobos.denx.de;\n spf=pass smtp.mailfrom=harsimransingh.tungal@arm.com"],"Received":["from phobos.denx.de (phobos.denx.de\n [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g2yQM41dSz1yHS\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 04:04:27 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 8E9DE844BD;\n\tSat, 25 Apr 2026 20:02:47 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id DC72F842FD; Sat, 25 Apr 2026 19:01:51 +0200 (CEST)","from foss.arm.com (foss.arm.com [217.140.110.172])\n by phobos.denx.de (Postfix) with ESMTP id BBCAE843E0\n for <u-boot@lists.denx.de>; Sat, 25 Apr 2026 19:01:46 +0200 (CEST)","from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 899D135AD;\n Fri, 24 Apr 2026 10:32:52 -0700 (PDT)","from e132995.arm.com (unknown [10.57.64.144])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E5183F7B4;\n Fri, 24 Apr 2026 10:32:56 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,\n DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED,\n SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2","DKIM-Signature":"v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss;\n t=1777051978; bh=+x5wp1lBslfS6w+D+Ltfg462R3eeWTvGEJtTeAHd7Is=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=htak67coacowwD4/k6Zl6g35bFsXrIdxeT+dhMlgQosineUhvvfhHJBerss1EsCTW\n DNGGlgj+AVR8rnp4n6g27Hgt29dHU0nWO3JoqF/VmeJ3rCrtRY6Tq5Jb+xj9W3PlKX\n P+kQbv0aJ/WD0/P1UvyXyMRemuhruLWgUakt3pj4=","From":"Harsimran Singh Tungal <harsimransingh.tungal@arm.com>","To":"u-boot@lists.denx.de","Cc":"Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>,\n Tom Rini <trini@konsulko.com>,\n Ilias Apalodimas <ilias.apalodimas@linaro.org>,\n Heinrich Schuchardt <xypron.glpk@gmx.de>,\n Hugues Kamba Mpiana <hugues.kambampiana@arm.com>,\n Simon Glass <sjg@chromium.org>,\n Harsimran Singh Tungal <harsimransingh.tungal@arm.com>","Subject":"[PATCH 12/12] efi_loader: align FF-A cache maintenance with runtime\n path","Date":"Fri, 24 Apr 2026 18:31:51 +0100","Message-Id":"<20260424173151.371134-13-harsimransingh.tungal@arm.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20260424173151.371134-1-harsimransingh.tungal@arm.com>","References":"<20260424173151.371134-1-harsimransingh.tungal@arm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Mailman-Approved-At":"Sat, 25 Apr 2026 20:02:44 +0200","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"Match boot-time FF-A cache handling to runtime behavior\n\nThe boot-time FF-A MM communication path used invalidate_dcache_all()\nafter copying the message into the shared buffer. This differs from the\nruntime path, which performs range-based maintenance to avoid global cache\noperations.\n\nUpdate ffa_mm_communicate() to use the same pattern as the runtime helper:\nclean the shared buffer range before the SMC and invalidate the same range\nafter the response. This keeps boot-time and runtime behavior consistent\nand avoids whole-cache invalidation.\n\nSigned-off-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>\nSigned-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>\n---\n lib/efi_loader/efi_variable_tee.c | 33 ++++++++++++++++++++++++-------\n 1 file changed, 26 insertions(+), 7 deletions(-)","diff":"diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c\nindex 30687c21b8e..df509a435b1 100644\n--- a/lib/efi_loader/efi_variable_tee.c\n+++ b/lib/efi_loader/efi_variable_tee.c\n@@ -389,19 +389,38 @@ static efi_status_t ffa_mm_communicate(void *comm_buf, ulong comm_buf_size)\n \tmemcpy(virt_shared_buf, comm_buf, tx_data_size);\n \n \t/*\n-\t * The secure world might have cache disabled for\n-\t * the device region used for shared buffer (which is the case for Optee).\n-\t * In this case, the secure world reads the data from DRAM.\n-\t * Let's flush the cache so the DRAM is updated with the latest data.\n+\t * Shared buffer cache maintenance for FF-A / OP-TEE communication:\n+\t *\n+\t * NS -> S (request path):\n+\t *\n+\t * The non-secure side populates the shared buffer. If the buffer is cached\n+\t * in NS, the updated bytes may reside in dirty D-cache lines and not yet be\n+\t * visible in DDR. Since the secure world typically reads the shared buffer\n+\t * directly from DDR (e.g. with caches disabled / non-coherent mapping), we\n+\t * must clean the corresponding cache lines to the Point of Coherency (PoC)\n+\t * before entering secure world.\n+\t *\n+\t * S -> NS (response path):\n+\t *\n+\t * The secure world may update the same shared buffer in DDR. After returning\n+\t * to non-secure, any cached copies of that region in NS may be stale. We\n+\t * therefore invalidate the shared buffer range after the FF-A call to drop\n+\t * those lines and force subsequent reads to fetch the latest data from DDR.\n \t */\n-#ifdef CONFIG_ARM64\n-\tinvalidate_dcache_all();\n-#endif\n+\tif (IS_ENABLED(CONFIG_ARM64))\n+\t\tflush_dcache_range((unsigned long)virt_shared_buf,\n+\t\t\t\t   (unsigned long)virt_shared_buf +\n+\t\t\t\t   CONFIG_FFA_SHARED_MM_BUF_SIZE);\n \n \t/* Announce there is data in the shared buffer */\n \n \tffa_ret = ffa_notify_mm_sp();\n \n+\tif (IS_ENABLED(CONFIG_ARM64))\n+\t\tinvalidate_dcache_range((unsigned long)virt_shared_buf,\n+\t\t\t\t\t(unsigned long)virt_shared_buf +\n+\t\t\t\t\tCONFIG_FFA_SHARED_MM_BUF_SIZE);\n+\n \tswitch (ffa_ret) {\n \tcase 0: {\n \t\tulong rx_data_size;\n","prefixes":["12/12"]}