Bug 15872

Summary: genericarm64/aarch64/qemuarm64 u-boot hangs with kvm
Product: [Build System, Metadata & Runtime] BSPs Reporter: Mikko Rapeli <mikko.rapeli>
Component: bsps-meta-yoctoAssignee: Mikko Rapeli <mikko.rapeli>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: randy.macleod, ross.burton, yoann.congal
Version: 5.2   
Target Milestone: 5.3 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: Regression (Used to work)
Verified: Documentation change: No (bug/feature does not impact docs)

Description Mikko Rapeli 2025-05-21 12:49:57 UTC
On a aarch64/arm64 build host where kvm is supported and working:

$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

$ kvm-ok 
INFO: /dev/kvm exists
KVM acceleration can be used

build genericarm64 machine image core-image-base and u-boot:

$ bitbake core-image-base u-boot

Run the image with qemu and kvm which boots via u-boot but hangs:

$ runqemu slirp nographic novga snapshot kvm
runqemu - INFO - Running bitbake -e  ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: []
BIOS: [/home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64/u-boot.bin]
MACHINE: [genericarm64]
FSTYPE: [wic (no-kernel-in-fs)]
ROOTFS: [/home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64/core-image-base-genericarm64.rootfs-20250521112852.wic]
CONFFILE: [/home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64/core-image-base-genericarm64.rootfs-20250521112852.qemuboot.conf]

runqemu - INFO - Network configuration: ip=dhcp
runqemu - INFO - Port forward: hostfwd=tcp:127.0.0.1:2222-:22 hostfwd=tcp:127.0.0.1:2323-:23
runqemu - INFO - Running /home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/work/aarch64-linux/qemu-helper-native/1.0/recipe-sysroot-native/usr/bin/qemu-system-aarch64 -device virtio-net-pci,netdev=net0,mac=52:54:00:12:35:02 -netdev user,id=net0,hostfwd=tcp:127.0.0.1:2222-:22,hostfwd=tcp:127.0.0.1:2323-:23,tftp=/home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64 -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -drive id=root,file=/home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64/core-image-base-genericarm64.rootfs-20250521112852.wic,if=none,format=raw -device virtio-blk-pci,drive=root   -machine virt -cpu host -machine gic-version=3 -smp 4 -enable-kvm -m 256 -snapshot -serial mon:stdio -serial null -nographic -vga none -bios /home/mcfrisk/src/base/repo/poky/build_genericarm64/tmp/deploy/images/genericarm64/u-boot.bin

runqemu - INFO - Host uptime: 15741092.71

The boot hangs here. Using ctrl-a-c to access qemu debug console works and the emulation can be stopped.

Root cause was traced by ilias.apalodimas@linaro.org to u-boot commit 53d5a221632e  "emulation: Use bloblist to hold tables" and was reported upstream in https://lists.denx.de/pipermail/u-boot/2025-May/590103.html

Revert is tricky but a config change is enough to fix this:

--- a/configs/qemu_arm64_defconfig
+++ b/configs/qemu_arm64_defconfig
@@ -2,7 +2,6 @@ CONFIG_ARM=y
 CONFIG_POSITION_INDEPENDENT=y
 CONFIG_ARCH_QEMU=y
 CONFIG_SYS_MALLOC_LEN=0x1000000
-CONFIG_BLOBLIST_SIZE_RELOC=0x2000
 CONFIG_NR_DRAM_BANKS=1
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x40200000
 CONFIG_ENV_SIZE=0x40000
@@ -27,7 +26,7 @@ CONFIG_USE_PREBOOT=y
 # CONFIG_DISPLAY_CPUINFO is not set
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_PCI_INIT_R=y
-CONFIG_BLOBLIST=y
+# CONFIG_BLOBLIST is not set
 CONFIG_CMD_SMBIOS=y
 CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_BOOTEFI_SELFTEST=y

I think we should improve the testing in oe-core to cover this, but there is a hard dependency on build/test machines to have working kvm also on aarch64/arm64.
Comment 1 Ross Burton 2025-05-21 12:54:04 UTC
Our selftest-armhost run will only run on Altras now, so we should be able to enable KVM in that build run which might be sufficient.

Alternatively, add qemuarm64-armhost to explicitly test with KVM enabled.
Comment 2 Mikko Rapeli 2025-05-21 13:53:13 UTC
Fix/workaround in https://lists.openembedded.org/g/openembedded-core/message/217030
Comment 3 Kevin Hao 2025-05-22 07:24:57 UTC
@Mikko, it looks like you've already created a patch to fix this issue. Is there anything else I need to do on my side? Also, should I update the bug to assign it to you?
Comment 4 Mikko Rapeli 2025-05-22 07:28:35 UTC
I'll try to fix this. Also thinking about adding a test case. KVM boot to qemu and kernel is tested vi selftests, but u-boot apparently not.
Comment 6 Mikko Rapeli 2025-06-05 14:21:56 UTC
Workarounds and selftest merged to poky master branch now.