Page MenuHomeFreeBSD

D55107.id171171.diff
No OneTemporary

D55107.id171171.diff

diff --git a/stand/efi/libefi/efizfs.c b/stand/efi/libefi/efizfs.c
--- a/stand/efi/libefi/efizfs.c
+++ b/stand/efi/libefi/efizfs.c
@@ -109,8 +109,9 @@
STAILQ_FOREACH(pd, &hd->pd_part, pd_link) {
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)
+ if (zfs_probe_dev(devname, &guid, false) == 0) {
insert_zfs(pd->pd_handle, guid);
+ }
}
}
}
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -143,6 +143,17 @@
*/
EFI_LOADED_IMAGE *boot_img;
+enum boot_policies {
+ STRICT,
+ RELAXED,
+} boot_policy = RELAXED;
+
+const char *policy_map[] = {
+ "strict",
+ "relaxed",
+};
+
+
static bool
has_keyboard(void)
{
@@ -592,16 +603,16 @@
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.
*/
STAILQ_FOREACH(zi, zfsinfo, zi_link) {
printf("Trying ZFS pool 0x%jx\n", zi->zi_pool_guid);
if (probe_zfs_currdev(zi->zi_pool_guid))
return (0);
+ if (boot_policy == STRICT &&
+ zi->zi_handle != boot_img->DeviceHandle)
+ break;
}
#endif /* EFI_ZFS_BOOT */
@@ -1189,6 +1200,23 @@
(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 @@
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.

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 22, 6:47 PM (12 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35377159
Default Alt Text
D55107.id171171.diff (2 KB)

Event Timeline