Skip to content

[Ubuntu on M1] Lima VM will not start (EFI stub: ERROR: FIRMWARE BUG: kernel image not aligned on 64k boundary) #712

Closed
@mateka

Description

@mateka

EDIT by @AkihiroSuda

Update (Mar 14, 2022)

⚠️ Running recent Linux guests on M1 macOS needs Homebrew's QEMU 6.2.0_1 or later.

Run brew upgrade to upgrade QEMU.

Intel macOS users are NOT affected by this issue.

For the further information, see #734 and Homebrew/homebrew-core#96743 .

Old information

Ubuntu kernel 5.13.0-35.40 (5.4.0-103.117 for 20.04 LTS) released in March 2022 is not bootable on ARM hosts:

(~/.lima/default/serial.log)
...
EFI stub: Booting Linux Kernel...
EFI stub: ERROR: FIRMWARE BUG: kernel image not aligned on 64k boundary
EFI stub: Using DTB from configuration table
EFI stub: Exiting boot services and installing virtual address map...
SetUefiImageMemoryAttributes - 0x000000013F500000 - 0x0000000000040000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013C190000 - 0x0000000000040000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013C140000 - 0x0000000000040000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013F4C0000 - 0x0000000000030000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013C0F0000 - 0x0000000000040000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013BCB0000 - 0x0000000000040000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013BB00000 - 0x0000000000030000 (0x0000000000000008)
SetUefiImageMemoryAttributes - 0x000000013BAC0000 - 0x0000000000030000 (0x0000000000000008)
(hangs here)

Until the issue gets resolved, it is HIGHLY RECOMMENDED to run the following command inside the Ubuntu shell to avoid upgrading the kernel:

sudo apt-mark hold linux-image-$(uname -r)

(Make sure to unhold it when we get the fix)

If your kernel was already upgraded and the VM does not boot, try running Lima with the following environment variable to show the video display:

export QEMU_SYSTEM_AARCH64="qemu-system-aarch64 -display cocoa"

After the display is shown, press the Esc key several times to show the GRUB prompt for choosing an older kernel.
You can also mount the disk image from another instance to modify the GRUB config or rescue the data inside the image.
#712 (comment)

See also https://gitlab.com/qemu-project/qemu/-/issues/899

🙏 Help wanted for testing

This QEMU patch may fix the issue: AkihiroSuda/homebrew-core@177d583
(from https://gitlab.com/qemu-project/qemu/-/issues/899)

Download qemu.rb and run brew install --build-from-source ./qemu.rb to apply the patch.

Below is the original post by @mateka


Description

Today I was working in lima VM (Ubuntu 20.04; Mac M1). After a while, it has lost connection (as it often does), so I had tried to restart it. Old VM and even brand new will not start and return an error after:

Waiting for the essential requirement 1 of 5: "ssh"

limactl --debug start VM-name prints:

DEBU[0171] [hostagent] executing ssh for script "ssh": /usr/bin/ssh [ssh -F /dev/null -o IdentityFile="/Users/matek/.lima/_config/user" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers="^[email protected],[email protected]" -o User=matek -o ControlMaster=auto -o ControlPath="/Users/matek/.lima/test/ssh.sock" -o ControlPersist=5m -p 52070 127.0.0.1 -- /bin/bash]
DEBU[0246] [hostagent] stdout="", stderr="kex_exchange_identification: read: Connection reset by peer\r\nConnection reset by 127.0.0.1 port 52070\r\n", err=failed to execute script "ssh": stdout="", stderr="kex_exchange_identification: read: Connection reset by peer\r\nConnection reset by 127.0.0.1 port 52070\r\n": exit status 255

Rancher Desktop seems to work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions