Bug 288900 - loader.efi: System won't boot without kvm or console=comconsole in loader.conf
Summary: loader.efi: System won't boot without kvm or console=comconsole in loader.conf
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.4-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-16 09:49 UTC by Michael Gmelin
Modified: 2026-10-18 04:18 UTC (History)
10 users (show)

See Also:


Attachments
Proposed fix (806 bytes, patch)
2026-09-13 17:43 UTC, Warner Losh
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Gmelin freebsd_committer freebsd_triage 2025-08-16 09:49:49 UTC
On Hetzner AX102 hosts (Ryzen based), only EFI boot is supported.

With a console connected (kvm) the systems boot just fine. With the console removed, they (presumably, since it cannot be perceived) get stuck in the boot loader or end up in a reboot loop (after a while the system shuts down).

This can be worked around by setting:

    console="comconsole"

in /boot/loader.conf.

Other settings do not work (e.g., console="comconsole,efi" will get stuck as well).

The downside of the workaround is that there is no console output during boot, even if a kvm is connected.

While experimenting with this, I read the loader code and noticed that the loader.conf(5) man page doe not distinguish between various loaders. It appears that many settings are not supported in loader.efi (inclusing some of the settings for console).

System information:

BIOS Information
        Vendor: American Megatrends International, LLC.
        Version: 20.11
        Release Date: 10/24/2024
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 32 MB
        Characteristics:
                PCI is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                Boot from CD is supported
                Selectable boot is supported
                BIOS ROM is socketed
                EDD is supported
                Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)
                Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
                5.25"/360 kB floppy services are supported (int 13h)
                5.25"/1.2 MB floppy services are supported (int 13h)
                3.5"/720 kB floppy services are supported (int 13h)
                3.5"/2.88 MB floppy services are supported (int 13h)
                Print screen service is supported (int 5h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                CGA/mono video services are supported (int 10h)
                ACPI is supported
                USB legacy is supported
                BIOS boot specification is supported
                Targeted content distribution is supported
                UEFI is supported
        BIOS Revision: 5.35

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
        Manufacturer: ASRockRack
        Product Name: B665D4U-1L
        Version: 3.03
Comment 1 punkt.de Hosting Team 2026-03-23 18:25:32 UTC
I can confirm this is the case. We experience the same with 14.3.

An alternative to connecting a KVM is to order a "HDMI emulator dongle" from Hetzner which they will provide for a small fee.

These boards have only an HDMI connector, no VGA or DP. When no monitor is connected there seems to be no EFI console at all which our boot loader does not like and crashes.

Forcing comconsole although there is no serial port present works for us, too.

Thanks, Michael!

Kind regards,
Patrick
Comment 2 Vidith Hundekar 2026-03-30 16:03:24 UTC
Hi,

I’m Vidith, currently working on the EFI boot counter project as part of GSoC exploration, and while going through the loader and early boot path I came across this issue.

I was trying to understand how console initialisation works in loader.efi when no display is attached.

From the description and the follow-up comment, it seems like when no monitor is connected, the firmware may not expose a usable EFI console — no GOP or no usable Simple Text Output Protocol. If loader.efi assumes ConsoleOut is always valid and tries to use it during early initialisation without checking, that would explain the hang or reboot loop, since this is all still happening in the BootServices phase where the loader depends entirely on what the firmware provides.

The comconsole workaround seems to support this — it sidesteps EFI console usage entirely and takes a different code path, which is why it works even when there's no serial port physically present.

My question is whether loader.efi currently verifies that a valid console handle exists (for example, via HandleProtocol on ConsoleOut) before attempting to use it, or whether it assumes one is always present. If it's the latter, would it make sense for the loader to fall back more gracefully when firmware exposes no console?

I'm likely missing some of the finer details of how console selection is handled internally, so any clarification would be helpful.

Thanks
Comment 3 Alexander Ziaee freebsd_committer freebsd_triage 2026-09-12 12:01:09 UTC
Hey do any of you guys have any advice for Vidith?
Comment 4 Warner Losh freebsd_committer freebsd_triage 2026-09-13 01:20:40 UTC
So, we assume ST->ConOut is non-NULL. We find EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID on the ConsoleInHandle, we use it, otherwise we assume conin is also non-NULL. We don't locate SIMPLE_TEXT_OUTPUT_INTERFACE on the ConsoleOutHandle if it is NULL.

So unless I can reproduce it, we're stuck playing a game of whack-a-mole to see which of these issues is the case.

But I can suggest some troubleshooting that will give me a good guess.

1. Can you boot without any USB HID devices attached, but with just the HDMI cable connected to a monitor.
2. Can you boot with a USB HID device, but without HDMI?
3. Can you boot with both attached?
4. But report is that you can't boot if neither is connected, correct?

If you can try all 4 of those, and give me a failure matrix with console=efi I will suggest patches.
Comment 5 Warner Losh freebsd_committer freebsd_triage 2026-09-13 01:25:47 UTC
Also, knowing the results for 15.1R and the latest snapshot would be nice. The differences between them ar large.

I can't imagine the firmware not exposing the output if there's no monitor attached. I can expect that it does something funky when we muck with graphics that causes us to dereference a NULL pointer.
Comment 6 Patrick M. Hausen freebsd_triage 2026-09-13 15:37:37 UTC
Unfortunately we cannot get our hands on the hardware proper. This is a recent hosting platform at Hetzner. I already asked them for a mainboard on lease but they politely but very definitely declined.

> 1. Can you boot without any USB HID devices attached, but with just the HDMI cable connected to a monitor.

That's what we are doing. We ordered so called "HDMI emulators" or "dongles" for all of the systems with that particular architecture. As soon as the dongle is present they boot.

I can give you any debug output you might need from one of those, although a reboot might have to be scheduled in advance with quite some timeframe involved.

The problem is that all machines we run are in production. I'll check if I have one for which we can have some longer downtime to experiment.

> 2. Can you boot with a USB HID device, but without HDMI?

I can probably arrange for that via Hetzner support. The downtime constraint from above still holds.

> 3. Can you boot with both attached?

Yes we can ;-) That's how we found out about the issue.

> 4. But report is that you can't boot if neither is connected, correct?

Correct.

So the situation we faced was:

- order new system with that particular mainboard
- boot into Linux rescue system, use depenguin.me to install FreeBSD
- reboot, system won't come up
- order a temporary IP KVM from Hetzner, they provide it, no video signal on the IP KVM display
- reset machine while KVM is connected
- FreeBSD boots flawlessly
- quizzical look, shrugs, tell Hetzner the KVM is not needed anymore, continue to install/configure host
- at next reboot the system won't come up again
- go back to the "order IP KVM" step
- after a couple of iterations notice a pattern

Michael came up with hard wiring comconsole, we solved it by ordering these dongles.

That's the situation that limits our options for debugging. Specifically the fact that with a KVM connected (hence a monitor from the system's view) everything works as expected but without one there will be no boot and no video output even if you connect a KVM/monitor later.

So no way to watch/investigate anything after a failure.

Kind regards,
Patrick
Comment 7 Warner Losh freebsd_committer freebsd_triage 2026-09-13 17:12:31 UTC
Excellent! So if you have a known broken setup that you can use comconsole for and get that output, I'll create some patches that 'fail' the EFI console (and default to the comconsole console). No need to get remote hands to test all possible combos, though. Your answers tell me enough.

If you can't get to a serial port, though, then that limits my options. I can still do it, but the patch would be somewhat different...  Most likely by 'dumping' the ST to kenv variables and iterating from there. I'll try to get the most from each experiment in a maint window. Hopefully we can boot the system with a -current loader.efi and we'll sort out the issues there. that might be the first thing to try. Or something else that occurs to you in your situation. I can be easy. I'll assume this path and get some patches for you to try. OK?
Comment 8 Warner Losh freebsd_committer freebsd_triage 2026-09-13 17:42:22 UTC
So I asked claude to do an analysis (which I've not independently confirmed, but it seems plausible) and it said that Windows and GRUB don't touch Mode->Info at all typically, so if either Mode or Mode->Info was NULL, in violation of the spec, there'd be a crash.

Can you test the attached that and let me know?
Comment 9 Warner Losh freebsd_committer freebsd_triage 2026-09-13 17:43:15 UTC
Created attachment 274702 [details]
Proposed fix

Guard against null pointers here.
Comment 10 Warner Losh freebsd_committer freebsd_triage 2026-09-13 17:45:58 UTC
This patch is likely correct regardless of whether it will fix your problem or not. It's good defensive programming techniques because UEFI firmware is implemented by people with a rather a wide range of competencies and with so many different versions, there's bound to be some minor non-conformance.
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-09-24 07:24:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b5f0e7f36afc20bf17e9e955454b445d686cda06

commit b5f0e7f36afc20bf17e9e955454b445d686cda06
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-09-24 07:22:16 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-09-24 07:22:25 +0000

    loader.efi: Be cautious about using GOPs

    When we're searching for the EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID (GOPs) to
    use, skip any whose Mode or Mode->Info pointers are NULL. The spec
    requires these to be non-null, however, some firmwares seem to fail to
    populate the Info when, for example, a monitor is not present. Work
    around these bugs by skipping any GOPs with bad pointers.

    PR: 288900
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D59830

 stand/efi/loader/framebuffer.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Comment 12 Patrick M. Hausen freebsd_triage 2026-09-24 20:33:23 UTC
Hi Warner,

I apologise for not replying earlier, but I caught the EuroBSDCon bug and fell flat with a cold.

> So if you have a known broken setup that you can use comconsole for and get that output

I can create a known broken setup but neither can I get at these mainboards because they are in Hetzner's DC, nor do they have serial ports. They only have a single HDMI connector. No UART anywhere, no IPMI serial over IP.

The only way to get at a wedged system is reset or power cycle with a KVM or an emulator connected to that HDMI port. At which point the issue is gone.

Forcing comconsole (what Michael did) seems to change the code path in our boot loader regardless if the board has one or not. We decided to buy those HDMI thingies.

> If you can't get to a serial port, though, then that limits my options. [...] I'll assume this path and get some patches for you to try. OK?

Thanks. I'll see when I can "break" a system and try the patch.

Kind regards,
Patrick
Comment 13 Warner Losh freebsd_committer freebsd_triage 2026-09-24 21:25:48 UTC
(In reply to Patrick M. Hausen from comment #12)
You might also see if my fix fixes your broken setup. It avoids things that can be null pointers w/o checking them (the GOP related stuff). Using comconsole
also avoids touching that code path.