Bug 291935 - Vidconsole (amd64 only) does not show anything on old hardware (MacBook2,1)
Summary: Vidconsole (amd64 only) does not show anything on old hardware (MacBook2,1)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Ahmad Khalifa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-25 14:19 UTC by Ruslan Zalata
Modified: 2026-01-12 19:18 UTC (History)
5 users (show)

See Also:


Attachments
Photo of MacBook booting screen right after loader gives control to the kernel (644.55 KB, image/jpeg)
2025-12-25 14:23 UTC, Ruslan Zalata
no flags Details
UGA framebuffer patch (2.56 KB, patch)
2025-12-29 17:47 UTC, Ahmad Khalifa
no flags Details | Diff
UGA gfxfb loader patch (588 bytes, patch)
2025-12-30 20:27 UTC, Ahmad Khalifa
no flags Details | Diff
Unified patch for FreeBSD 14.3-RELEASE to add UGA support in 32-bit loader for old MacBooks (3.26 KB, patch)
2025-12-30 22:59 UTC, Ruslan Zalata
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ruslan Zalata 2025-12-25 14:19:14 UTC
Recently I was trying to install 64-bit FreeBSD on my old MacBook2,1 (A1181 mid 2007, based on Intel Core2 Duo T7400 @ 2.16GHz) and I faced the following issued: right after loader boots the kernel and gives control to it, no more output is produced on video console. Last few lines on the screen I can see are:

Start @ 0xffffffff80387000 ...
Loading splash ok


Yet system proceeds booting and Installer runs, keyboard works fine (I even can use Installer in the blind).

The problem appears only on amd64 branch. On i386 branch vidconsole works fine and I was able to install FreeBSD sucessfully on this machine (although it's completely unusable due to lack of drm-kmod support in i386 branch). I tested it on a number of previous releases: 13.5-RELEASE, 14.3-RELEASE and 15.0-RELEASE - same effect on all of them. I tested booting from memstick and DVD images. A friend of mine has same issue on another old MacBook though I don't know which model exactly.

Any ideas what to try to reveal the root of the problem ? I can dedicate some time to help resolve this issue (trace the kernel in DDB if necessary). Just need some instructions/directions. :)
Comment 1 Ruslan Zalata 2025-12-25 14:23:04 UTC
Created attachment 266522 [details]
Photo of MacBook booting screen right after loader gives control to the kernel
Comment 2 Ahmad Khalifa freebsd_committer freebsd_triage 2025-12-29 17:47:12 UTC
Created attachment 266624 [details]
UGA framebuffer patch

Hello,

IIRC these old macbooks use the old UGA protocol as opposed to GOP. Looking at the EFI loader's framebuffer probing code, it looks like we bail out upon not finding GOP, and don't actually proceed to probe for UGA.

Could you try the attached patch and see if it makes things better?

I'll also note that we don't list the MacBook2,1 when setting our hardcoded stride and offset values, so the framebuffer's stride and offset may be off.
Comment 3 Ahmad Khalifa freebsd_committer freebsd_triage 2025-12-29 17:57:00 UTC
(In reply to Ruslan Zalata from comment #0)

> The problem appears only on amd64 branch. On i386 branch vidconsole works fine and I was able to install FreeBSD sucessfully on this machine (although it's completely unusable due to lack of drm-kmod support in i386 branch).

Forgot to add:

It probably works on i386 since that doesn't boot through UEFI at all. Booting the amd64 image with CSM enabled *should* have the same effect.
Comment 4 Ruslan Zalata 2025-12-29 22:41:47 UTC
Hello Ahmad.

Good shot! Here's how it went. I applied your patch to 14.3-RELEASE/amd64 with slight modification (s/EFI_GRAPHICS_OUTPUT_PROTOCOL/EFI_GRAPHICS_OUTPUT/), built and copied loader_ia32.efi to /EFI/BOOT/bootia32.efi on USB memstick, pluged it into MacBook and powered up with Option key pressed. Soon as I select USB as boot device, the loader starts and prints following message:

  No change detected in framebuffer -- error 0???Unable to reliably detect frame
  buffer.???Unable to reliably detect the stride.???

A couple of seconds later normal boot process proceeds with all the regular output from kernel visible, vidconsole works well, Installer is visible. I toyed a little with the "Live System", everything seems good so far on this MacBook.

The bad news is that it stopped working on 64-bit EFI system (tested on my Lenovo laptop dated 2021) - no output after "Starting @ ...". I copied loader.efi to /EFI/BOOT/bootx64.efi of course. Seems the selection algorithm is not correct. Curretly trying to figure out how to fix it so that both GOP and UGA could work.
Comment 5 Ruslan Zalata 2025-12-29 23:24:56 UTC
Oops, my bad. When manually applying your patch I missed this line:

 nhandles = hsize / sizeof(*hlist);

and it never finds GOP handle because nHandles initialized to zero. After fixing this, loader works fine on both EFI32 (MacBook) with UGA and on EFI64 with GOP. So, basically your patch works well. Thank you very much Ahmad!

Now trying to find out how to fix the stride issue.
Comment 6 Ruslan Zalata 2025-12-30 02:29:14 UTC
I noticed another problem. As loader detects UGA it switches to "graphics mode" (default is text mode) and no output from loader is visible since then. I'm sure that fb_addr, fb_size and fb_stride detected correctly because kernel produces correct output. Also I tried writing to framebuffer myself from within efi_find_framebuffer() and could observe it on the screen.

If I set gfx_state.tg_fb_type = FB_TEXT somewhere in cons_update_mode() after call to efi_find_framebuffer(), it reverts loader console back to text mode and I can observe output both from loader and from kernel. Looks like there's one more bug (or an artifact) in loader while rendering text in graphics mode on UGA.
Comment 7 Ahmad Khalifa freebsd_committer freebsd_triage 2025-12-30 20:27:00 UTC
Created attachment 266658 [details]
UGA gfxfb loader patch

Hmm, digging deeper into this, there does seem to be some weirdness here.

In gfxfb_blt(), we assume that gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL structure (which in UGA's case, it doesn't). At first glance, that looks like it would be problematic, since we try to deference it and call it's Blt() function. However, it looks like both EFI_GRAPHICS_OUTPUT_PROTOCOL and EFI_UGA_DRAW_PROTOCOL have both their Blt functions at the same offset (which is probably why the loader isn't hanging/crashing). I doubt this is intentional though.

So it would seem like the problem here is that the MacBook's Blt function just doesn't work. IMO we shouldn't be using the firmware provided Blt functions on UGA platforms at all.

The attached patch switches to gfxfb's implementation of these functions if we're on UGA. Could you try and see if that fixes the issue? (this should be applied over the previous patch of course)
Comment 8 Ruslan Zalata 2025-12-30 22:53:20 UTC
Hello Ahmad. Your gfxfb patch worked. Now I can observe output both from loader and from kernel. Though, the font is a bit high, but it's bearable. Thank you for your support!

Happy New Year!
Comment 9 Ruslan Zalata 2025-12-30 22:59:58 UTC
Created attachment 266664 [details]
Unified patch for FreeBSD 14.3-RELEASE to add UGA support in 32-bit loader for old MacBooks

Just in case someone is interested, am attaching a unified patch for FreeBSD 14.3-RELEASE 32-bit loader. Should work for 15.0-RELEASE as well with slight shift in line numbers. Adding hardcoded params for MacBook2,1 was not necessary as the default autodetect algorithm works ok.
Comment 10 Ahmad Khalifa freebsd_committer freebsd_triage 2025-12-31 02:57:17 UTC
Thank you for confirming the patch fixes the issue, and happy new year :)

I'll try to get these reviewed and merged soon.
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-01-04 13:21:32 UTC
A commit in branch main references this bug:

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

commit 9595055ae7494997bb07b4aaed544f88ac4c5e7f
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:37 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-04 13:15:37 +0000

    loader.efi: only use firmware provided Blt on GOP

    gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
    using GOP.

    The firmware provided Blt functions on UGA platforms have been observed
    to not work on old MacBooks, and are likley hit or miss anyways as UGA
    has been deprecated since 2006.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54432

 stand/common/gfx_fb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-01-04 13:21:35 UTC
A commit in branch main references this bug:

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

commit 5d85dde27b4769604fc108b89328607e70e767ed
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:02 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-04 13:15:02 +0000

    loader.efi: probe for UGA if GOP isn't found

    Probe for UGA instead of returning early if we can't find GOP.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54431

 stand/efi/loader/framebuffer.c | 74 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 36 deletions(-)
Comment 13 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:04 UTC
A commit in branch stable/13 references this bug:

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

commit 8591ee986b22007a98ded2f3dc86e8065f14b213
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:37 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:28:03 +0000

    loader.efi: only use firmware provided Blt on GOP

    gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
    using GOP.

    The firmware provided Blt functions on UGA platforms have been observed
    to not work on old MacBooks, and are likley hit or miss anyways as UGA
    has been deprecated since 2006.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54432

    (cherry picked from commit 9595055ae7494997bb07b4aaed544f88ac4c5e7f)

 stand/common/gfx_fb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Comment 14 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:06 UTC
A commit in branch stable/15 references this bug:

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

commit 5a9e2c59cb08bf1c1a428cd8a9ebd2886381a051
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:02 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:24:55 +0000

    loader.efi: probe for UGA if GOP isn't found

    Probe for UGA instead of returning early if we can't find GOP.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54431

    (cherry picked from commit 5d85dde27b4769604fc108b89328607e70e767ed)

 stand/efi/loader/framebuffer.c | 74 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 36 deletions(-)
Comment 15 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:07 UTC
A commit in branch stable/15 references this bug:

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

commit d3902baca506ec48e2f8b1121c7744766a175516
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:37 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:24:55 +0000

    loader.efi: only use firmware provided Blt on GOP

    gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
    using GOP.

    The firmware provided Blt functions on UGA platforms have been observed
    to not work on old MacBooks, and are likley hit or miss anyways as UGA
    has been deprecated since 2006.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54432

    (cherry picked from commit 9595055ae7494997bb07b4aaed544f88ac4c5e7f)

 stand/common/gfx_fb.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Comment 16 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:08 UTC
A commit in branch stable/14 references this bug:

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

commit 6741fb1bd4f473f3bc46e46841d2e53a9629907c
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:37 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:26:33 +0000

    loader.efi: only use firmware provided Blt on GOP

    gfx_state.tg_private points to a EFI_GRAPHICS_OUTPUT_PROTOCOL only when
    using GOP.

    The firmware provided Blt functions on UGA platforms have been observed
    to not work on old MacBooks, and are likley hit or miss anyways as UGA
    has been deprecated since 2006.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54432

    (cherry picked from commit 9595055ae7494997bb07b4aaed544f88ac4c5e7f)

 stand/common/gfx_fb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Comment 17 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:09 UTC
A commit in branch stable/13 references this bug:

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

commit f4e56d1bda03982c9624e9d098a47bbbe2b834d5
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:02 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:28:02 +0000

    loader.efi: probe for UGA if GOP isn't found

    Probe for UGA instead of returning early if we can't find GOP.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54431

    (cherry picked from commit 5d85dde27b4769604fc108b89328607e70e767ed)

 stand/efi/loader/framebuffer.c | 74 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 36 deletions(-)
Comment 18 commit-hook freebsd_committer freebsd_triage 2026-01-12 17:34:11 UTC
A commit in branch stable/14 references this bug:

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

commit 4832232096f8e691563e5200b9f0d86d158bc51a
Author:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2026-01-04 13:15:02 +0000
Commit:     Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2026-01-12 17:26:33 +0000

    loader.efi: probe for UGA if GOP isn't found

    Probe for UGA instead of returning early if we can't find GOP.

    Reviewed by:    tsoome
    PR:             291935
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D54431

    (cherry picked from commit 5d85dde27b4769604fc108b89328607e70e767ed)

 stand/efi/loader/framebuffer.c | 74 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 36 deletions(-)