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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6592A10F9300 for ; Tue, 31 Mar 2026 21:10:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C7FF584020; Tue, 31 Mar 2026 23:10:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=garyguo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=garyguo.net header.i=@garyguo.net header.b="vz1IroeF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 48BD883F5B; Tue, 31 Mar 2026 21:19:07 +0200 (CEST) Received: from LO2P265CU024.outbound.protection.outlook.com (mail-uksouthazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c205::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 37C9883AA9 for ; Tue, 31 Mar 2026 21:19:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=garyguo.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=gary@garyguo.net ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=V3+sY0U4MTttV0Lgb/oaXVSyc3A6bI15z+7DOpFZmwK2ExDgNOU8gv6xKQC5N9h/UmgfbKrSZ+/FmuqOtZTwfTvpeoDtySLN0bMZademPBcyjp5rWK7JbLh7vsStIOLIUSzDBeMDGGKtZ3BtPhOTOKu/XdcZNDFfKbSc5kZuJ1NoYPqiQlJI8R9TaFpOwbj2tnnShiccVENFwy0aH2dmGSSEVwZJAjMilhe81ragNQagLKCZlLfYYfOQd/zKPDMVo2UAMLc94kPSguIrdr89yzZ8gaBMd7xo+rV1icVlVGb3/S2msg+jYNrpWyQ2plKeTBnh71K/htx+8083fl2kCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=49SYE5aS3m+IKqFZ2yxqfx0bBw+TigmNtmQXm7GokKw=; b=R9Abm5iVI0siX+FJEbcI6Rq9rwb0dTWxpdbYgZPVwpkYPesNXuc60KNKYJ1DGoV707WJKC+h00KzLDmO6gQ3rcKG2/u4s4F4fNEgRwAolpK1s0avIDcixiRgf62jZQPHOAnQDwdYxrHXowVra9EMT9bdHl7cFA2xbwxS2eK67pWHFWag4jHlubkOJ6e3Ih/8ind23aATC9IkKJAP+4OWhTdGsmuQfFjz3Ay+Xyvt+5cFxrUruz1MBl3PiZR9fng5nF21Deb2eXZKI5KKraCbu07v5Kt3dLE6IyeN9UFO0YH5R0p59E64j7PdKdhS2bRbrLr4l10hZd1xJlLK04MfHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=49SYE5aS3m+IKqFZ2yxqfx0bBw+TigmNtmQXm7GokKw=; b=vz1IroeFUPzLF1Hn4XvhQNrYpuOQ+AKFX4ZPwSMlt9l2xbR3lweeI22uC8Tcxxp91n8dgyIJj0fYSBz2dTF9EZvuAaYWfMf6LbmIZkuNzUYfs2lmg4//ns1wjWJT8bIJawjuDwEo3B2xV03+00EuRUDkNETM7pQjJVr98X0QZcE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) by LO2P265MB3609.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:1b5::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9745.28; Tue, 31 Mar 2026 19:19:02 +0000 Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986]) by LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986%4]) with mapi id 15.20.9769.014; Tue, 31 Mar 2026 19:19:02 +0000 From: Gary Guo To: Tom Rini , Heinrich Schuchardt , Ilias Apalodimas , David Zang , Sam Protsenko , Gary Guo , "Ying-Chun Liu (PaulLiu)" , Adriano Cordova , Simon Glass , Javier Tia , Martyn Welch Cc: u-boot@lists.denx.de Subject: [PATCH] efi_loader: support EFI_OS_INDICATIONS_BOOT_TO_FW_UI Date: Tue, 31 Mar 2026 20:18:51 +0100 Message-ID: <20260331191853.44549-1-gary@garyguo.net> X-Mailer: git-send-email 2.51.2 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: DUZPR01CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::19) To LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LOVP265MB8871:EE_|LO2P265MB3609:EE_ X-MS-Office365-Filtering-Correlation-Id: c5fd4b94-108d-4416-1fa6-08de8f5a5e50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|7416014|1800799024|18002099003|56012099003|921020; X-Microsoft-Antispam-Message-Info: YRjvAug7GflenV/2bvlt9455jeOk+fsGgbGB/33Xj9zele6+OvSi/spM/NgiybufmX2gCtDJYfpNGCopv3+/sZAhR7aN6gFq13c6nb1I3C6KQkLciZca6e7gOSd47/VhxOWQVGCYLBXE1aUsxtyVJ2GyDYbLQRd4xXLJ8trTr/0cBwAErw879Q2HPw4kmjV9MczTIxsAOvLx28ZfzTYS1k+oolrBsTxGqnx2Stkz9vAQDMWDfes49ubrm9MC3lx50pOPq4qFlH9fG2O5uSxPnWprBQDF9wcI87h1z0qSkVbyTnBvw4dB2BukxYcqtR7/xa/uy1ukUs6uZFddFG2As1SQTaQSsRF9DC3QQzvZG1bq3cpw5K+w4/LvJSpultH1pxC//bkYnTGUBxZQvD3aMGlIkNBe2cXP5V5FXhBjJZN2ZKlUqxO0pUpE7hdv3hLQ7OzLdnFtwxOIxUZxnDik9yIz72BYreqj/5aUE4dcVN11kuqJSov2HjATSABgaMg/ev+ewJHhe0DvAvKP5iY45GOQMrg+Q5zH/bFNGTRzAf61vDFFn/Uh8M7w3Gfp4hsLXLXhcPsH+VFO907VBaa7YfitcuobopNjg9IN85GaxXG/+XXCFJdd0EGs8aKkdCPQdR+XqYXEP7CuyJJlBtWsN+fcfpPpJQVQcwfq1zxCX3rqKGCpnyZ2AEuXTsRiUXq0Gqpxu0LYd0Xa0oB2XJGOWLH3K9PZfNSskzirlYyqlQCxstZc9NuGFj19p7Wh83LbXpBhVsZ8OmB/AKWnBvsZBw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(7416014)(1800799024)(18002099003)(56012099003)(921020); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-A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yguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: c5fd4b94-108d-4416-1fa6-08de8f5a5e50 X-MS-Exchange-CrossTenant-AuthSource: LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2026 19:19:02.6535 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: s9gGadWOiqh+iLMmiKmurmPDb2sTtZSptujQxtPhBDXF+F1x/gZjTmeRy5brqiqOVTLf6XEpQqcXwvEe2VOEHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO2P265MB3609 X-Mailman-Approved-At: Tue, 31 Mar 2026 23:10:31 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean EFI variable OsIndications have a bit EFI_OS_INDICATIONS_BOOT_TO_FW_UI indicating that the OS (or next stage bootloader) requests booting into firmware UI instead of continuing autoboot process. Support it by having autoboot.c asking EFI bootmgr if boot should continue, which checks and clear the bit (so the next boot continue as normal). With this change, systemd-boot will show a "Reboot Into Firmware Interface" option which will be able to drop back to u-boot. This can be useful if bootdelay is configured to be -2. Signed-off-by: Gary Guo --- common/autoboot.c | 4 +++- include/efi_loader.h | 2 ++ lib/efi_loader/efi_bootmgr.c | 45 ++++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_setup.c | 4 ++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/common/autoboot.c b/common/autoboot.c index 1783ef92c94c..b889407612dc 100644 --- a/common/autoboot.c +++ b/common/autoboot.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -503,7 +504,8 @@ void autoboot_command(const char *s) { debug("### main_loop: bootcmd=\"%s\"\n", s ? s : ""); - if (s && (stored_bootdelay == -2 || + if (s && !(IS_ENABLED(CONFIG_EFI_BOOTMGR) && efi_should_abort_autoboot()) && + (stored_bootdelay == -2 || (stored_bootdelay != -1 && !abortboot(stored_bootdelay)))) { bool lock; int prev; diff --git a/include/efi_loader.h b/include/efi_loader.h index 3e70ac070550..449697ad13b3 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -583,6 +583,8 @@ efi_status_t efi_bootmgr_get_unused_bootoption(u16 *buf, efi_status_t efi_bootmgr_update_media_device_boot_option(void); /* Delete selected boot option */ efi_status_t efi_bootmgr_delete_boot_option(u16 boot_index); +/* Check if autoboot should be aborted based on EFI vars */ +bool efi_should_abort_autoboot(void); /* Invoke EFI boot manager */ efi_status_t efi_bootmgr_run(void *fdt); /* search the boot option index in BootOrder */ diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a687f4d8e85c..39f255ac9de4 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -1290,6 +1290,51 @@ out: return ret; } +/** + * efi_should_abort_autoboot() - check if autoboot should be aborted per EFI vars + * + * Return: true if autoboot should abort + */ +bool efi_should_abort_autoboot(void) +{ + efi_status_t ret; + u64 os_indications = 0x0; + efi_uintn_t size; + efi_status_t r; + + /* Initialize EFI drivers */ + ret = efi_init_obj_list(); + if (ret != EFI_SUCCESS) { + log_err("Error: Cannot initialize UEFI sub-system, r = %lu\n", + ret & ~EFI_ERROR_MASK); + return false; + } + + size = sizeof(os_indications); + r = efi_get_variable_int(u"OsIndications", &efi_global_variable_guid, + NULL, &size, &os_indications, NULL); + if (r != EFI_SUCCESS || size != sizeof(os_indications)) + return false; + + if (!(os_indications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) + return false; + + /* Clear the BOOT_TO_FW_UI so next boot returns to normal */ + os_indications &= ~EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + r = efi_set_variable_int(u"OsIndications", + &efi_global_variable_guid, + EFI_VARIABLE_NON_VOLATILE | + EFI_VARIABLE_BOOTSERVICE_ACCESS | + EFI_VARIABLE_RUNTIME_ACCESS, + sizeof(os_indications), + &os_indications, false); + + if (r != EFI_SUCCESS) + log_err("Setting %ls failed\n", L"OsIndications"); + + return true; +} + /** * efi_bootmgr_run() - execute EFI boot manager * @fdt: Flat device tree diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index f06cf49e4435..0ad02e9fe0dd 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -156,6 +156,10 @@ static efi_status_t efi_init_os_indications(void) { u64 os_indications_supported = 0; + if (IS_ENABLED(CONFIG_EFI_BOOTMGR)) + os_indications_supported |= + EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) os_indications_supported |= EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED; -- 2.51.2