From nobody Fri Jun 17 17:10:03 2022 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 CAC988547E2; Fri, 17 Jun 2022 17:10:03 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPlsR5KrYz4c3J; Fri, 17 Jun 2022 17:10:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655485803; 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=FkLZfDTQiebpQxueM02OlEIVcIY1yPEDO2abii/dZZo=; b=Ibi03BsIovn7DDYegSjJ/FdxcSEIo0QRsxOihTKzGKp/6F4L1CqzhVhl/kTdGWmNnrcvQo +QShuH4huYFomTxiUanYJ79XUw14Co76u/cAAij+clr8vKqxxyKY9hh/G3Xg+IBxnByxpe 4zannGdeP84nh18W9eokfDmAX7P9EwP+iiQBJVBUTX36h4YMRMqQ9eHpUCTyoiSqK/QBSr MNF0CudyOZvB68wzXUJqCoHHyplK3GrPNUaTRL4M/ibxxgOMW9pchOnScqhS8MPb1/UXOo ivuwD+qwVMXfEbSojqi3ZDJKDawZxDpjGXW01KZiIYfkYZiuy1UyN5rLngj5dQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9348523661; Fri, 17 Jun 2022 17:10:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HHA34s009469; Fri, 17 Jun 2022 17:10:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HHA3qZ009466; Fri, 17 Jun 2022 17:10:03 GMT (envelope-from git) Date: Fri, 17 Jun 2022 17:10:03 GMT Message-Id: <202206171710.25HHA3qZ009466@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 721d0a045abc - stable/13 - Loader: support booting OS from memory disk (MD) 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 721d0a045abcf0d587f0a0a424164946db9d6bd0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655485803; 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=FkLZfDTQiebpQxueM02OlEIVcIY1yPEDO2abii/dZZo=; b=E06w9NWJBO/nhLh+BH76sC2otP9df2n7bjzyEMYanfvqZ4OQj5jK28ilFg5wPcdl/527mo o+DubD+0++67wwPIMB1q15qxDWAw21QLFx+87ESBa97c8wzzl6j+mCuDDwNSEujVQHe6Zu DbPLGyKVec5S/DQt01YgqgfJT5waZ/dhLep0H9gHjeEXTKgtIFOlDjPV/L4T0Sww8MS/YC j9EMbMiUtjwUHVHZyqslr4mt7V7p8bTKFH56THepz9y7xyAukKWhTlugoSEBD+qwUFh9Rh bQo0r6KDMThgzyMLconkJbgBTtzi75CYSu07usDDtXTUCkkqB+1WlPZww1VyXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655485803; a=rsa-sha256; cv=none; b=Ig09Gmcgogp9o0uMoe3Znh9ccnmtEv4IU9AMSdzp75UJV1gVXWqJq/QkAvMFocXW/5nbSj eYZAXrHXAsJUwSKWZUFyszjXhXCZRrD/9m7e+PRufyVp1ZO8k/gIl7RcMiydQVR1K0+Or6 nVYbA/gS3NzhnOVJ+0sYNIanWqdC8Y12MvpUWMMWp3MljixpAzVQ8IdZOoG08gD3gocHP2 LR4MJqPcp6MO5lRrbmPCsnyhnumgNZ7+qBCIcx+ej5pCEyTd7Df1j5cwXpOUeggsVb0FlX 2xjf5ikTT2OSBuBVsQUgdSCeFtuvGqXVeEqeZxCJapGMjxEWbVFGIIo8SSCplg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=721d0a045abcf0d587f0a0a424164946db9d6bd0 commit 721d0a045abcf0d587f0a0a424164946db9d6bd0 Author: Yongbo Yao AuthorDate: 2021-04-07 18:33:22 +0000 Commit: Mitchell Horne CommitDate: 2022-06-17 17:01:40 +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. Reviewed by: dab, tsoome MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29512 (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 217372939685..863c9188c72c 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 7752751efd0b..eb143989190d 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -294,6 +294,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) { @@ -567,6 +582,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 71559d945b9b..4027063e891d 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 @@ -961,6 +961,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