#
344399 |
|
21-Feb-2019 |
kevans |
MFC GELI Loader Improvements: r336252, r336254, r336256, r336354, r336532-r336534, r336537, r336626, r337326, r337349, r341071, r341160, r341420, r341473, r341651, r342793
Note that this MFC contains some seemingly unrelated zfsloader bits -- this was needed in order to pull in some later fixes for GELI hand-off w/ ZFS bits included.
r336252: Extend loader(8) geli support to all architectures and all disk-like devices.
This moves the bulk of the geli support from lib386/biosdisk.c into a new geli/gelidev.c which implements a devsw-type device whose dv_strategy() function handles geli decryption. Support for all arches comes from moving the taste-and-attach code to the devopen() function in libsa.
After opening any DEVT_DISK device, devopen() calls the new function geli_probe_and_attach(), which will "attach" the geli code to the open_file struct by creating a geli_devdesc instance to replace the disk_devdesc instance in the open_file. That routes all IO for the device through the geli code.
A new public geli_add_key() function is added, to allow arch/vendor-specific code to add keys obtained from custom hardware or other sources.
With these changes, geli support will be compiled into all variations of loader(8) on all arches because the default is WITH_LOADER_GELI.
r336254: Use if rather than case for a simple boolean. gcc thinks blks is undefined sometimes with the case, but enc is always 0 or 1, so and if / else is better anyway.
r336256: Fix glitched indentation (and rewrap as needed due to deeper indent). No functional changes.
r336354: zfsboot: fix build with WITHOUT_LOADER_GELI
r336532: Collapse zfsloader functionality back down into loader.
We no longer really need a separate zfsloader. It was useful when we were first supporting ZFS and had limited ability to properly boot off of ZFS without the special boot loader. Now that the boot loader has matured, go the way loader.efi pioneered and just build one binary. Change the name of the loader to load in the secondary boot blocks to be just /boot/loader. Provide a symbolic link from zfsloader to loader so people who have not upgraded their boot blocks are not affected. This has the happy benefit of making coexistence easier as well (fewer binaries in the matrix).
r336533: Eliminate zfsloader man page.
Remove all cross references to zfsloader.8 and /boot/zfsloader. Move ZFS specific info into loader.8.
r336534: NM and OBJCOPY are already defined for all builds. There's no need to conditionally define them here.
r336537: Mention zfsloader being folded into loader in UPDATING.
r336626: Older zfs boot blocks don't support symlinks. install the link to zfsloader as a hard link. While newer ones do, the whole point of the link was to transition to the new world order smoothly. A hard link is less flexible, but it works and will result in fewer bumps. Adjust UPDATING entry to match.
r337326: loader: biosdisk.c has leftover geli header.
A small cleanup, remove unneeded #include.
r337349: zfsboot: Fix startup crash
On a FreeNAS mini XL, with geli encrypted drives the loader crashed in geli_read().
When we iterate over the list of disks and allocate the zfsdsk structures we don’t zero out the gdev pointer. In one case that resulted in geli_read() (called on the bogus pointer) dividing by zero.
Use calloc() to ensure the zfsdsk structure is always zeroed, so the pointer is initialised to NULL. As a side benefit it gets rid of one #ifdef LOADER_GELI_SUPPORT.
r341071: Restore the ability to override the disk unit/partition at the boot: prompt in gptboot.
When arch-independent geli support was added, a new static 'gdsk' struct was added, but there was still a static 'dsk' struct, and when you typed in an alternate disk/partition, the string was parsed into that struct, which was then never used for anything. Now the string gets parsed into gdsk.dsk, the struct that's actually used.
r341160: Add comments describing the bootargs handoff between loader(8) and gptboot or zfsboot, when loader(8) is the BTX loader. No functional changes.
r341420: Eliminate duplicated code and struct member definitions in the handoff of args data between gptboot/zfsboot and loader(8).
Despite what seems like a lot of changes here, there are no actual changes in behavior, or in the data layout in the structures involved. This is just eliminating identical code pasted into multiple locations.
In detail, the changes are...
- Move struct zfs_boot_args definition from libsa/zfs/libzfs.h to i386/common/bootargs.h because it is specific to x86 booting and the handoff between zfsboot and loader, and has no relation to the zfs library code in general.
- The geli_boot_args and zfs_boot_args structs both contain an identical set of member variables containing geli information. Extract this out to a new geli_boot_data struct, and embed it in the arg-passing structs.
- Provide new routines geli_import_boot_data() and geli_export_boot_data() that can be shared between gptboot, zfsboot, and loader instead of pasting identical code into several different .c files.
- Remove some checks for a NULL pointer that can never be true because the pointer being tested was set using pointer math (kargs + 1) and that can never result in NULL in this code.
r341473: Fix args cross-threading between gptboot(8) and loader(8) with zfs support.
When loader(8) is built with zfs support enabled, it assumes that any extarg data present is a zfs_boot_args struct, but if the first-stage loader was gptboot(8) the extarg data is actually a geli_boot_args struct. Luckily, zfsboot(8) and gptzfsboot(8) have always passed KARGS_FLAGS_ZFS along with KARGS_FLAGS_EXTARG, so we can use KARGS_FLAGS_ZFS to decide whether the extarg data is a zfs_boot_args struct.
To avoid similar problems in the future, gptboot(8) now passes a new KARGS_FLAGS_GELI to indicate that extarg data is geli_boot_args. In loader(8), if the neither KARGS_FLAGS_ZFS nor KARGS_FLAGS_GELI is set but extarg data is present (which will be the case for gptboot compiled before this change), we now check for the known size of the geli_boot_args struct passed by the older versions of gptboot as a way of confirming what type of extarg data is present.
In a semi-related tidying up, since loader's main() has already decided what type of extarg data is present and set the global 'zargs' var accordingly, don't repeat the check in extract_currdev, just check whether zargs is NULL or not.
r341651: Don't reference zfs-specific variables if LOADER_ZFS_SUPPORT is undefined because the variables will be undefined too.
r342793: MK_ZFS -> {MK_ZFS|MK_LOADER_ZFS}, this is so we can diable userland / kernel ZFS but keep the boot-loaders when using ZoL port.
Relnotes: yes (GELI support extended) Relnotes: yes (zfsloader has been collapsed into loader and may be removed after boot blocks have been updated)
|
#
329140 |
|
11-Feb-2018 |
kevans |
MFC Loader Fixes 2017q4p6: r324649,r324650,r324651,r324652,r324653,r324654, r324700,r324702,r324709,r324717,r324719,r324841,r324842,r324843,r324845, r324850,r324876,r324877,r324878,r324879,r324880,r324881,r324883,r324980, r324981,r324982,r324995,r325014,r325093,r325094,r325114,r325170,r325171, r325172,r325173,r325174,r325175,r325176,r325248,r325286,r325310,r325332, r325338,r325339,r325376,r325377,r325379,r325380,r325382,r325478,r325479, r325480,r325482,r325483,r325484,r325485,r325556,r325641,r325681,r325685, r325686,r325687,r325688,r325689,r325690,r325691,r325692,r325693,r325694, r325743,r325744,r325748,r325775,r325779,r325780
r324649: Move common/Makefile.inc to sys/boot/loader.mk.
r324650: tweak style
r324651: create defs.mk for common definitions
r324652: Move all the ficl common code into ficl.mk
r324653: LOADER_foo_SUPPORTED
r324654: Explicitly inlcude SYSDIR in the include path
r324700: loader: initialize dv_cleanup in md.c to eliminate clang warning
r324702: We need to include disk.o in libuboot.a when we're building with support for disk access.
r324709: Revert "Unify boot1 with loader" change r324646
r324717: libsa/ip.c: misplaced comment, ip_v is half char, not ip_p
r324719: libsa/ip: stop read loop on bad fragments
r324841: Use BOOTDIR more consistently in defs.mk rather than repeat sys/boot.
r324842: Introduce BOOTOBJ: The top level object directory for the boot tree
r324843: Stopgap fix to the mistmatch between LOADER_GELI_SUPPORT and LOADER_NO_GELI_SUPPORT.
r324845: Use BOOTOBJ and BOOTDIR to find geli includes and libraries.
r324850: Define LIBSA32 to LIBSA on i386 to fix build.
r324876: Move fdt and uboot defines into common uboot.mk.
r324877: End source directories with SRC rather than a hodgepodge of names
r324878: Make at91 boot loader compile again.
r324879: Prefer SRCTOP paths for bits we're grabbing from libc.
r324880: Use BOOTSRC here.
r324881: Use SYSDIR instead of ${.CURDIR}/../..<etc>/sys.
r324883: Use preferred defined paths, rather than relative paths in fdt.
r324980: Use BOOTDIR consistently.
r324981: Move BINDIR definition to defs.mk, and override where it isn't /boot
r324982: Remove sys/boot/arm/at91 and ixp425
r324995: loader.efi: Make framebuffer commands available for arm64
r325014: Add a 'place holder' arm struct efi_fb until a real one comes
r325093: Define new EFI variables
r325094: Cleanup non-arch Makefiles
r325114: Use defs.mk defins in most MD code
r325170: Use defs.mk values for userboot
r325171: Use defs.mk name and prefer bsd.init.mk
r325172: Remove the -nostdlib stuff I added. Instead, fix LDFLAGS to be honored correctly with the new Makefile.inc include order.
r325173: We don't need to build a special ficl for userboot.
r325174: Minor cleanup
r325175: For amd64, compile both zfs and zfs32 libraries.
r325176: Actually add zfs32/Makefile
r325248: loader ptblread() is broken with >512B sectors
r325286: efipart_strategy is using wrong offset with >512B sectors
r325310: zfs.c:vdev_read() needs to be careful about large sectors
r325332: loader: re-enable gzip support for x86
r325338: loader: fix BOOTSRC -> BOOTOBJ in a library path
r325339: This used to have bzip2 support too.
r325376: WIP: centralize machine links
r325377: mostly libsa
r325379: Revert "mostly libsa"
r325380: Revert "WIP: centralize machine links"
r325382: Cleanup stray libstand names to be libsa names.
r325478: Powerpc is a 32-bit boot loader.
r325479: Define LIBFICL32 to be libficl.a on i386 and libficl32.a on amd64.
r325480: Use DO32 for all the places that we need to flag we're building a 32-bit version of a library.
r325482: Move machine and other link creation to defs.mk
r325483: MACHINE can never be powerpc64, so cleanup code that thinks it can.
r325484: Prefer bsd.init.mk to src.opts.mk
r325485: Centralize all 32-bit builds on 64-bit platform stuff.
r325556: loader: set options before including bsd.init.mk
r325641: loader.efi: efi_devpath_is_prefix should return bool
r325681: boot1: avoid using NULL device path
r325685: libsa32 isn't needed for i386. It's already a 32-bit platform.
r325686: Simplify this if to a direct assignment.
r325687: Remove all the empty help files from the powerpc build.
r325688: FDT support doesn't make sense for ps3, remove it.
r325689: Remove LOADER_FDT_SUPPORT as a Makefile variable.
r325690: Remove LOADER_ZFS_SUPPORT as a Makefile variable
r325691: Remove useless PNP define here.
r325692: Replace LOADER_FIREWIRE_SUPPORT variable
r325693: Move LOADER_{NO,}_GELI_SUPPORT to MK_LOADER_GELI
r325694: Install the 4th files in sys/boot/forth instead of each loader
r325743: Make sure the proper loader.rc gets installed.
r325744: boot1: also check for NULL device
r325748: Use proper include file.
r325775: Add loader.conf to the list of files that are MD.
r325779: Add /boot/dts to the list of default modules.
r325780: Don't add /boot/dt*s* but /boot/dt*b*. Stupid think-o. |
#
234898 |
|
01-May-2012 |
marius |
Add initial support for booting from ZFS on sparc64. At least on Sun Fire V100, the firmware is known to be broken and not allowing to simultaneously open disk devices, causing attempts to boot from a mirror or RAIDZ to cause a crash. This will be worked around later. The firmwares of newer sun4u models don't seem to exhibit this problem though.
Steps for ZFS booting:
1. create VTOC8 label # gpart create -s vtoc8 da0
2. add partitions, f.e.: # gpart add -t freebsd-zfs -s 60g da0 # gpart add -t freebsd-swap da0 resulting in something like: # gpart show => 0 143331930 da0 VTOC8 (68G) 0 125821080 1 freebsd-zfs (60G) 125821080 17510850 2 freebsd-swap (8.4G)
3. create zpool # zpool create bunker da0a or for mirror/RAIDZ (after preparing additional disks as in steps 1. + 2.): # zpool create bunker mirror da0a da1a # zpool create bunker raidz da0a da1a da2a ...
4. set bootfs # zpool set bootfs=bunker bunker
5. install zfsboot # zpool export bunker # gpart bootcode -p /boot/zfsboot da0
6. write zfsloader to the ZFS Boot Block (so far, there's no dedicated tool for this, so dd(1) has to be used for this purpose) When using mirror/RAIDZ, step 4. and the dd(1) invocation should be repeated for the additional disks in order to be able to boot from another disk in case of failure. # sysctl kern.geom.debugflags=0x10 # dd if=/boot/zfsloader of=/dev/da0a bs=512 oseek=1024 conv=notrunc # zpool import bunker
7. install system on ZFS filesystem Don't forget to set 'zfs_load="YES"' and vfs.root.mountfrom="zfs:bunker" in loader.conf as well as 'zfs_enable="YES"'in rc.conf.
8. copy zpool.cache to the ZFS filesystem cp -p /boot/zfs/zpool.cache /bunker/boot/zfs/zpool.cache
9. set mountpoint # zfs set mountpoint=/ bunker
10. Now, given that aliases for all disks in the zpool exists (check with the `devalias` command on the boot monitor prompt) and disk0 corresponds to da0 (likewise for additional disks), the system can be booted from the ZFS with: {1} ok boot disk0
PR: 165025 Submitted by: Gavin Mu
|