{"id":2228251,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2228251/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260424173151.371134-8-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-8-harsimransingh.tungal@arm.com>","date":"2026-04-24T17:31:46","name":"[07/12] efi: selftest: add runtime variable tests with non-volatile storage","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e96501306365d8a446faa1417eb856cee3418a35","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-8-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/2228251/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2228251/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=bc4DKhlp;\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=\"bc4DKhlp\";\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 4g2yQ93Wdzz1yHS\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 26 Apr 2026 04:04:17 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 54AC5844AF;\n\tSat, 25 Apr 2026 20:02:47 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id 2F18D840AB; 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 A749E84399\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 6852335A7;\n Fri, 24 Apr 2026 10:32:43 -0700 (PDT)","from e132995.arm.com (unknown [10.57.64.144])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3089D3F7B4;\n Fri, 24 Apr 2026 10:32:47 -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=1777051968; bh=ohciqUgHTHvcL0AYdIA2fuLaaejikD+o8or3qyqI5GE=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=bc4DKhlpPSmp+lEAbf5eTLwAbk2YoiGhIK2/q7KxBFw44JTAHnlHVhAtCNg1DwpFz\n a8AbM0ckFE00SChI5K56I7H02FQoMidxS2gYMgqqGsj+rxSs7Iz3g5cvpEnISsmyQa\n FlOFXq9HqCOWbn6ZCTav6FUzVMFBkvkp7qFl/zfA=","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 07/12] efi: selftest: add runtime variable tests with\n non-volatile storage","Date":"Fri, 24 Apr 2026 18:31:46 +0100","Message-Id":"<20260424173151.371134-8-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":"Extend runtime variable tests for persistent storage\n\nPreviously, EFI selftesting of runtime variables was only supported\nunder CONFIG_EFI_RT_VOLATILE_STORE, which uses VarToFile to simulate\nnon-volatile variable storage. This commit adds new test cases that\nexercise runtime variable operations for persistent storage.\n\nFeatures tested:\n- Creation of runtime-accessible variables (set)\n- Retrieval of runtime variables (get)\n- Deletion using SetVariable() with size = 0\n- Append operation using EFI_VARIABLE_APPEND_WRITE\n\nThis improves EFI compliance validation for non-volatile runtime storage\nscenarios and ensures proper attribute enforcement and variable\nmanagement.\n\nSigned-off-by: Harsimran Singh Tungal <harsimransingh.tungal@arm.com>\n---\n .../efi_selftest_variables_runtime.c          | 106 +++++++++++++++++-\n 1 file changed, 104 insertions(+), 2 deletions(-)","diff":"diff --git a/lib/efi_selftest/efi_selftest_variables_runtime.c b/lib/efi_selftest/efi_selftest_variables_runtime.c\nindex fd570d673f0..9a7ab18bc90 100644\n--- a/lib/efi_selftest/efi_selftest_variables_runtime.c\n+++ b/lib/efi_selftest/efi_selftest_variables_runtime.c\n@@ -3,6 +3,7 @@\n  * efi_selftest_variables_runtime\n  *\n  * Copyright (c) 2019 Heinrich Schuchardt <xypron.glpk@gmx.de>\n+ * Copyright (c) 2026 Arm Limited and/or its affiliates <open-source-office@arm.com>\n  *\n  * This unit test checks the runtime services for variables after\n  * ExitBootServices():\n@@ -22,7 +23,13 @@ static const efi_guid_t efi_rt_var_guid = U_BOOT_EFI_RT_VAR_FILE_GUID;\n /**\n  * execute() - execute unit test\n  *\n- * As runtime support is not implmented expect EFI_UNSUPPORTED to be returned.\n+ * For EFI variables in non-volatile storage, these tests have to be executed in two phases\n+ * 1. During first phase, run these tests and it creates EFI variable in persistent storage.\n+ * 2. Then reboot and run the test again to verify if the variable created above is still\n+ *    available in non-volatile storage. If available, validate the EFI variable, append\n+ *    it, and validate it again. If validation is successful, delete the same variable.\n+ *\n+ * Return: EFI_ST_SUCCESS on success, EFI_ST_FAILURE on failure\n  */\n static int execute(void)\n {\n@@ -39,6 +46,80 @@ static int execute(void)\n \tu64 max_storage, rem_storage, max_size;\n \tint test_ret;\n \n+\t/* Compare the value of EFI variable if it already exists in non volatile storage */\n+\tif (!IS_ENABLED(CONFIG_EFI_RT_VOLATILE_STORE)) {\n+\t\tlen = sizeof(v) / 2;\n+\t\tret = st_runtime->get_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t&attr, &len, data);\n+\t\tif (ret == EFI_SUCCESS) {\n+\t\t\tefi_st_printf(\"EFI Variable efi_st_var0 found. Executing Second Phase\\n\");\n+\t\t\tif (len != sizeof(v) / 2) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\t\t\tif (memcmp(data, v, len)) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\t/* Append an existing variable */\n+\t\t\tappend_len = sizeof(v) - len;\n+\t\t\tret = st_runtime->set_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t\t    EFI_VARIABLE_BOOTSERVICE_ACCESS |\n+\t\t\t\t\t\t    EFI_VARIABLE_RUNTIME_ACCESS |\n+\t\t\t\t\t\t    EFI_VARIABLE_APPEND_WRITE |\n+\t\t\t\t\t\t    EFI_VARIABLE_NON_VOLATILE,\n+\t\t\t\t\t\t    append_len, (v + len));\n+\t\t\tif (ret != EFI_SUCCESS) {\n+\t\t\t\tefi_st_error(\"SetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\tlen = sizeof(v);\n+\t\t\tret = st_runtime->get_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t&attr, &len, data);\n+\t\t\tif (ret != EFI_SUCCESS) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\tif (len != sizeof(v)) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\tif (memcmp(data, v, len)) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\t/* Delete it by setting the size to 0 */\n+\t\t\tret = st_runtime->set_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t\t    EFI_VARIABLE_BOOTSERVICE_ACCESS |\n+\t\t\t\t\t\t    EFI_VARIABLE_RUNTIME_ACCESS |\n+\t\t\t\t\t\t    EFI_VARIABLE_NON_VOLATILE,\n+\t\t\t\t\t\t    0, NULL);\n+\t\t\tif (ret != EFI_SUCCESS) {\n+\t\t\t\tefi_st_error(\"SetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\tret = st_runtime->get_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t&attr, &len, data);\n+\t\t\tif (ret != EFI_NOT_FOUND) {\n+\t\t\t\tefi_st_error(\"GetVariable failed\\n\");\n+\t\t\t\treturn EFI_ST_FAILURE;\n+\t\t\t}\n+\n+\t\t\treturn EFI_ST_SUCCESS;\n+\t\t} else {\n+\t\t\tif (ret == EFI_NOT_FOUND) {\n+\t\t\t\tefi_st_printf(\"EFI Variable efi_st_var0 not found. \"\n+\t\t\t\t\t\"Executing First Phase\\n\");\n+\t\t\t}\n+\t\t}\n+\t}\n+\n \tmemset(v2, 0x1, sizeof(v2));\n \n \tif (IS_ENABLED(CONFIG_EFI_VARIABLE_FILE_STORE)) {\n@@ -279,7 +360,28 @@ static int execute(void)\n \t\t\treturn EFI_ST_FAILURE;\n \t\t}\n \t} else {\n-\t\tif (ret != EFI_UNSUPPORTED) {\n+\t\tif (ret != EFI_SUCCESS) {\n+\t\t\tefi_st_error(\"SetVariable failed\\n\");\n+\t\t\treturn EFI_ST_FAILURE;\n+\t\t}\n+\n+\t\t/* Delete it by setting the size to 0 */\n+\t\tret = st_runtime->set_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t    EFI_VARIABLE_BOOTSERVICE_ACCESS |\n+\t\t\t\t\t    EFI_VARIABLE_RUNTIME_ACCESS,\n+\t\t\t\t\t    0, NULL);\n+\t\tif (ret != EFI_SUCCESS) {\n+\t\t\tefi_st_error(\"SetVariable failed\\n\");\n+\t\t\treturn EFI_ST_FAILURE;\n+\t\t}\n+\n+\t\t/* Add an 8byte aligned variable */\n+\t\tret = st_runtime->set_variable(u\"efi_st_var0\", &guid_vendor0,\n+\t\t\t\t\t    EFI_VARIABLE_BOOTSERVICE_ACCESS |\n+\t\t\t\t\t    EFI_VARIABLE_RUNTIME_ACCESS |\n+\t\t\t\t\t    EFI_VARIABLE_NON_VOLATILE,\n+\t\t\t\t\t    sizeof(v) / 2, v);\n+\t\tif (ret != EFI_SUCCESS) {\n \t\t\tefi_st_error(\"SetVariable failed\\n\");\n \t\t\treturn EFI_ST_FAILURE;\n \t\t}\n","prefixes":["07/12"]}