Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Oct 2021 01:16:51 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4d1e0b5bcd81 - stable/12 - Loader: support booting OS from memory disk (MD)
Message-ID:  <202110080116.1981GpZq011077@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=4d1e0b5bcd819c0f0061d85aebb5e3c408df7946

commit 4d1e0b5bcd819c0f0061d85aebb5e3c408df7946
Author:     Yongbo Yao <yongbo.yao@dell.com>
AuthorDate: 2021-04-07 18:33:22 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2021-10-08 01:16:00 +0000

    Loader: support booting OS from memory disk (MD)
    
    Until now, the boot image can be embedded into the loader with
    /sys/tools/embed_mfs.sh, and memory disk (MD) is already supported
    in loader source. But due to memory disk (MD) driver isn't registered
    to the loader yet, the boot image can't be boot from embedded memory
    disk.
    
    (cherry picked from commit 5984246f9626fbc3d356ee2d3b3cd159f6d0a7c2)
---
 stand/efi/loader/conf.c |  7 +++++++
 stand/efi/loader/main.c | 24 ++++++++++++++++++++++++
 stand/man/loader.8      | 19 ++++++++++++++++++-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/stand/efi/loader/conf.c b/stand/efi/loader/conf.c
index a5d2ad7c613f..b112cc2f8c0b 100644
--- a/stand/efi/loader/conf.c
+++ b/stand/efi/loader/conf.c
@@ -35,6 +35,10 @@ __FBSDID("$FreeBSD$");
 
 extern struct devsw vdisk_dev;
 
+#ifdef MD_IMAGE_SIZE
+extern struct devsw md_dev;
+#endif
+
 struct devsw *devsw[] = {
 	&efipart_fddev,
 	&efipart_cddev,
@@ -46,6 +50,9 @@ struct devsw *devsw[] = {
 	&vdisk_dev,
 #ifdef EFI_ZFS_BOOT
 	&zfs_dev,
+#endif
+#ifdef MD_IMAGE_SIZE
+	&md_dev,
 #endif
 	NULL
 };
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 95a00d72b6a4..cf0a041b6432 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -277,6 +277,21 @@ probe_zfs_currdev(uint64_t guid)
 }
 #endif
 
+#ifdef MD_IMAGE_SIZE
+static bool
+probe_md_currdev(void)
+{
+	extern struct devsw md_dev;
+	bool rv;
+
+	set_currdev_devsw(&md_dev, 0);
+	rv = sanity_check_currdev();
+	if (!rv)
+		printf("MD not present\n");
+	return (rv);
+}
+#endif
+
 static bool
 try_as_currdev(pdinfo_t *hd, pdinfo_t *pp)
 {
@@ -550,6 +565,15 @@ find_currdev(bool do_bootmgr, bool is_last,
 	}
 #endif /* EFI_ZFS_BOOT */
 
+#ifdef MD_IMAGE_SIZE
+	/*
+	 * If there is an embedded MD, try to use that.
+	 */
+	printf("Trying MD\n");
+	if (probe_md_currdev())
+		return (0);
+#endif /* MD_IMAGE_SIZE */
+
 	/*
 	 * Try to find the block device by its handle based on the
 	 * image we're booting. If we can't find a sane partition,
diff --git a/stand/man/loader.8 b/stand/man/loader.8
index 0a32125681a6..b5f770803bff 100644
--- a/stand/man/loader.8
+++ b/stand/man/loader.8
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 2, 2020
+.Dd April 7, 2021
 .Dt LOADER 8
 .Os
 .Sh NAME
@@ -981,6 +981,23 @@ See
 for details.
 In order for this to be effective, one should also configure the firmware
 (BIOS or UEFI) to prevent booting from unauthorized devices.
+.Sh MD
+Memory disk (MD) can be used when the
+.Nm
+was compiled with
+.Va MD_IMAGE_SIZE .
+The size of the memory disk is determined by
+.Va MD_IMAGE_SIZE .
+If MD available, a file system can be embedded into the
+.Nm
+with
+.Pa /sys/tools/embed_mfs.sh .
+Then, MD will be probed and be set to
+.Va currdev
+during initialization.
+.Pp
+Currently, MD is only supported in
+.Xr loader.efi 8 .
 .Sh FILES
 .Bl -tag -width /usr/share/examples/bootforth/ -compact
 .It Pa /boot/loader



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202110080116.1981GpZq011077>