From patchwork Tue Sep 2 15:21:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 185 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826566; bh=IX9CB/XPwXWShP4AUzTb57ytbq+eGqY/E7S2D6vKdiY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=tthBTp+Re0VXJtzfLbyFOb70JjurrdOHVgUzz0Eff8xQWiSXZjIKjD+lnOz2wd79O VFZA4yaLjocl7KaS6Mt9Z84iLR9ycDUD85IhzDLeuavUtgfg8Y87iv5aVHf+iBD0AL Tb1+K+SlUSTHSh7q/2zflYJT7EZx2mV/apqO9ord0mSgXNGsdGVKbFo5vWGZMgVK+p UWA8XKIeC8IVVumf3uGZ5PLiHhkNv/kcXLvfDWXoDxy6fPSYZ4Ku9zOrPALGvzga/d Kmiz/Os7sNk/bAuV+N1Qe2FfmJ7PPssMiIBjHHlX8kngmgrI2VfIrzWIeiXmCCvHbR 8qq1UiJTOfnYw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EBDDA678E9 for ; Tue, 2 Sep 2025 09:22:46 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 9rY9dZTx82NC for ; Tue, 2 Sep 2025 09:22:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826566; bh=IX9CB/XPwXWShP4AUzTb57ytbq+eGqY/E7S2D6vKdiY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=tthBTp+Re0VXJtzfLbyFOb70JjurrdOHVgUzz0Eff8xQWiSXZjIKjD+lnOz2wd79O VFZA4yaLjocl7KaS6Mt9Z84iLR9ycDUD85IhzDLeuavUtgfg8Y87iv5aVHf+iBD0AL Tb1+K+SlUSTHSh7q/2zflYJT7EZx2mV/apqO9ord0mSgXNGsdGVKbFo5vWGZMgVK+p UWA8XKIeC8IVVumf3uGZ5PLiHhkNv/kcXLvfDWXoDxy6fPSYZ4Ku9zOrPALGvzga/d Kmiz/Os7sNk/bAuV+N1Qe2FfmJ7PPssMiIBjHHlX8kngmgrI2VfIrzWIeiXmCCvHbR 8qq1UiJTOfnYw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2A7AF678F3 for ; Tue, 2 Sep 2025 09:22:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826562; bh=jrpseVbGjjXXaP+A1/hPDYcnV+NFjP3Irn5yqWO7X/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrS2JL3mG17U5bszQdotNWq8wf0iXoKlRuuajpjrA/m8nyi4nGegm1GyhcP8PnG+a 7e3leO9kjRROGTGGp8lwJZ9hvfZHwpMOjhyVCLPvUM4jfDrdhgbNa+SkuIJEKi7eGD L8islhJr5yAtFQswTH5mvna20SIT+ANMJW6CYzee7iUhv6VTPiwBAzdNKi0Kq8wE/Z ADpiu+zdygyILFtYHNcU3wSicpLshdJ6bBpRBkP/YxBoA9wArKIYySx1YyIJGBkoB2 wdgEWAgM953ijQiRpcK47iDHjQ0bjYyFTF0wGLredRR4HXhe2+mCHf9ilovkhg+9wy nckzeAlqO/NUA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6C41967867; Tue, 2 Sep 2025 09:22:42 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id pyt-LlHsaIX4; Tue, 2 Sep 2025 09:22:42 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756826561; bh=sVgiEEW66+KK3HZYuOtCvvY1ivPQP3Tl6AnKMV6ji7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S8UJBZ7fGvSdHfgMCgkknLvpx3tP+CsZY2XGmjbRcX2AAoR3/AyJ8Q7cbpiISgkb/ UMP7a7qIyYbmsYIGTO0lk0WsJVs9yfBqEXLhoVW5U3W5b9vjPLyU1SkJaUII4zw2Jh F5jtOQ0xXVBMWHRtR6AQ3TYwosn3zqscuGIXyJTWIQQd01jZfB3ex85/3dLuRQHKn7 lblPT/ZV0QrIxW/VlbC5dbxtC1/2f6IhyWx0V78DRXy8Vd/xYZUCmd3BnZxhvYg3Vm TuMSGvetyiQAy4G/eeR1lNxXAa5+zQlI/1cXley209eJ1acbA4Ewnt1VrQeFhARXSk +EKKbLZQ/t7CQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7B7AC677F7; Tue, 2 Sep 2025 09:22:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 2 Sep 2025 09:21:46 -0600 Message-ID: <20250902152158.2285264-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250902152158.2285264-1-sjg@u-boot.org> References: <20250902152158.2285264-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2KQQ5ZL5SGYG3HGFOHFIKV55ZEMPHHOJ X-Message-ID-Hash: 2KQQ5ZL5SGYG3HGFOHFIKV55ZEMPHHOJ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/18] shim: Add a flag to make the setting persistent List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide a -n flag to 'shim debug' so that the setting persists across reboots. Co-developed-by: Claude Signed-off-by: Simon Glass --- cmd/shim.c | 21 +++++++++++++++------ doc/usage/cmd/shim.rst | 16 ++++++++++++---- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/cmd/shim.c b/cmd/shim.c index 903f1823f19..3a24b66ccf4 100644 --- a/cmd/shim.c +++ b/cmd/shim.c @@ -22,11 +22,12 @@ static int do_shim_debug(struct cmd_tbl *cmdtp, int flag, int argc, struct abuf buf; const char *sub; u32 value; + u32 attr; int ret; sub = cmd_arg1(argc, argv); - if (!sub) { - ret = efi_read_var(SHIM_VERBOSE_VAR_NAME, &efi_shim_lock, NULL, + if (argc == 1) { + ret = efi_read_var(SHIM_VERBOSE_VAR_NAME, &efi_shim_lock, &attr, &buf, NULL); if (ret == -ENOENT) { value = 0; @@ -41,10 +42,18 @@ static int do_shim_debug(struct cmd_tbl *cmdtp, int flag, int argc, } printf("%d\n", value); } else { - value = hextoul(sub, NULL) ? 1 : 0; + int arg = 1; + + attr = EFI_VARIABLE_BOOTSERVICE_ACCESS; + if (!strcmp("-n", argv[arg])) { + attr |= EFI_VARIABLE_NON_VOLATILE; + arg++; + } + if (arg == argc) + return CMD_RET_USAGE; + value = hextoul(argv[arg], NULL) ? 1 : 0; eret = efi_set_variable_int(SHIM_VERBOSE_VAR_NAME, - &efi_shim_lock, - EFI_VARIABLE_BOOTSERVICE_ACCESS, + &efi_shim_lock, attr, sizeof(value), &value, false); if (eret) { printf("Failed to write variable (err=%lx)\n", eret); @@ -59,7 +68,7 @@ fail: } U_BOOT_LONGHELP(shim, - "debug [<0/1>] - Enable / disable debug verbose mode"); + "debug [[-n] <0/1>] - Enable / disable debug verbose mode"); U_BOOT_CMD_WITH_SUBCMDS(shim, "Shim utilities", shim_help_text, U_BOOT_SUBCMD_MKENT(debug, 3, 1, do_shim_debug)); diff --git a/doc/usage/cmd/shim.rst b/doc/usage/cmd/shim.rst index 285dd200558..71974f46bb7 100644 --- a/doc/usage/cmd/shim.rst +++ b/doc/usage/cmd/shim.rst @@ -8,7 +8,7 @@ Synopsis :: - shim debug [<0/1>] + shim debug [[-n] <0/1>] Description ----------- @@ -36,6 +36,7 @@ Controls the Shim verbose debugging mode. shim debug # Display current debug state (0 or 1) shim debug 0 # Disable verbose debugging shim debug 1 # Enable verbose debugging + shim debug -n 1 # Enable verbose debugging (non-volatile) The command reads from or writes to the ``SHIM_VERBOSE`` EFI variable in the Shim Lock GUID namespace. When verbose mode is enabled (value = 1), Shim will @@ -44,6 +45,7 @@ output additional debugging information during the boot process. When disabled **Parameters:** +* ``-n`` - Makes the variable non-volatile (persistent across reboots) * ``<0/1>`` - Optional parameter to set debug mode: * ``0`` - Disable verbose debugging @@ -69,6 +71,10 @@ Disable verbose debugging:: => shim debug 0 +Enable verbose debugging with persistence across reboots:: + + => shim debug -n 1 + Configuration ~~~~~~~~~~~~~ @@ -86,12 +92,14 @@ The command uses the EFI variable services to read and write the * **Variable Name:** ``SHIM_VERBOSE`` (Unicode string) * **GUID:** EFI Shim Lock GUID (``605dab50-e046-4300-abb6-3dd810dd8b23``) -* **Attributes:** ``EFI_VARIABLE_BOOTSERVICE_ACCESS`` +* **Attributes:** ``EFI_VARIABLE_BOOTSERVICE_ACCESS`` (default) or + ``EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE`` (with ``-n`` flag) * **Data Type:** 32-bit unsigned integer (4 bytes) * **Values:** 0 (disabled) or 1 (enabled) -The variable is stored in the EFI variable store and persists across reboots -until explicitly changed or the variable store is cleared. +By default, the variable is volatile and will be reset on reboot. When the +``-n`` flag is used, the variable becomes non-volatile and persists across +reboots until explicitly changed or the variable store is cleared. See Also ~~~~~~~~