Bug 223969 - EFI boot failure with iPXE mapped disks
Summary: EFI boot failure with iPXE mapped disks
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-29 14:46 UTC by Jeff Pieper
Modified: 2018-02-12 17:45 UTC (History)
3 users (show)

See Also:


Attachments
efi boot error screen cap (59.37 KB, image/jpeg)
2017-11-29 14:46 UTC, Jeff Pieper
no flags Details
loader lsdev -v (56.06 KB, image/jpeg)
2017-11-29 15:13 UTC, Jeff Pieper
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Pieper 2017-11-29 14:46:07 UTC
Created attachment 188396 [details]
efi boot error screen cap

We are seeing EFI disk errors resulting boot failure using a fresh build of HEAD. This was built on 2017-11-28 (see attached screen cap). The disk layout is:

# gpart show ada0
=>        40  3907029088  ada0  GPT  (1.8T)
          40   134217728     1  freebsd-swap  (64G)
   134217768    41943040     2  freebsd-ufs  (20G)
   176160808  3730868320        - free -  (1.7T)

Possibly related to https://svnweb.freebsd.org/base?view=revision&revision=326089 

I can work around this by using /boot/loader.efi from an older build.
Comment 1 Toomas Soome freebsd_committer freebsd_triage 2017-11-29 15:02:13 UTC
ok, error 12 from screen dump is:
#define EFI_NO_MEDIA                    EFIERR(12)

So in that case we are attempting to read from some odd device.

could you also paste output from loader: lsdev -v
Comment 2 Jeff Pieper 2017-11-29 15:13:02 UTC
Created attachment 188397 [details]
loader lsdev -v
Comment 3 Jeff Pieper 2017-11-29 15:15:17 UTC
Attached screen cap. Just an FYI, we are not booting from disk. We are running PXE/diskless. The physical disks are for local storage to avoid writing over NFS.
Comment 4 Toomas Soome freebsd_committer freebsd_triage 2017-11-29 15:32:56 UTC
Okay, so it does take net0 as disk device. BTW, is there iPXE also used? I do recall some comments about iPXE mapped disks...
Comment 5 Jeff Pieper 2017-11-29 15:39:14 UTC
Yes, we are using iPXE.
Comment 6 Toomas Soome freebsd_committer freebsd_triage 2017-11-29 15:51:35 UTC
Could you test this update:

Index: stand/efi/libefi/efipart.c
===================================================================
--- stand/efi/libefi/efipart.c	(revision 326368)
+++ stand/efi/libefi/efipart.c	(working copy)
@@ -257,6 +257,15 @@
 		    !blkio->Media->MediaPresent) {
 			return (false);
 		}
+
+		/*
+		 * iPXE stub Block IO protocol. Test for "iPXE" in MediaID
+		 * and BlockSize.
+		 */
+		if (blkio->Media->MediaId == 0x69505845U &&
+		    blkio->Media->BlockSize == 1) {
+			return (false);
+		}
 	}
 	return (true);
 }
Comment 7 Jeff Pieper 2017-11-29 18:02:59 UTC
This patch works for us, thanks!
Comment 8 Toomas Soome freebsd_committer freebsd_triage 2017-11-29 18:15:11 UTC
(In reply to Jeff Pieper from comment #7)

OK, thank you. 

https://reviews.freebsd.org/D13297
Comment 9 commit-hook freebsd_committer freebsd_triage 2017-12-01 06:37:57 UTC
A commit references this bug:

Author: tsoome
Date: Fri Dec  1 06:37:12 UTC 2017
New revision: 326421
URL: https://svnweb.freebsd.org/changeset/base/326421

Log:
  loader.efi: efipart should exclude iPXE stub block protocol

  iPXE does insert stub  BLOCK IO protocol handle to rework other issues,
  this handle is not usable as it does not provide actual implementation.

  We can detect this situation by checking and validating the BlockSize
  property, so this update does make sure we have BlockSize at least 512B
  and its value is power of 2.

  PR:		223969
  Reported by:	Jeff Pieper
  Reviewed by:	imp
  Differential Revision:	https://reviews.freebsd.org/D13297

Changes:
  head/stand/efi/libefi/efipart.c
Comment 10 commit-hook freebsd_committer freebsd_triage 2018-02-12 17:45:18 UTC
A commit references this bug:

Author: kevans
Date: Mon Feb 12 17:44:38 UTC 2018
New revision: 329175
URL: https://svnweb.freebsd.org/changeset/base/329175

Log:
  MFC Loader Fixes 2017q4p7: r324844,r326089,r326926,r326440,r326484,r326494,
  r326588,r326708,r326784,r326914,r327390,r328446,r326090,r326143,r326144,
  r326182,r326384,r326421,r326440,r326441,r326442,r326443,r326444,r326445,
  r326446,r326447,r326448,r326484,r326485,r326486,r326487,r326488,r326490,
  r326491,r326492,r326493,r326494,r326495,r326504,r326507,r326509,r326584,
  r326585,r326586,r326587,r326588,r326589,r326590,r326591,r326592,r326593,
  r326594,r326600,r326616,r326671,r326707,r326708,r326709,r326710,r326711,
  r326712,r326714,r326720,r326768,r326772,r326784,r326792,r326812,r326854,
  r326855,r326856,r326858,r326886,r326887,r326914,r326926,r326927,r326960,
  r326961,r326962,r326963,r327351,r327453,r327390,r327523,r327524,r326489,
  r327880,r328437,r328438,r328439,r328441,r328446,r328448,r328449,r328612,
  r328613,r328615

  While here, undo our libfdt hack of not including <stdlib.h> if we're
  compiling _STANDALONE.

  r324844: When building standalone, don't define errno. Let the definition from
  stand.h override. This is similar to what we do in the kernel.

  r326089: loader.efi: efipart does not recognize partitionless disks

  r326090: net_parse_rootpath() has no parameters

  r326143: Fix theoretical integer overflow issues. If the product here is

  r326144: Mark the func pointer as __dead2. It looks up loader_main, which

  r326182: Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems

  r326384: Use const pointers to avoid casting away constness.

  r326421: loader.efi: efipart should exclude iPXE stub block protocol

  r326440: Remove stale dependency on ufsread.c

  r326441: Minor flags cleanup

  r326442: Cleanup CFALGS usage here

  r326443: We don't need both _STAND and _STANDALONE, use the latter.

  r326444: Move geli to common DO32 stuff

  r326445: Fix random() and srandom() prototypes to match the standard.

  r326446: Undefine _STANDALONE since this is test code.

  r326447: Tweaks to the beri boot loader so that it builds w/o warnings.

  r326448: Fix all warnings related to geli and ZFS support on x86.

  r326484: Const poison the propname.

  r326485: Delcare md_load in libofw.h. Make all prototypes match for ofw

  r326486: Include machine/md_var to pick up __syncicache prototype.

  r326487: Cast mdp (a vm_offset_t) to void * to match prototype.

  r326488: e_entry can be smaller than a pointer. Cast it to an intptr_t

  r326490: Declare our strange brand of main().

  r326491: Disconnet ps3 from the build. There's too many warnings to fix.

  r326492: Cast void * pointer to char * so the arg matches the %s format.

  r326493: Provide a md_load64 prototype.

  r326494: Mark two things as unused (since they are only sometimes used)

  r326495: Now it's safe to bump WARNS to 1.

  r326504: Switch to proper MK_LOADER_GELI tests.

  r326507: increase maximum size of zfsboot

  r326509: loader.efi: add note about iPXE into the efipart.c

  r326584: When building standalone, include stand.h rather than the kernel

  r326585: Include ficl.h before anything else

  r326586: No need to include the userland md5.h, the kernel one is just fine.

  r326587: Use the kernel relative paths, rather than the userland relative
  paths

  r326588: Need to include skein in the include path

  r326589: Make sure we include the right path for skein.h

  r326590: Prefer stdint.h to inttypes.h

  r326591: This isn't NetBSD specific code. Include these for any kernel /

  r326592: Don't inherit CFLAGS. This a specialized test program.

  r326593: Stop building with the standard system headers.

  r326594: Now that we offer a semi-sane standards-ish set of #include files,
  stop hacking includes with sed.

  r326600: Since this is contrib code, create an upstreamable version of my

  r326616: dhcp_try_rfc1048() is not used any more

  r326671: Avoid setting -Wno-tentative-definition-incomplete-type with gcc.

  r326707: Add partial support signal.h functioanlity. Pull in
  machine/signal.h

  r326708: Remove _KERNEL hack now that errno.h does the right thing when
  built standalone.

  r326709: Provide implementations for iscntrl, ispunct and isgraph.

  r326710: Put the files we're copying over into a few variables and clean
  hings up.

  r326711: Const poison a couple of interfaces.

  r326712: Create interp class.

  r326714: boot1.c needs EFI_ZFS_BOOT too, so add it globally.

  r326720: This path belongs in ficl/Makefile, not the common defines for
  users

  r326768: Fix a comment to be more accurate

  r326772: Fix regression with lua import

  r326784: Revert part of 362772. It was causing problems for includes

  r326792: Attempt to unbreak buildworld

  r326812: Revert r326792, r326784, r326772, r326712

  r326854: libefi: make efichar.h more usable in stand code

  r326855: Cargo cut a fix for the regressions r326585 caused.

  r326856: Fix comments after bump in size.

  r326858: Revert r326855: Cargo cut a fix for the regressions r326585 caused.

  r326886: Panic in sbrk if setheap hasn't been called yet. This is preferable
  o a mysterious crash

  r326887: Remove the 'mini libstand in libstand' that util.[ch] provided.

  r326914: Move loader-only defines to loader.mk from defs.mk

  r326926: Move loader help file definitions to being 100% inside of
  loader.mk.

  r326927: libficl is only ever used in a loader (never a boot) program. Move
  it.

  r326960: Simplify things a little. The RETURN macro isn't required.

  r326961: Interact is always called with NULL. Simplify code a little

  r326962: Hoist btx include stuff to i386/Makefile.inc

  r326963: No need to use relative paths like this here.

  r327351: Fix ubldr. uboot/lib uses defines for the loader.

  r327453: Add a validbcd() routine that uses the bcd2bin_data[] array

  r327390: Garbage-collect loader.ps3. It is currently disconnected from the
  build and kboot replaces.

  r327523: Don't clobber system LDFLAGS for beri boot loaders.

  r327524: Use 'extern uint8_t' instead of 'extern void' for external symbols.

  r326489: Allow this file to be used in libsa without warning...

  r327880: Move getsecs() prototype to stand.h from net.h so it can be used

  r328437: Split panic routine

  r328438: Implement abort() as a call to panic.

  r328439: Provide abs form stdlib.h.

  r328441: abort() should be marked __dead2 since it won't return.

  r328446: Now that exit is __dead2, we need to tag ub_exit() as __dead2.

  r328448: Make exit() never return until host_exit can be written.

  r328449: Tag unreachable places as such. I left the while (1); in place

  r328612: Move strtold wrapper from strtol.c to its own strtold.c.

  r328613: Kill copies of strtol and strtoul.

  r328615: Update stand.h for changes for strto*l

  PR:		223969

Changes:
_U  stable/11/
  stable/11/contrib/compiler-rt/lib/builtins/int_lib.h
  stable/11/lib/libc/stdlib/Makefile.inc
  stable/11/lib/libc/stdlib/strtol.c
  stable/11/lib/libc/stdlib/strtold.c
  stable/11/stand/Makefile.amd64
  stable/11/stand/Makefile.i386
  stable/11/stand/Makefile.inc
  stable/11/stand/arm/uboot/Makefile
  stable/11/stand/common/bootstrap.h
  stable/11/stand/common/dev_net.c
  stable/11/stand/common/interp.c
  stable/11/stand/common/interp_backslash.c
  stable/11/stand/common/interp_forth.c
  stable/11/stand/common/interp_parse.c
  stable/11/stand/common/load_elf.c
  stable/11/stand/common/load_elf_obj.c
  stable/11/stand/common/reloc_elf.c
  stable/11/stand/defs.mk
  stable/11/stand/efi/boot1/Makefile
  stable/11/stand/efi/boot1/boot1.c
  stable/11/stand/efi/include/efichar.h
  stable/11/stand/efi/libefi/Makefile
  stable/11/stand/efi/libefi/efichar.c
  stable/11/stand/efi/libefi/efipart.c
  stable/11/stand/efi/loader/Makefile
  stable/11/stand/efi/loader/main.c
  stable/11/stand/ficl/Makefile
  stable/11/stand/ficl/float.c
  stable/11/stand/ficl.mk
  stable/11/stand/geli/Makefile
  stable/11/stand/geli/geliboot.c
  stable/11/stand/geli/geliboot_internal.h
  stable/11/stand/i386/Makefile.inc
  stable/11/stand/i386/boot2/Makefile
  stable/11/stand/i386/common/cons.c
  stable/11/stand/i386/common/drv.c
  stable/11/stand/i386/gptboot/Makefile
  stable/11/stand/i386/gptboot/gptboot.c
  stable/11/stand/i386/gptboot/gptldr.S
  stable/11/stand/i386/gptzfsboot/Makefile
  stable/11/stand/i386/libfirewire/Makefile
  stable/11/stand/i386/libi386/Makefile
  stable/11/stand/i386/libi386/biosdisk.c
  stable/11/stand/i386/libi386/multiboot.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.c
  stable/11/stand/libsa/Makefile
  stable/11/stand/libsa/abort.c
  stable/11/stand/libsa/bootp.c
  stable/11/stand/libsa/bootp.h
  stable/11/stand/libsa/cd9660.c
  stable/11/stand/libsa/gpt.c
  stable/11/stand/libsa/net.h
  stable/11/stand/libsa/panic.c
  stable/11/stand/libsa/sbrk.c
  stable/11/stand/libsa/stand.h
  stable/11/stand/libsa/strtol.c
  stable/11/stand/libsa/strtoul.c
  stable/11/stand/libsa/util.c
  stable/11/stand/libsa/util.h
  stable/11/stand/libsa/xlocale_private.h
  stable/11/stand/loader.mk
  stable/11/stand/mips/beri/boot2/Makefile
  stable/11/stand/mips/beri/boot2/boot2.c
  stable/11/stand/mips/beri/common/altera_jtag_uart.c
  stable/11/stand/mips/beri/common/cfi.c
  stable/11/stand/mips/beri/common/sdcard.c
  stable/11/stand/mips/beri/loader/Makefile
  stable/11/stand/mips/beri/loader/devicename.c
  stable/11/stand/mips/beri/loader/exec.c
  stable/11/stand/mips/beri/loader/loader.h
  stable/11/stand/mips/beri/loader/main.c
  stable/11/stand/mips/uboot/Makefile
  stable/11/stand/mips/uboot/conf.c
  stable/11/stand/ofw/common/main.c
  stable/11/stand/ofw/libofw/elf_freebsd.c
  stable/11/stand/ofw/libofw/libofw.h
  stable/11/stand/ofw/libofw/openfirm.c
  stable/11/stand/ofw/libofw/openfirm.h
  stable/11/stand/ofw/libofw/ppc64_elf_freebsd.c
  stable/11/stand/powerpc/Makefile
  stable/11/stand/powerpc/boot1.chrp/Makefile
  stable/11/stand/powerpc/boot1.chrp/boot1.c
  stable/11/stand/powerpc/kboot/Makefile
  stable/11/stand/powerpc/kboot/host_syscall.h
  stable/11/stand/powerpc/kboot/hostdisk.c
  stable/11/stand/powerpc/kboot/kbootfdt.c
  stable/11/stand/powerpc/kboot/main.c
  stable/11/stand/powerpc/kboot/ppc64_elf_freebsd.c
  stable/11/stand/powerpc/ofw/Makefile
  stable/11/stand/powerpc/ofw/start.c
  stable/11/stand/powerpc/ps3/
  stable/11/stand/powerpc/uboot/Makefile
  stable/11/stand/sparc64/boot1/Makefile
  stable/11/stand/sparc64/loader/Makefile
  stable/11/stand/sparc64/loader/main.c
  stable/11/stand/sparc64/loader/metadata.c
  stable/11/stand/uboot/common/main.c
  stable/11/stand/uboot/lib/glue.c
  stable/11/stand/uboot/lib/glue.h
  stable/11/stand/userboot/test/Makefile
  stable/11/stand/userboot/test/test.c
  stable/11/stand/userboot/userboot/Makefile
  stable/11/stand/userboot/userboot/main.c
  stable/11/stand/zfs/zfsimpl.c
  stable/11/sys/cddl/boot/zfs/zfssubr.c
  stable/11/sys/contrib/libfdt/libfdt_env.h
  stable/11/sys/geom/eli/g_eli_hmac.c
  stable/11/sys/geom/eli/pkcs5v2.c
  stable/11/sys/opencrypto/xform_userland.h
  stable/11/sys/sys/errno.h
  stable/11/sys/sys/libkern.h
  stable/11/sys/sys/syslimits.h