Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146217010
D55107.id171160.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D55107.id171160.diff
View Options
diff --git a/stand/efi/include/efizfs.h b/stand/efi/include/efizfs.h
--- a/stand/efi/include/efizfs.h
+++ b/stand/efi/include/efizfs.h
@@ -47,6 +47,7 @@
STAILQ_ENTRY(zfsinfo) zi_link;
EFI_HANDLE zi_handle;
uint64_t zi_pool_guid;
+ bool zi_on_bootdev;
} zfsinfo_t;
void efi_zfs_probe(void);
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
@@ -76,7 +76,7 @@
}
static void
-insert_zfs(EFI_HANDLE handle, uint64_t guid)
+insert_zfs(EFI_HANDLE handle, uint64_t guid, bool on_bootdev)
{
zfsinfo_t *zi;
@@ -84,6 +84,7 @@
if (zi != NULL) {
zi->zi_handle = handle;
zi->zi_pool_guid = guid;
+ zi->zi_on_bootdev = on_bootdev;
STAILQ_INSERT_TAIL(&zfsinfo, zi, zi_link);
}
}
@@ -109,8 +110,10 @@
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)
- insert_zfs(pd->pd_handle, guid);
+ if (zfs_probe_dev(devname, &guid, false) == 0) {
+ 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
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -143,6 +143,11 @@
*/
EFI_LOADED_IMAGE *boot_img;
+enum boot_policies {
+ STRICT,
+ RELAXED,
+} boot_policy = RELAXED;
+
static bool
has_keyboard(void)
{
@@ -592,17 +597,21 @@
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))
+ if (zi->zi_on_bootdev && probe_zfs_currdev(zi->zi_pool_guid))
return (0);
}
+ if (boot_policy == RELAXED) {
+ STAILQ_FOREACH(zi, zfsinfo, zi_link) {
+ printf("Trying ZFS pool 0x%jx\n", zi->zi_pool_guid);
+ if (!zi->zi_on_bootdev && probe_zfs_currdev(zi->zi_pool_guid))
+ return (0);
+ }
+ }
#endif /* EFI_ZFS_BOOT */
#ifdef MD_IMAGE_SIZE
@@ -1189,6 +1198,25 @@
(void)smbios_detect(smbios_v2_ptr);
}
+static void
+set_boot_policy(void)
+{
+ const char *policy;
+
+ if ((policy = getenv("boot_policy")) == NULL)
+ return;
+ if (strcmp(policy, "strict") == 0) {
+ boot_policy = STRICT;
+ return;
+ }
+ if (strcmp(policy, "relaxed") == 0) {
+ boot_policy = RELAXED;
+ return;
+ }
+ printf("Unknown boot_policy '%s', defaulting to %s\n",
+ policy, boot_policy == RELAXED ? "relaxed" : "strict");
+}
+
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 1, 8:20 PM (3 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29124898
Default Alt Text
D55107.id171160.diff (3 KB)
Attached To
Mode
D55107: stand/efi: Allow RELAXED or STRICT boot policies
Attached
Detach File
Event Timeline
Log In to Comment