|Summary:||gptboot broken when compiled with clang 6 and WITHOUT_LOADER_GELI -- clang 5 is OK|
|Product:||Base System||Reporter:||Andre Albsmeier <mail>|
|Component:||bin||Assignee:||Kyle Evans <kevans>|
|Severity:||Affects Some People||CC:||emaste, guyyur, kevans|
Description Andre Albsmeier 2018-05-11 10:00:43 UTC
FreeBSD 11.2 r333382 (or older if clang 6 is used) When compiled with clang 6 and WITHOUT_LOADER_GELI gptboot hangs where stage 2 should be run -- when the '\' should start spinning the screen turns white and the box hangs (tested on two machines, an Asus P5W and a Supermicro A2SAV). The gptboot in question is: -r--r--r-- 1 root wheel 20859 11 May 11:46 /boot/gptboot It worked as long as clang 5 was in the base system. It also works 1. if WITHOUT_LOADER_GELI is removed. The resulting gptboot is: -r--r--r-- 1 root wheel 66082 11 May 11:49 /boot/gptboot or 2. if -O1 is changed to -O2 in stand/i386/gptboot/Makefile. The resulting gptboot is: -r--r--r-- 1 root wheel 22023 11 May 11:48 /boot/gptboot See also: https://lists.freebsd.org/pipermail/freebsd-stable/2018-April/088814.html
Comment 1 guyyur 2018-06-16 16:22:50 UTC
I got a similar issue with 12-CURRENT and WITHOUT_LOADER_GELI in VirtualBox. I got: "can't work out which disk we are booting from. Guessed BIOS device 0x80 not found by probes, defaulting to disk0: can't load 'kernel'" "lsdev" output was empty. The problem is passing KARGS_FLAGS_EXTARG to __exec when no extra params are passed (r316078 added the ifdef for LOADER_GELI_SUPPORT on __exec). I am not familiar with btx so I don't know how this affects loader but for me it caused bd_int13probe int13 08h to fail. Attaching patch for gptboot and isoboot (doesn't use geli so shouldn't pass KARGS_FLAGS_EXTARG) on 12-CURRENT. I think it should apply cleanly to 11.2 too.
Comment 2 guyyur 2018-06-16 16:23:42 UTC
Created attachment 194309 [details] only pass KARGS_FLAGS_EXTARG when geliargs are passed
Comment 3 Andre Albsmeier 2018-06-17 07:21:31 UTC
I tested your gptboot patch and can confirm that it solves the problem. I am using a slightly modified version which is functionally the same but I find the resulting gptboot.c a bit more legible.
Comment 4 Andre Albsmeier 2018-06-17 07:22:48 UTC
Created attachment 194318 [details] slightly more legible patch (only for gptboot.c)
Comment 5 commit-hook 2018-08-09 02:07:09 UTC
A commit references this bug: Author: kevans Date: Thu Aug 9 02:06:26 UTC 2018 New revision: 337520 URL: https://svnweb.freebsd.org/changeset/base/337520 Log: isoboot, gptboot: Fix WITHOUT_LOADER_GELI (gptboot) and isoboot in general gptboot was broken when r316078 added the LOADER_GELI_SUPPORT #ifdef to not pass geliargs via __exec. KARGS_FLAGS_EXTARG must not be used if we're not going to pass an additional argument to __exec. PR: 228151 Submitted by: email@example.com MFC after: 1 week Changes: head/stand/i386/gptboot/gptboot.c head/stand/i386/isoboot/isoboot.c
Comment 6 Kyle Evans 2018-08-09 02:08:48 UTC
Comment 7 Kyle Evans 2018-08-14 01:29:17 UTC
Additional thanks for pointing out the case in isoboot- isoboot was reportedly broken and hybrid ISOs in stable/11, but the cause wasn't immediately obvious. This indeed turned out to be the problem.
Comment 8 commit-hook 2018-08-14 19:45:06 UTC
A commit references this bug: Author: kevans Date: Tue Aug 14 19:44:37 UTC 2018 New revision: 337816 URL: https://svnweb.freebsd.org/changeset/base/337816 Log: MFC r337520: Fix WITHOUT_LOADER_GELI (gptboot) and isoboot in general gptboot was broken when r316078 added the LOADER_GELI_SUPPORT #ifdef to not pass geliargs via __exec. KARGS_FLAGS_EXTARG must not be used if we're not going to pass an additional argument to __exec. PR: 228151 Changes: _U stable/11/ stable/11/stand/i386/gptboot/gptboot.c stable/11/stand/i386/isoboot/isoboot.c