Bug 244906 - kernel booted by loader.efi on VMware Fusion crashes in EFI firmware
Summary: kernel booted by loader.efi on VMware Fusion crashes in EFI firmware
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
Keywords: uefi
Depends on:
Reported: 2020-03-19 12:19 UTC by Francis Dupont
Modified: 2020-12-04 08:38 UTC (History)
11 users (show)

See Also:

Screenshot of failure (59.95 KB, image/png)
2020-10-31 15:22 UTC, Roger Leigh
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Francis Dupont 2020-03-19 12:19:34 UTC
It is a known issue generic to some VMware products (https://www.reddit.com/r/freebsd/comments/drxqlm/failed_to_do_efi_boot_on_a_vmware_virtual_machine/f6om6p2/) and restoring a previous version of /boot/loader.edi works well.

So the bug is between 13.0-CURRENT loader.efi and VMware EFI firmware.

Unfortunately VMware does not give information (other than the firmware crashes) so I am afraid the bug will be hard to find. BTW I have a pretty fast host so I can help.
Comment 1 Ruslan Garipov 2020-03-20 15:00:57 UTC
After r358989 I unable to boot my FreeBSD 13.0-CURRENT VMware guest
systems anymore.  Even with that ``loader prompt trick''.

I wrote to Toomas Soome, and he said[1] that:

> Regarding the issue with vm, I am afraid the roots are going much
> deeper there. I have not got to the exact cause (and therefore a fix),
> but the problem is not about this specific patch. The problem is about
> memory map, specifically one just before and after we switch off Boot
> Services.

Therefore, currently I have to revert r358989 to be able to boot UEFI
VMware guests on VMware ESXi or Workstation.  But that patch is not
actually the reason for boot failing.

[1] https://lists.freebsd.org/pipermail/svn-src-head/2020-March/134676.html
Comment 2 Francis Dupont 2020-03-23 17:04:46 UTC
Found another reference http://freebsd.1045724.x6.nabble.com/ESXi-VM-does-not-boot-in-UEFI-mode-from-20190906-snapshot-ISO-td6350284.html

Note the r358989 breaks the work-around: the only way to recover is to boot from an install or live cd and restore a working (e.g 12.1 release, not 12 stable) loader.efi file.
Comment 4 Toomas Soome freebsd_committer 2020-03-23 18:33:28 UTC
(In reply to Ruslan Garipov from comment #1)

Yes, it does "help" to trigger the issue by adding a bit to loader.efi size and via some change to screen update - getting text on screen via simple text output protocol does cause memory allocation by uefi firmware.

The first visible related error is memory allocation to store efi memory map just before we switch off BootServices, however simple switch to alternate memory does not chenge anything there, so it must be something more going on.

My guess is that the best option still would be to hook up to gdb stub and try to catch where we are blowing up and then we also know why exactly. Right now we can only guess.
Comment 5 Yuri Pankov 2020-10-08 18:13:07 UTC
So this is now in 12.2 as well? Can it be fixed finally?
Comment 6 ykla 2020-10-27 02:39:19 UTC
I Installed freebsd 12.2-RC3 in vmware16 with UEFI. After Installed, it also not boot with the following error message: "The firmware encountered an unexpected exception. The virtual machine cannot boot."
Comment 7 Roger Leigh 2020-10-31 15:22:28 UTC
Created attachment 219242 [details]
Screenshot of failure

VMware 15 on AMD Ryzen 2700X.
Comment 8 Roger Leigh 2020-10-31 15:23:52 UTC
See attached screenshot.

See https://forums.freebsd.org/threads/cant-boot-on-uefi.68141/ for a 2018 report of the issue, though the discussion is looking at irrelevant details which aren't actually the root cause.

See also https://communities.vmware.com/thread/643481 (they think it's most likely a FreeBSD bug, but there's a small possibility it's a vmware issue).  I've attached detailed logs from the vmware side there which include all of the hardware details.

Also on pfSense: https://redmine.pfsense.org/issues/10943

FreeBSD 12.2: installer booted; it's on boot of the new install the failure occurs.

FreeBSD CURRENT: installer will not boot.
Comment 9 Hongbo He 2020-11-04 02:04:01 UTC
If I hit ESC and entering the EFI shell of VMware's UEFI firmware before booting FreeBSD then it will boot successfully. Hope this helps.

see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250580#c5
Comment 10 Hongbo He 2020-11-04 02:17:40 UTC
See also https://communities.vmware.com/message/2994826 (Discussion on VMware forum)
Comment 11 Yuri Pankov 2020-11-21 08:25:30 UTC
(In reply to Hongbo He from comment #9)
It doesn't, that looks like completely different issue.

Still the same issue with VMware Workstation 16.{0,1} now and FreeBSD-13.0-CURRENT-amd64-20201119-f2ea0734875-disc1.iso .
Comment 12 Graham Perrin 2020-12-04 08:38:27 UTC
Cross reference https://old.reddit.com/r/freebsd/comments/ir90ra/hp_probook_440_g7/gejo49g/ – apparently a hardware instance of the bug. 

HP ProBook 440 G7.