Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Feb 2019 23:55:35 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r344399 - in stable/11: . share/mk stand stand/common stand/efi/boot1 stand/efi/libefi stand/efi/loader stand/i386 stand/i386/boot2 stand/i386/common stand/i386/gptboot stand/i386/gptzf...
Message-ID:  <201902202355.x1KNtZ3c094540@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Feb 20 23:55:35 2019
New Revision: 344399
URL: https://svnweb.freebsd.org/changeset/base/344399

Log:
  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)

Added:
  stable/11/stand/libsa/geli/geli_metadata.c
     - copied unchanged from r336252, head/stand/libsa/geli/geli_metadata.c
  stable/11/stand/libsa/geli/gelidev.c
     - copied unchanged from r336252, head/stand/libsa/geli/gelidev.c
  stable/11/tools/build/options/WITHOUT_LOADER_ZFS
     - copied unchanged from r342793, head/tools/build/options/WITHOUT_LOADER_ZFS
Deleted:
  stable/11/stand/i386/zfsloader/Makefile
  stable/11/stand/man/zfsloader.8
  stable/11/stand/sparc64/zfsloader/Makefile
Modified:
  stable/11/.gitattributes
  stable/11/UPDATING
  stable/11/share/mk/src.opts.mk
  stable/11/stand/common/devopen.c
  stable/11/stand/common/metadata.c
  stable/11/stand/common/paths.h
  stable/11/stand/defs.mk
  stable/11/stand/efi/boot1/Makefile
  stable/11/stand/efi/libefi/Makefile
  stable/11/stand/efi/loader/Makefile
  stable/11/stand/efi/loader/bootinfo.c
  stable/11/stand/i386/Makefile
  stable/11/stand/i386/boot2/Makefile
  stable/11/stand/i386/common/bootargs.h
  stable/11/stand/i386/gptboot/Makefile
  stable/11/stand/i386/gptboot/gptboot.c
  stable/11/stand/i386/gptzfsboot/Makefile
  stable/11/stand/i386/gptzfsboot/gptzfsboot.8
  stable/11/stand/i386/isoboot/Makefile
  stable/11/stand/i386/libi386/Makefile
  stable/11/stand/i386/libi386/biosdisk.c
  stable/11/stand/i386/libi386/bootinfo32.c
  stable/11/stand/i386/libi386/bootinfo64.c
  stable/11/stand/i386/loader/Makefile
  stable/11/stand/i386/loader/main.c
  stable/11/stand/i386/zfsboot/Makefile
  stable/11/stand/i386/zfsboot/zfsboot.8
  stable/11/stand/i386/zfsboot/zfsboot.c
  stable/11/stand/libsa/Makefile
  stable/11/stand/libsa/geli/Makefile.inc
  stable/11/stand/libsa/geli/geliboot.c
  stable/11/stand/libsa/geli/geliboot.h
  stable/11/stand/libsa/geli/geliboot_crypto.c
  stable/11/stand/libsa/geli/geliboot_internal.h
  stable/11/stand/libsa/zfs/libzfs.h
  stable/11/stand/loader.mk
  stable/11/stand/lua/core.lua.8
  stable/11/stand/man/Makefile
  stable/11/stand/man/loader.8
  stable/11/stand/sparc64/Makefile
  stable/11/stand/sparc64/loader/Makefile
  stable/11/stand/userboot/userboot/Makefile
  stable/11/stand/userboot/userboot/bootinfo32.c
  stable/11/tools/build/options/WITHOUT_ZFS
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/.gitattributes
==============================================================================
--- stable/11/.gitattributes	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/.gitattributes	Wed Feb 20 23:55:35 2019	(r344399)
@@ -3,3 +3,4 @@
 *.cpp  diff=cpp
 *.hpp  diff=cpp
 *.py   diff=python
+. svn-properties=svn:keywords=tools/build/options/WITHOUT_LOADER_ZFS

Modified: stable/11/UPDATING
==============================================================================
--- stable/11/UPDATING	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/UPDATING	Wed Feb 20 23:55:35 2019	(r344399)
@@ -16,6 +16,14 @@ from older versions of FreeBSD, try WITHOUT_CLANG and 
 the tip of head, and then rebuild without this option. The bootstrap process
 from older version of current across the gcc/clang cutover is a bit fragile.
 
+20190220:
+	zfsloader's functionality has now been folded into loader.
+	zfsloader is no longer necesasary once you've updated your
+	boot blocks. For a transition period, we will install a
+	hardlink for zfsloader to loader to allow a smooth transition
+	until the boot blocks can be updated (hard link because old
+	zfs boot blocks don't understand symlinks).
+
 20190216:
 	Lualoader has been merged to facilitate testing on this branch.  It's
 	purely opt-in for now by building WITH_LOADER_LUA and WITHOUT_FORTH in

Modified: stable/11/share/mk/src.opts.mk
==============================================================================
--- stable/11/share/mk/src.opts.mk	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/share/mk/src.opts.mk	Wed Feb 20 23:55:35 2019	(r344399)
@@ -183,6 +183,7 @@ __DEFAULT_YES_OPTIONS = \
     WIRELESS \
     WPA_SUPPLICANT_EAPOL \
     ZFS \
+    LOADER_ZFS \
     ZONEINFO
 
 __DEFAULT_NO_OPTIONS = \
@@ -290,10 +291,6 @@ BROKEN_OPTIONS+=LIBSOFT
     ${__T:Mriscv*}
 BROKEN_OPTIONS+=EFI
 .endif
-# GELI isn't supported on !x86
-.if ${__T} != "i386" && ${__T} != "amd64"
-BROKEN_OPTIONS+=LOADER_GELI
-.endif
 # OFW is only for powerpc and sparc64, exclude others
 .if ${__T:Mpowerpc*} == "" && ${__T:Msparc64} == ""
 BROKEN_OPTIONS+=LOADER_OFW
@@ -377,6 +374,7 @@ MK_SOURCELESS_UCODE:= no
 
 .if ${MK_CDDL} == "no"
 MK_ZFS:=	no
+MK_LOADER_ZFS:=	no
 MK_CTF:=	no
 .endif
 

Modified: stable/11/stand/common/devopen.c
==============================================================================
--- stable/11/stand/common/devopen.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/common/devopen.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -32,6 +32,10 @@ __FBSDID("$FreeBSD$");
 
 #include "bootstrap.h"
 
+#ifdef LOADER_GELI_SUPPORT
+#include "geliboot.h"
+#endif
+
 int
 devopen(struct open_file *f, const char *fname, const char **file) 
 {
@@ -43,6 +47,7 @@ devopen(struct open_file *f, const char *fname, const 
 		return (result);
 
 	/* point to device-specific data so that device open can use it */
+	f->f_dev = dev->d_dev;
 	f->f_devdata = dev;
 	result = dev->d_dev->dv_open(f, dev);
 	if (result != 0) {
@@ -51,8 +56,17 @@ devopen(struct open_file *f, const char *fname, const 
 		return (result);
 	}
 
-	/* reference the devsw entry from the open_file structure */
-	f->f_dev = dev->d_dev;
+#ifdef LOADER_GELI_SUPPORT
+	/*
+	 * If f->f_dev is geli-encrypted and we can decrypt it (will prompt for
+	 * pw if needed), this will attach the geli code to the open_file by
+	 * replacing f->f_dev and f_devdata with pointers to a geli_devdesc.
+	 */
+	if (f->f_dev->dv_type == DEVT_DISK) {
+		geli_probe_and_attach(f);
+	}
+#endif
+
 	return (0);
 }
 

Modified: stable/11/stand/common/metadata.c
==============================================================================
--- stable/11/stand/common/metadata.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/common/metadata.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$");
 
 #include "bootstrap.h"
 
+#ifdef LOADER_GELI_SUPPORT
+#include "geliboot.h"
+#endif
+
 #if defined(__sparc64__)
 #include <openfirm.h>
 
@@ -355,7 +359,9 @@ md_load_dual(char *args, vm_offset_t *modulep, vm_offs
 #endif
 	file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
     }
-
+#ifdef LOADER_GELI_SUPPORT
+    geli_export_key_metadata(kfp);
+#endif
 #if defined(__sparc64__)
     file_addmetadata(kfp, MODINFOMD_DTLB_SLOTS,
 	sizeof dtlb_slot, &dtlb_slot);

Modified: stable/11/stand/common/paths.h
==============================================================================
--- stable/11/stand/common/paths.h	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/common/paths.h	Wed Feb 20 23:55:35 2019	(r344399)
@@ -33,7 +33,6 @@
 #define PATH_CONFIG	"/boot/config"
 #define PATH_LOADER	"/boot/loader"
 #define PATH_LOADER_EFI	"/boot/loader.efi"
-#define PATH_LOADER_ZFS	"/boot/zfsloader"
 #define PATH_KERNEL	"/boot/kernel/kernel"
 
 #endif /* _PATHS_H_ */

Modified: stable/11/stand/defs.mk
==============================================================================
--- stable/11/stand/defs.mk	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/defs.mk	Wed Feb 20 23:55:35 2019	(r344399)
@@ -56,7 +56,6 @@ CFLAGS+=	-Ddouble=jagged-little-pill -Dfloat=floaty-mc
 
 
 # GELI Support, with backward compat hooks (mostly)
-.if defined(HAVE_GELI)
 .if defined(LOADER_NO_GELI_SUPPORT)
 MK_LOADER_GELI=no
 .warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
@@ -69,7 +68,6 @@ MK_LOADER_GELI=yes
 CFLAGS+=	-DLOADER_GELI_SUPPORT
 CFLAGS+=	-I${SASRC}/geli
 .endif # MK_LOADER_GELI
-.endif # HAVE_GELI
 
 # These should be confined to loader.mk, but can't because uboot/lib
 # also uses it. It's part of loader, but isn't a loader so we can't

Modified: stable/11/stand/efi/boot1/Makefile
==============================================================================
--- stable/11/stand/efi/boot1/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/efi/boot1/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -24,7 +24,7 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-function
 
 # architecture-specific loader code
 SRCS=	boot1.c self_reloc.c start.S ufs_module.c
-.if ${MK_ZFS} != "no"
+.if ${MK_LOADER_ZFS} != "no"
 SRCS+=		zfs_module.c
 CFLAGS.zfs_module.c+=	-I${ZFSSRC}
 CFLAGS.zfs_module.c+=	-I${SYSDIR}/cddl/boot/zfs
@@ -75,9 +75,6 @@ DPADD+=		${LIBEFI} ${LIBSA}
 LDADD+=		${LIBEFI} ${LIBSA}
 
 DPADD+=		${LDSCRIPT}
-
-NM?=		nm
-OBJCOPY?=	objcopy
 
 .if ${MACHINE_CPUARCH} == "amd64"
 EFI_TARGET=	efi-app-x86_64

Modified: stable/11/stand/efi/libefi/Makefile
==============================================================================
--- stable/11/stand/efi/libefi/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/efi/libefi/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -44,7 +44,7 @@ CFLAGS+= -fPIC -mno-red-zone
 .endif
 CFLAGS+= -I${EFIINC}
 CFLAGS+= -I${EFIINCMD}
-.if ${MK_ZFS} != "no"
+.if ${MK_LOADER_ZFS} != "no"
 CFLAGS+=	-I${ZFSSRC}
 CFLAGS+=	-DEFI_ZFS_BOOT
 .endif

Modified: stable/11/stand/efi/loader/Makefile
==============================================================================
--- stable/11/stand/efi/loader/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/efi/loader/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -24,7 +24,7 @@ SRCS=	autoload.c \
 	smbios.c \
 	vers.c
 
-.if ${MK_ZFS} != "no"
+.if ${MK_LOADER_ZFS} != "no"
 CFLAGS+=	-I${ZFSSRC}
 CFLAGS+=	-DEFI_ZFS_BOOT
 HAVE_ZFS=	yes
@@ -90,9 +90,6 @@ LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -share
 CLEANFILES+=	loader.efi
 
 NEWVERSWHAT=	"EFI loader" ${MACHINE}
-
-NM?=		nm
-OBJCOPY?=	objcopy
 
 .if ${MACHINE_CPUARCH} == "amd64"
 EFI_TARGET=	efi-app-x86_64

Modified: stable/11/stand/efi/loader/bootinfo.c
==============================================================================
--- stable/11/stand/efi/loader/bootinfo.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/efi/loader/bootinfo.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -56,6 +56,10 @@ __FBSDID("$FreeBSD$");
 #include <fdt_platform.h>
 #endif
 
+#ifdef LOADER_GELI_SUPPORT
+#include "geliboot.h"
+#endif
+
 int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp);
 
 extern EFI_SYSTEM_TABLE	*ST;
@@ -452,7 +456,9 @@ bi_load(char *args, vm_offset_t *modulep, vm_offset_t 
 #endif
 	file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
 	file_addmetadata(kfp, MODINFOMD_FW_HANDLE, sizeof ST, &ST);
-
+#ifdef LOADER_GELI_SUPPORT
+	geli_export_key_metadata(kfp);
+#endif
 	bi_load_efi_data(kfp);
 
 	/* Figure out the size and location of the metadata. */

Modified: stable/11/stand/i386/Makefile
==============================================================================
--- stable/11/stand/i386/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -18,6 +18,6 @@ SUBDIR.yes+=	pxeldr
 SUBDIR.yes+=	kgzldr
 .endif
 
-SUBDIR.${MK_ZFS}+=	zfsboot gptzfsboot zfsloader
+SUBDIR.${MK_LOADER_ZFS}+=	zfsboot gptzfsboot
 
 .include <bsd.subdir.mk>

Modified: stable/11/stand/i386/boot2/Makefile
==============================================================================
--- stable/11/stand/i386/boot2/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/boot2/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -4,8 +4,6 @@
 
 FILES=		boot boot1 boot2
 
-NM?=		nm
-
 # A value of 0x80 enables LBA support.
 BOOT_BOOT1_FLAGS?=	0x80
 

Modified: stable/11/stand/i386/common/bootargs.h
==============================================================================
--- stable/11/stand/i386/common/bootargs.h	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/common/bootargs.h	Wed Feb 20 23:55:35 2019	(r344399)
@@ -18,10 +18,11 @@
 #ifndef _BOOT_I386_ARGS_H_
 #define	_BOOT_I386_ARGS_H_
 
-#define	KARGS_FLAGS_CD		0x1
-#define	KARGS_FLAGS_PXE		0x2
-#define	KARGS_FLAGS_ZFS		0x4
-#define	KARGS_FLAGS_EXTARG	0x8	/* variably sized extended argument */
+#define	KARGS_FLAGS_CD		0x0001	/* .bootdev is a bios CD dev */
+#define	KARGS_FLAGS_PXE		0x0002	/* .pxeinfo is valid */
+#define	KARGS_FLAGS_ZFS		0x0004	/* .zfspool is valid, EXTARG is zfs_boot_args */
+#define	KARGS_FLAGS_EXTARG	0x0008	/* variably sized extended argument */
+#define	KARGS_FLAGS_GELI	0x0010	/* EXTARG is geli_boot_args */
 
 #define	BOOTARGS_SIZE	24	/* sizeof(struct bootargs) */
 #define	BA_BOOTFLAGS	8	/* offsetof(struct bootargs, bootflags) */
@@ -43,6 +44,24 @@
 
 #ifndef __ASSEMBLER__
 
+/*
+ * This struct describes the contents of the stack on entry to btxldr.S.  This
+ * is the data that follows the return address, so it begins at 4(%esp).  On
+ * the sending side, this data is passed as individual args to __exec().  On the
+ * receiving side, code in btxldr.S copies the data from the entry stack to a
+ * known fixed location in the new address space.  Then, btxcsu.S sets the
+ * global variable __args to point to that known fixed location before calling
+ * main(), which casts __args to a struct bootargs pointer to access the data.
+ * The btxldr.S code is aware of KARGS_FLAGS_EXTARG, and if it's set, the extra
+ * args data is copied along with the other bootargs from the entry stack to the
+ * fixed location in the new address space.
+ *
+ * The bootinfo field is actually a pointer to a bootinfo struct that has been
+ * converted to uint32_t using VTOP().  On the receiving side it must be
+ * converted back to a pointer using PTOV().  Code in btxldr.S is aware of this
+ * field and if it's non-NULL it copies the data it points to into another known
+ * fixed location, and adjusts the bootinfo field to point to that new location.
+ */
 struct bootargs
 {
 	uint32_t			howto;
@@ -66,11 +85,15 @@ struct bootargs
 
 #ifdef LOADER_GELI_SUPPORT
 #include <crypto/intake.h>
+#include "geliboot.h"
 #endif
 
-struct geli_boot_args
+/*
+ * geli_boot_data is embedded in geli_boot_args (passed from gptboot to loader)
+ * and in zfs_boot_args (passed from zfsboot and gptzfsboot to loader).
+ */
+struct geli_boot_data
 {
-    uint32_t		size;
     union {
         char            gelipw[256];
         struct {
@@ -86,6 +109,49 @@ struct geli_boot_args
 #endif
         };
     };
+};
+
+#ifdef LOADER_GELI_SUPPORT
+
+static inline void
+export_geli_boot_data(struct geli_boot_data *gbdata)
+{
+
+	gbdata->notapw = '\0';
+	gbdata->keybuf_sentinel = KEYBUF_SENTINEL;
+	gbdata->keybuf = malloc(sizeof(struct keybuf) +
+	    (GELI_MAX_KEYS * sizeof(struct keybuf_ent)));
+	geli_export_key_buffer(gbdata->keybuf);
+}
+
+static inline void
+import_geli_boot_data(struct geli_boot_data *gbdata)
+{
+
+	if (gbdata->gelipw[0] != '\0') {
+	    setenv("kern.geom.eli.passphrase", gbdata->gelipw, 1);
+	    explicit_bzero(gbdata->gelipw, sizeof(gbdata->gelipw));
+	} else if (gbdata->keybuf_sentinel == KEYBUF_SENTINEL) {
+	    geli_import_key_buffer(gbdata->keybuf);
+	}
+}
+#endif /* LOADER_GELI_SUPPORT */
+
+struct geli_boot_args
+{
+	uint32_t		size;
+	struct geli_boot_data	gelidata;
+};
+
+struct zfs_boot_args
+{
+	uint32_t		size;
+	uint32_t		reserved;
+	uint64_t		pool;
+	uint64_t		root;
+	uint64_t		primary_pool;
+	uint64_t		primary_vdev;
+	struct geli_boot_data	gelidata;
 };
 
 #endif /*__ASSEMBLER__*/

Modified: stable/11/stand/i386/gptboot/Makefile
==============================================================================
--- stable/11/stand/i386/gptboot/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/gptboot/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -1,15 +1,11 @@
 # $FreeBSD$
 
-HAVE_GELI=		yes
-
 .include <bsd.init.mk>
 
 .PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/common ${SASRC}
 
 FILES=		gptboot
 MAN=		gptboot.8
-
-NM?=		nm
 
 BOOT_COMCONSOLE_PORT?= 0x3f8
 BOOT_COMCONSOLE_SPEED?= 9600

Modified: stable/11/stand/i386/gptboot/gptboot.c
==============================================================================
--- stable/11/stand/i386/gptboot/gptboot.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/gptboot/gptboot.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -81,7 +81,6 @@ uint32_t opts;
 static const char *const dev_nm[NDEV] = {"ad", "da", "fd"};
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
-static struct dsk dsk;
 static char kname[1024];
 static int comspeed = SIOSPD;
 static struct bootinfo bootinfo;
@@ -113,11 +112,19 @@ static int vdev_read(void *vdev __unused, void *priv, 
 #include "ufsread.c"
 #include "gpt.c"
 #ifdef LOADER_GELI_SUPPORT
-#include "geliboot.c"
+#include "geliboot.h"
 static char gelipw[GELI_PW_MAXLEN];
-static struct keybuf *gelibuf;
 #endif
 
+struct gptdsk {
+	struct dsk       dsk;
+#ifdef LOADER_GELI_SUPPORT
+	struct geli_dev *gdev;
+#endif
+};
+
+static struct gptdsk gdsk;
+
 static inline int
 xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
@@ -225,19 +232,21 @@ static int
 gptinit(void)
 {
 
-	if (gptread(&freebsd_ufs_uuid, &dsk, dmadat->secbuf) == -1) {
+	if (gptread(&freebsd_ufs_uuid, &gdsk.dsk, dmadat->secbuf) == -1) {
 		printf("%s: unable to load GPT\n", BOOTPROG);
 		return (-1);
 	}
-	if (gptfind(&freebsd_ufs_uuid, &dsk, dsk.part) == -1) {
+	if (gptfind(&freebsd_ufs_uuid, &gdsk.dsk, gdsk.dsk.part) == -1) {
 		printf("%s: no UFS partition was found\n", BOOTPROG);
 		return (-1);
 	}
 #ifdef LOADER_GELI_SUPPORT
-	if (geli_taste(vdev_read, &dsk, (gpttable[curent].ent_lba_end -
-	    gpttable[curent].ent_lba_start)) == 0) {
-		if (geli_havekey(&dsk) != 0 && geli_passphrase(gelipw,
-		    dsk.unit, 'p', curent + 1, &dsk) != 0) {
+	gdsk.gdev = geli_taste(vdev_read, &gdsk.dsk, 
+	    (gpttable[curent].ent_lba_end - gpttable[curent].ent_lba_start),
+	    "disk%up%u:", gdsk.dsk.unit, curent + 1);
+	if (gdsk.gdev != NULL) {
+		if (geli_havekey(gdsk.gdev) != 0 &&
+		    geli_passphrase(gdsk.gdev, gelipw) != 0) {
 			printf("%s: unable to decrypt GELI key\n", BOOTPROG);
 			return (-1);
 		}
@@ -273,21 +282,18 @@ main(void)
 
 	v86.ctl = V86_FLAGS;
 	v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
-	dsk.drive = *(uint8_t *)PTOV(ARGS);
-	dsk.type = dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
-	dsk.unit = dsk.drive & DRV_MASK;
-	dsk.part = -1;
-	dsk.start = 0;
+	gdsk.dsk.drive = *(uint8_t *)PTOV(ARGS);
+	gdsk.dsk.type = gdsk.dsk.drive & DRV_HARD ? TYPE_AD : TYPE_FD;
+	gdsk.dsk.unit = gdsk.dsk.drive & DRV_MASK;
+	gdsk.dsk.part = -1;
+	gdsk.dsk.start = 0;
 	bootinfo.bi_version = BOOTINFO_VERSION;
 	bootinfo.bi_size = sizeof(bootinfo);
 	bootinfo.bi_basemem = bios_basemem / 1024;
 	bootinfo.bi_extmem = bios_extmem / 1024;
 	bootinfo.bi_memsizes_valid++;
-	bootinfo.bi_bios_dev = dsk.drive;
+	bootinfo.bi_bios_dev = gdsk.dsk.drive;
 
-#ifdef LOADER_GELI_SUPPORT
-	geli_init();
-#endif
 	/* Process configuration file */
 
 	if (gptinit() != 0)
@@ -332,8 +338,8 @@ main(void)
 		load();
 		memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
 		load();
-		gptbootfailed(&dsk);
-		if (gptfind(&freebsd_ufs_uuid, &dsk, -1) == -1)
+		gptbootfailed(&gdsk.dsk);
+		if (gptfind(&freebsd_ufs_uuid, &gdsk.dsk, -1) == -1)
 			break;
 		dsk_meta = 0;
 	}
@@ -345,8 +351,8 @@ main(void)
 			printf("\nFreeBSD/x86 boot\n"
 			    "Default: %u:%s(%up%u)%s\n"
 			    "boot: ",
-			    dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
-			    dsk.part, kname);
+			    gdsk.dsk.drive & DRV_MASK, dev_nm[gdsk.dsk.type],
+			    gdsk.dsk.unit, gdsk.dsk.part, kname);
 		}
 		if (ioctrl & IO_SERIAL)
 			sio_flush();
@@ -392,9 +398,9 @@ load(void)
 	if (!(ino = lookup(kname))) {
 		if (!ls) {
 			printf("%s: No %s on %u:%s(%up%u)\n", BOOTPROG,
-			    kname, dsk.drive & DRV_MASK, dev_nm[dsk.type],
-			    dsk.unit,
-			    dsk.part);
+			    kname, gdsk.dsk.drive & DRV_MASK,
+			    dev_nm[gdsk.dsk.type], gdsk.dsk.unit,
+			    gdsk.dsk.part);
 		}
 		return;
 	}
@@ -469,21 +475,22 @@ load(void)
 	}
 	bootinfo.bi_esymtab = VTOP(p);
 	bootinfo.bi_kernelname = VTOP(kname);
-	bootinfo.bi_bios_dev = dsk.drive;
+	bootinfo.bi_bios_dev = gdsk.dsk.drive;
 #ifdef LOADER_GELI_SUPPORT
 	geliargs.size = sizeof(geliargs);
 	explicit_bzero(gelipw, sizeof(gelipw));
-	gelibuf = malloc(sizeof(struct keybuf) +
-	    (GELI_MAX_KEYS * sizeof(struct keybuf_ent)));
-	geli_fill_keybuf(gelibuf);
-	geliargs.notapw = '\0';
-	geliargs.keybuf_sentinel = KEYBUF_SENTINEL;
-	geliargs.keybuf = gelibuf;
+	export_geli_boot_data(&geliargs.gelidata);
 #endif
+	/*
+	 * Note that the geliargs struct is passed by value, not by pointer.
+	 * Code in btxldr.S copies the values from the entry stack to a fixed
+	 * location within loader(8) at startup due to the presence of the
+	 * KARGS_FLAGS_EXTARG flag.
+	 */
 	__exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK),
-	    MAKEBOOTDEV(dev_maj[dsk.type], dsk.part + 1, dsk.unit, 0xff),
+	    MAKEBOOTDEV(dev_maj[gdsk.dsk.type], gdsk.dsk.part + 1, gdsk.dsk.unit, 0xff),
 #ifdef LOADER_GELI_SUPPORT
-	    KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo), geliargs
+	    KARGS_FLAGS_GELI | KARGS_FLAGS_EXTARG, 0, 0, VTOP(&bootinfo), geliargs
 #else
 	    0, 0, 0, VTOP(&bootinfo)
 #endif
@@ -561,22 +568,22 @@ parse_cmds(char *cmdstr, int *dskupdated)
 				    arg[1] != dev_nm[i][1]; i++)
 					if (i == NDEV - 1)
 						return (-1);
-				dsk.type = i;
+				gdsk.dsk.type = i;
 				arg += 3;
-				dsk.unit = *arg - '0';
-				if (arg[1] != 'p' || dsk.unit > 9)
+				gdsk.dsk.unit = *arg - '0';
+				if (arg[1] != 'p' || gdsk.dsk.unit > 9)
 					return (-1);
 				arg += 2;
-				dsk.part = *arg - '0';
-				if (dsk.part < 1 || dsk.part > 9)
+				gdsk.dsk.part = *arg - '0';
+				if (gdsk.dsk.part < 1 || gdsk.dsk.part > 9)
 					return (-1);
 				arg++;
 				if (arg[0] != ')')
 					return (-1);
 				arg++;
 				if (drv == -1)
-					drv = dsk.unit;
-				dsk.drive = (dsk.type <= TYPE_MAXHARD
+					drv = gdsk.dsk.unit;
+				gdsk.dsk.drive = (gdsk.dsk.type <= TYPE_MAXHARD
 				    ? DRV_HARD : 0) + drv;
 				*dskupdated = 1;
 			}
@@ -596,12 +603,13 @@ dskread(void *buf, daddr_t lba, unsigned nblk)
 {
 	int err;
 
-	err = drvread(&dsk, buf, lba + dsk.start, nblk);
+	err = drvread(&gdsk.dsk, buf, lba + gdsk.dsk.start, nblk);
 
 #ifdef LOADER_GELI_SUPPORT
-	if (err == 0 && is_geli(&dsk) == 0) {
+	if (err == 0 && gdsk.gdev != NULL) {
 		/* Decrypt */
-		if (geli_read(&dsk, lba * DEV_BSIZE, buf, nblk * DEV_BSIZE))
+		if (geli_read(gdsk.gdev, lba * DEV_BSIZE, buf,
+		    nblk * DEV_BSIZE))
 			return (err);
 	}
 #endif
@@ -611,8 +619,8 @@ dskread(void *buf, daddr_t lba, unsigned nblk)
 
 #ifdef LOADER_GELI_SUPPORT
 /*
- * Read function compartible with the ZFS callback, required to keep the GELI
- * Implementation the same for both UFS and ZFS
+ * Read function compatible with the ZFS callback, required to keep the GELI
+ * implementation the same for both UFS and ZFS.
  */
 static int
 vdev_read(void *vdev __unused, void *priv, off_t off, void *buf, size_t bytes)
@@ -620,22 +628,22 @@ vdev_read(void *vdev __unused, void *priv, off_t off, 
 	char *p;
 	daddr_t lba;
 	unsigned int nb;
-	struct dsk *dskp;
+	struct gptdsk *dskp;
 
-	dskp = (struct dsk *)priv;
+	dskp = (struct gptdsk *)priv;
 
 	if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1)))
 		return (-1);
 
 	p = buf;
 	lba = off / DEV_BSIZE;
-	lba += dskp->start;
+	lba += dskp->dsk.start;
 
 	while (bytes > 0) {
 		nb = bytes / DEV_BSIZE;
 		if (nb > VBLKSIZE / DEV_BSIZE)
 			nb = VBLKSIZE / DEV_BSIZE;
-		if (drvread(dskp, dmadat->blkbuf, lba, nb))
+		if (drvread(&dskp->dsk, dmadat->blkbuf, lba, nb))
 			return (-1);
 		memcpy(p, dmadat->blkbuf, nb * DEV_BSIZE);
 		p += nb * DEV_BSIZE;

Modified: stable/11/stand/i386/gptzfsboot/Makefile
==============================================================================
--- stable/11/stand/i386/gptzfsboot/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/gptzfsboot/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -1,7 +1,5 @@
 # $FreeBSD$
 
-HAVE_GELI=	yes
-
 .include <bsd.init.mk>
 
 .PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \
@@ -10,8 +8,6 @@ HAVE_GELI=	yes
 
 FILES=		gptzfsboot
 MAN=		gptzfsboot.8
-
-NM?=		nm
 
 BOOT_COMCONSOLE_PORT?= 0x3f8
 BOOT_COMCONSOLE_SPEED?= 9600

Modified: stable/11/stand/i386/gptzfsboot/gptzfsboot.8
==============================================================================
--- stable/11/stand/i386/gptzfsboot/gptzfsboot.8	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/gptzfsboot/gptzfsboot.8	Wed Feb 20 23:55:35 2019	(r344399)
@@ -71,7 +71,7 @@ If the
 .Cm bootfs
 property is not set, then the root filesystem of the pool is used as
 the default.
-.Xr zfsloader 8
+.Xr loader 8
 is loaded from the boot filesystem.
 If
 .Pa /boot.config
@@ -83,7 +83,7 @@ in the same way as
 .Pp
 The ZFS GUIDs of the first successfully probed device and the first
 detected pool are made available to
-.Xr zfsloader 8
+.Xr loader 8
 in the
 .Cm vfs.zfs.boot.primary_vdev
 and
@@ -104,7 +104,7 @@ accepts all the options that
 supports.
 .Pp
 The filesystem specification and the path to
-.Xr zfsloader 8
+.Xr loader 8
 are different from
 .Xr boot 8 .
 The format is
@@ -116,7 +116,7 @@ The format is
 Both the filesystem and the path can be specified.
 If only a path is specified, then the default filesystem is used.
 If only a pool and filesystem are specified, then
-.Pa /boot/zfsloader
+.Pa /boot/loader
 is used as a path.
 .Pp
 Additionally, the
@@ -128,7 +128,7 @@ The output format is similar to that of
 .Pp
 The configured or automatically determined ZFS boot filesystem is
 stored in the
-.Xr zfsloader 8
+.Xr loader 8
 .Cm loaddev
 variable, and also set as the initial value of the
 .Cm currdev
@@ -171,7 +171,6 @@ gpart bootcode -p /boot/gptzfsboot -i 1 ada0
 .Xr boot 8 ,
 .Xr gpart 8 ,
 .Xr loader 8 ,
-.Xr zfsloader 8 ,
 .Xr zpool 8
 .Sh HISTORY
 .Nm

Modified: stable/11/stand/i386/isoboot/Makefile
==============================================================================
--- stable/11/stand/i386/isoboot/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/isoboot/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -1,7 +1,5 @@
 # $FreeBSD$
 
-HAVE_GELI=		yes
-
 .include <bsd.init.mk>
 
 .PATH:		${BOOTSRC}/i386/boot2 ${BOOTSRC}/i386/gptboot \
@@ -9,8 +7,6 @@ HAVE_GELI=		yes
 
 FILES=		isoboot
 MAN=		isoboot.8
-
-NM?=		nm
 
 BOOT_COMCONSOLE_PORT?= 0x3f8
 BOOT_COMCONSOLE_SPEED?= 9600

Modified: stable/11/stand/i386/libi386/Makefile
==============================================================================
--- stable/11/stand/i386/libi386/Makefile	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/libi386/Makefile	Wed Feb 20 23:55:35 2019	(r344399)
@@ -1,7 +1,5 @@
 # $FreeBSD$
 
-HAVE_GELI=		yes
-
 .include <bsd.init.mk>
 
 LIB=			i386

Modified: stable/11/stand/i386/libi386/biosdisk.c
==============================================================================
--- stable/11/stand/i386/libi386/biosdisk.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/libi386/biosdisk.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -50,34 +50,6 @@ __FBSDID("$FreeBSD$");
 #include "disk.h"
 #include "libi386.h"
 
-#ifdef LOADER_GELI_SUPPORT
-#include "cons.h"
-#include "drv.h"
-#include "gpt.h"
-#include "part.h"
-#include <uuid.h>
-struct pentry {
-	struct ptable_entry	part;
-	uint64_t		flags;
-	union {
-		uint8_t bsd;
-		uint8_t	mbr;
-		uuid_t	gpt;
-		uint16_t vtoc8;
-	} type;
-	STAILQ_ENTRY(pentry)	entry;
-};
-struct ptable {
-	enum ptable_type	type;
-	uint16_t		sectorsize;
-	uint64_t		sectors;
-
-	STAILQ_HEAD(, pentry)	entries;
-};
-
-#include "geliboot.c"
-#endif /* LOADER_GELI_SUPPORT */
-
 #define BIOS_NUMDRIVES		0x475
 #define BIOSDISK_SECSIZE	512
 #define BUFSIZE			(1 * BIOSDISK_SECSIZE)
@@ -138,17 +110,6 @@ static int bd_close(struct open_file *f);
 static int bd_ioctl(struct open_file *f, u_long cmd, void *data);
 static int bd_print(int verbose);
 
-#ifdef LOADER_GELI_SUPPORT
-enum isgeli {
-	ISGELI_UNKNOWN,
-	ISGELI_NO,
-	ISGELI_YES
-};
-static enum isgeli geli_status[MAXBDDEV][MAXTBLENTS];
-
-int bios_read(void *, void *, off_t off, void *buf, size_t bytes);
-#endif /* LOADER_GELI_SUPPORT */
-
 struct devsw biosdisk = {
 	"disk",
 	DEVT_DISK,
@@ -195,9 +156,6 @@ bd_init(void)
 {
 	int base, unit, nfd = 0;
 
-#ifdef LOADER_GELI_SUPPORT
-	geli_init();
-#endif
 	/* sequence 0, 0x80 */
 	for (base = 0; base <= 0x80; base += 0x80) {
 		for (unit = base; (nbdinfo < MAXBDDEV); unit++) {
@@ -379,7 +337,7 @@ bd_print(int verbose)
 static int
 bd_open(struct open_file *f, ...)
 {
-	struct disk_devdesc *dev;
+	struct disk_devdesc *dev, rdev;
 	struct disk_devdesc disk;
 	int err, g_err;
 	va_list ap;
@@ -421,81 +379,6 @@ bd_open(struct open_file *f, ...)
 	err = disk_open(dev, BD(dev).bd_sectors * BD(dev).bd_sectorsize,
 	    BD(dev).bd_sectorsize);
 
-#ifdef LOADER_GELI_SUPPORT
-	static char gelipw[GELI_PW_MAXLEN];
-	char *passphrase;
-
-	if (err)
-		return (err);
-
-	/* if we already know there is no GELI, skip the rest */
-	if (geli_status[dev->dd.d_unit][dev->d_slice] != ISGELI_UNKNOWN)
-		return (err);
-
-	struct dsk dskp;
-	struct ptable *table = NULL;
-	struct ptable_entry part;
-	struct pentry *entry;
-	int geli_part = 0;
-
-	dskp.drive = bd_unit2bios(dev->dd.d_unit);
-	dskp.type = dev->dd.d_dev->dv_type;
-	dskp.unit = dev->dd.d_unit;
-	dskp.slice = dev->d_slice;
-	dskp.part = dev->d_partition;
-	dskp.start = dev->d_offset;
-
-	/* We need the LBA of the end of the partition */
-	table = ptable_open(&disk, BD(dev).bd_sectors,
-	    BD(dev).bd_sectorsize, ptblread);
-	if (table == NULL) {
-		DEBUG("Can't read partition table");
-		/* soft failure, return the exit status of disk_open */
-		return (err);
-	}
-
-	if (table->type == PTABLE_GPT)
-		dskp.part = 255;
-
-	STAILQ_FOREACH(entry, &table->entries, entry) {
-		dskp.slice = entry->part.index;
-		dskp.start = entry->part.start;
-		if (is_geli(&dskp) == 0) {
-			geli_status[dev->dd.d_unit][dskp.slice] = ISGELI_YES;
-			return (0);
-		}
-		if (geli_taste(bios_read, &dskp,
-		    entry->part.end - entry->part.start) == 0) {
-			if (geli_havekey(&dskp) == 0) {
-				geli_status[dev->dd.d_unit][dskp.slice] = ISGELI_YES;
-				geli_part++;
-				continue;
-			}
-			if ((passphrase = getenv("kern.geom.eli.passphrase"))
-			    != NULL) {
-				/* Use the cached passphrase */
-				bcopy(passphrase, &gelipw, GELI_PW_MAXLEN);
-			}
-			if (geli_passphrase(gelipw, dskp.unit, 'p',
-				    (dskp.slice > 0 ? dskp.slice : dskp.part),
-				    &dskp) == 0) {
-				setenv("kern.geom.eli.passphrase", gelipw, 1);
-				bzero(gelipw, sizeof(gelipw));
-				geli_status[dev->dd.d_unit][dskp.slice] = ISGELI_YES;
-				geli_part++;
-				continue;
-			}
-		} else
-			geli_status[dev->dd.d_unit][dskp.slice] = ISGELI_NO;
-	}
-
-	/* none of the partitions on this disk have GELI */
-	if (geli_part == 0) {
-		/* found no GELI */
-		geli_status[dev->dd.d_unit][dev->d_slice] = ISGELI_NO;
-	}
-#endif /* LOADER_GELI_SUPPORT */
-
 	return (err);
 }
 
@@ -841,80 +724,7 @@ bd_io(struct disk_devdesc *dev, daddr_t dblk, int blks
 static int
 bd_read(struct disk_devdesc *dev, daddr_t dblk, int blks, caddr_t dest)
 {
-#ifdef LOADER_GELI_SUPPORT
-	struct dsk dskp;
-	off_t p_off, diff;
-	daddr_t alignlba;
-	int err, n, alignblks;
-	char *tmpbuf;
 
-	/* if we already know there is no GELI, skip the rest */
-	if (geli_status[dev->dd.d_unit][dev->d_slice] != ISGELI_YES)
-		return (bd_io(dev, dblk, blks, dest, 0));
-
-	if (geli_status[dev->dd.d_unit][dev->d_slice] == ISGELI_YES) {
-		/*
-		 * Align reads to DEV_GELIBOOT_BSIZE bytes because partial
-		 * sectors cannot be decrypted. Round the requested LBA down to
-		 * nearest multiple of DEV_GELIBOOT_BSIZE bytes.
-		 */
-		alignlba = rounddown2(dblk * BD(dev).bd_sectorsize,
-		    DEV_GELIBOOT_BSIZE) / BD(dev).bd_sectorsize;
-		/*
-		 * Round number of blocks to read up to nearest multiple of
-		 * DEV_GELIBOOT_BSIZE
-		 */
-		diff = (dblk - alignlba) * BD(dev).bd_sectorsize;
-		alignblks = roundup2(blks * BD(dev).bd_sectorsize + diff,
-		    DEV_GELIBOOT_BSIZE) / BD(dev).bd_sectorsize;
-
-		/*
-		 * If the read is rounded up to a larger size, use a temporary
-		 * buffer here because the buffer provided by the caller may be
-		 * too small.
-		 */
-		if (diff == 0) {
-			tmpbuf = dest;
-		} else {
-			tmpbuf = malloc(alignblks * BD(dev).bd_sectorsize);
-			if (tmpbuf == NULL) {
-				return (-1);
-			}
-		}
-
-		if (alignlba + alignblks > BD(dev).bd_sectors) {
-			DEBUG("Shorted read at %llu from %d to %llu blocks",
-			    alignlba, alignblks, BD(dev).bd_sectors - alignlba);
-			alignblks = BD(dev).bd_sectors - alignlba;
-		}
-
-		err = bd_io(dev, alignlba, alignblks, tmpbuf, 0);
-		if (err)
-			return (err);
-
-		dskp.drive = bd_unit2bios(dev->dd.d_unit);
-		dskp.type = dev->dd.d_dev->dv_type;
-		dskp.unit = dev->dd.d_unit;
-		dskp.slice = dev->d_slice;
-		dskp.part = dev->d_partition;
-		dskp.start = dev->d_offset;
-
-		/* GELI needs the offset relative to the partition start */
-		p_off = alignlba - dskp.start;
-
-		err = geli_read(&dskp, p_off * BD(dev).bd_sectorsize, (u_char *)tmpbuf,
-		    alignblks * BD(dev).bd_sectorsize);
-		if (err)
-			return (err);
-
-		if (tmpbuf != dest) {
-			bcopy(tmpbuf + diff, dest, blks * BD(dev).bd_sectorsize);
-			free(tmpbuf);
-		}
-		return (0);
-	}
-#endif /* LOADER_GELI_SUPPORT */
-
 	return (bd_io(dev, dblk, blks, dest, 0));
 }
 
@@ -1009,25 +819,3 @@ bd_getdev(struct i386_devdesc *d)
     DEBUG("dev is 0x%x\n", rootdev);
     return(rootdev);
 }
-
-#ifdef LOADER_GELI_SUPPORT
-int
-bios_read(void *vdev __unused, void *xpriv, off_t off, void *buf, size_t bytes)
-{
-	struct disk_devdesc dev;
-	struct dsk *priv = xpriv;
-
-	dev.dd.d_dev = &biosdisk;
-	dev.dd.d_unit = priv->unit;
-	dev.d_slice = priv->slice;
-	dev.d_partition = priv->part;
-	dev.d_offset = priv->start;
-
-	off = off / BD(&dev).bd_sectorsize;
-	/* GELI gives us the offset relative to the partition start */
-	off += dev.d_offset;
-	bytes = bytes / BD(&dev).bd_sectorsize;
-
-	return (bd_io(&dev, off, bytes, buf, 0));
-}
-#endif /* LOADER_GELI_SUPPORT */

Modified: stable/11/stand/i386/libi386/bootinfo32.c
==============================================================================
--- stable/11/stand/i386/libi386/bootinfo32.c	Wed Feb 20 23:53:39 2019	(r344398)
+++ stable/11/stand/i386/libi386/bootinfo32.c	Wed Feb 20 23:55:35 2019	(r344399)
@@ -39,9 +39,6 @@ __FBSDID("$FreeBSD$");
 
 #ifdef LOADER_GELI_SUPPORT
 #include "geliboot.h"
-
-static const size_t keybuf_size = sizeof(struct keybuf) +
-    (GELI_MAX_KEYS * sizeof(struct keybuf_ent));
 #endif
 
 static struct bootinfo  bi;
@@ -154,10 +151,6 @@ bi_load32(char *args, int *howtop, int *bootdevp, vm_o
     int				bootdevnr, i, howto;
     char			*kernelname;
     const char			*kernelpath;
-#ifdef LOADER_GELI_SUPPORT
-    char                        buf[keybuf_size];
-    struct keybuf               *keybuf = (struct keybuf *)buf;
-#endif
 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



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