From nobody Fri Feb 27 01:01:55 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fMVQq5FL3z6Swm7 for ; Fri, 27 Feb 2026 01:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fMVQq48rvz3p63 for ; Fri, 27 Feb 2026 01:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772154115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0gL/w7hZzq+kWp8fg5aCthOD5jCuKmHhN9qnt4SmDIE=; b=GuEAXgsK5UQSfpETOqw/G0zmS7n93qHYM5OIky5KvzwDsmWxZ2sUriPCFPdWqOJT8vStV8 6Mp6HzeaHQXzLAYetbprDgYDZ68KlD/H3NZKuSxmC90bFZtSW1W+Q7gR2+U+TluCGEJ9Ht iQpuvI/LPOibG1XCOlgcG4xIFGtVAmeC/wLAw4btfaCWMDsN8wPD0xq2uFoHNims9UGnSf ++L7cUrT4RuIzEKroAaDw+HalI8rLjNCm+vinzXZFNjHkni9N/8dzTxYyWROemMFeNYU1V YpON6VUHjP26BIibtR+6njlbc9ZiV5dHaJUXSH2vxe0EexAqq2VC6l5m2csUww== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772154115; a=rsa-sha256; cv=none; b=T3RZXcyi30P6izEJSSNPWIaYY8Hgv2Uhyni1tt7M+XNnh+R3XRubaOb2bd04FiIRq4oV9f wzuXRbMsRATRhaKXS53I0tpFUEcqsSzBLFTTbjglhZ3NQHk4zGQ0t2GbJdm7owAfjChbqj GObtVpnsqeT42nt9HOiLWXnUqEIDi6wSCsGBK2Vaze/4mJ1RvBpPdNYxv5dr11lgS7GDXu NqCvwsuRmekxW+n3Bc83K+4xVYAv5XKI6IIMLIozYKZ/2SrWcKkjcTK9lsrTey/kTwT2dl 6dOxMvhDrOuDscP7vult5YTzNJeIHJNLFCe9+MvoN/gQL6vTZVG6OvYh9FTsaw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772154115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0gL/w7hZzq+kWp8fg5aCthOD5jCuKmHhN9qnt4SmDIE=; b=Su12TZdAVbMMbP/6CFwyereumYSXm2RTf3yaHqz0ug7WdKcNEW/wllrjOPweSCVkLQlnsJ 0hEHoVtPdJkBZdoYx4djSqAw1XnwS4R1/HkmA1iHrpe3AvoXAV2aBKEmJWJ0uX0mE8j0rF iZ+1QcCdqzWZz3MQYguaYVW3g7olyH4qkCTCA9z4EF6MENudT/JW/mmDt1TJ+ZKOUSM326 HXxxbNrHdNL82zV/Up6INhNiqoK0optVnPRY4iYWUTX+0i+mUCeii+gCc6BV4nKWkkbI8/ NyuOGgbITzAmXyo1/c1CIeJTntNvQ5XkUU9Gx/TmI3L9g8Vzo3f1yXUnqvwjLw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fMVQq3DWvzwMt for ; Fri, 27 Feb 2026 01:01:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 45d75 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 27 Feb 2026 01:01:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 784150fd2535 - main - stand/efi: Allow RELAXED or STRICT boot policies List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 784150fd25351f4a38f4d983882f4a26cc5d3272 Auto-Submitted: auto-generated Date: Fri, 27 Feb 2026 01:01:55 +0000 Message-Id: <69a0ed03.45d75.2a153af5@gitrepo.freebsd.org> The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=784150fd25351f4a38f4d983882f4a26cc5d3272 commit 784150fd25351f4a38f4d983882f4a26cc5d3272 Author: Warner Losh AuthorDate: 2026-02-27 00:57:39 +0000 Commit: Warner Losh CommitDate: 2026-02-27 01:01:36 +0000 stand/efi: Allow RELAXED or STRICT boot policies The RELAXED boot policy will automatically search for any root filesystem (currently zfs only) on any device. STRICT policy only searches on the boot device. RELEAXED will still prefer the device we booted from, which is the smallest behavior change we should do. STRICT may be needed for releases, though. Sponsored by: Netflix Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D55107 --- stand/efi/libefi/efizfs.c | 10 +++++++--- stand/efi/loader/main.c | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c index 563cf841143a..8ad410488b9c 100644 --- a/stand/efi/libefi/efizfs.c +++ b/stand/efi/libefi/efizfs.c @@ -76,7 +76,7 @@ efizfs_get_guid_by_handle(EFI_HANDLE handle, uint64_t *guid) } static void -insert_zfs(EFI_HANDLE handle, uint64_t guid) +insert_zfs(EFI_HANDLE handle, uint64_t guid, bool head) { zfsinfo_t *zi; @@ -84,7 +84,10 @@ insert_zfs(EFI_HANDLE handle, uint64_t guid) if (zi != NULL) { zi->zi_handle = handle; zi->zi_pool_guid = guid; - STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link); + if (head) + STAILQ_INSERT_HEAD(&zfsinfo, zi, zi_link); + else + STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link); } } @@ -110,7 +113,8 @@ efi_zfs_probe(void) snprintf(devname, sizeof(devname), "%s%dp%d:", efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); if (zfs_probe_dev(devname, &guid, false) == 0) - insert_zfs(pd->pd_handle, guid); + insert_zfs(pd->pd_handle, guid, + pd->pd_handle == boot_img->DeviceHandle); } } } diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index d8508d7d91a0..f83db2e0668d 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -143,6 +143,16 @@ UINT16 boot_current; */ EFI_LOADED_IMAGE *boot_img; +enum boot_policies { + STRICT, + RELAXED, +} boot_policy = RELAXED; + +const char *policy_map[] = { + [STRICT] = "strict", + [RELAXED] = "relaxed", +}; + static bool has_keyboard(void) { @@ -592,13 +602,14 @@ find_currdev(bool do_bootmgr, char *boot_info, size_t boot_info_sz) zfsinfo_t *zi; /* - * Did efi_zfs_probe() detect the boot pool? If so, use the zpool - * it found, if it's sane. ZFS is the only thing that looks for - * disks and pools to boot. This may change in the future, however, - * if we allow specifying which pool to boot from via UEFI variables - * rather than the bootenv stuff that FreeBSD uses today. + * First try the zfs pool(s) that were on the boot device, then + * try any other pool if we have a relaxed policy. zfsinfo has + * the pools that had elements on the boot device first. */ STAILQ_FOREACH(zi, zfsinfo, zi_link) { + if (boot_policy == STRICT && + zi->zi_handle != boot_img->DeviceHandle) + continue; printf("Trying ZFS pool 0x%jx\n", zi->zi_pool_guid); if (probe_zfs_currdev(zi->zi_pool_guid)) return (0); @@ -1189,6 +1200,23 @@ efi_smbios_detect(void) (void)smbios_detect(smbios_v2_ptr); } +static void +set_boot_policy(void) +{ + const char *policy; + + if ((policy = getenv("boot_policy")) == NULL) + return; + for (int i = 0; i < nitems(policy_map); i++) { + if (strcmp(policy, policy_map[i]) == 0) { + boot_policy = i; + return; + } + } + printf("Unknown boot_policy '%s', defaulting to %s\n", + policy, policy_map[boot_policy]); +} + EFI_STATUS main(int argc, CHAR16 *argv[]) { @@ -1287,6 +1315,8 @@ main(int argc, CHAR16 *argv[]) read_loader_env("LoaderEnv", "/efi/freebsd/loader.env", false); read_loader_env("NextLoaderEnv", NULL, true); + set_boot_policy(); + /* * We now have two notions of console. howto should be viewed as * overrides. If console is already set, don't set it again.