Skip to content

stal/IX kernels built with CONFIG_EFI_STUB=y are not bootable in legacy BIOS #754

Description

@EarldridgeJazzedPineda

I have a Linux 6.15.2 kernel at /bin/kernel-6-15, built using the stock configuration (which has CONFIG_EFI_STUB=y). When I tried to boot it in legacy BIOS using GRUB, it said error: invalid magic number. I later discovered that my kernel is missing the byte sequence AA 55 at offset 510, which means it will not be bootable in legacy BIOS, no matter what I try. Setting CONFIG_EFI_STUB=n did fix the issue, but CONFIG_EFI_STUB by itself is not the cause.

A valid (bootable in legacy BIOS) Linux kernel from Alpine Linux:

  • Bytes at offset 510: aa55 6aeb 6448 5372 020f 0000 0000 1000
  • File format according to file: Linux kernel x86 boot executable, bzImage, version 6.12.13-0-virt (buildozer@build-3-21-x86_64) #1-Alpine SMP PREEMPT_DYNAMIC 2025-02-10 21:47:33, RO-rootFS, Normal VGA, setup size 512*31, syssize 0xb1540, jump 0x26c 0x8cd88ec0fc8cd239 instruction, protocol 2.15, from protected-mode code at offset 0x2c4 0xb069ea bytes gzip compressed, relocatable, handover offsett 0xb0ec7d, legacy 64-bit entry point, can be above 4G, 64-bit EFI handoff entry point, EFI kexec boot support, xloadflags bit 5, max cmdline size 2047, init_size 0x25b3000

My invalid (not bootable in legacy BIOS) Linux kernel:

  • Bytes at offset 510: 0000 0fa4 0000 8566 0fc0 0e84 6701 8d66
  • File format according to file: PE32+ executable for EFI (application), x86-64 (stripped to external PDB), 4 sections

How to reproduce

  1. Copy the stock configuration to pkgs/bin/kernel/configs/cfg_6_14
  2. ./ix mut system bin/kernel/6/15
  3. hexdump -s 510 /bin/kernel-6-15 | head -n 1 (first two bytes should not be aa55)
  4. file -L /bin/kernel-6-15 (should be PE32+ executable for EFI (application), x86-64 (stripped to external PDB), 4 sections)

See also

https://forums.gentoo.org/viewtopic-p-8815100.html#8815100

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions