qemu-system-aarch64: Error: r = HV_BAD_ARGUMENT (0xfae94003, at ../target/arm/hvf/hvf.c:2259)
Host environment
- Operating system: macOS 15.3.2 (24D81)
- OS/kernel version: Darwin macos 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:23:36 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8112 arm64
- Architecture: arm64
- QEMU flavor: qemu-system-aarch64
- QEMU version: 0f15892a
- QEMU command line:
/Volumes/src/qemu-project/qemu/build/qemu-system-aarch64 \
-nodefaults \
-nographic \
-machine "virt" \
-accel "hvf" \
-cpu "host" \
-smp "2" \
-m "2G" \
-bios "/Volumes/src/qemu-project/qemu/build/pc-bios/edk2-aarch64-code.fd" \
-gdb "tcp::1234" \
-netdev "user,id=net0,hostfwd=tcp::2222-:22" \
-device "virtio-net-pci,netdev=net0" \
-drive "id=boot,file=debian-13-genericcloud-arm64-daily.qcow2,format=qcow2,if=virtio,discard=unmap,media=disk,read-only=no" \
-kernel "arch/arm64/boot/Image" \
-append "root=/dev/vda1 audit=0 nokaslr console=ttyAMA0" \
-serial "mon:stdio"
Emulated/Virtualized environment
- Operating system: Linux
- OS/kernel version: Upstream latest
- Architecture: arm64
Description of problem
When I launch a Linux guest in QEMU with -accel hvf
+ -gdb "tcp::1234"
, and I try to debug the kernel with lldb
, QEMU crashes with the following report:
qemu-system-aarch64: Error: r = HV_BAD_ARGUMENT (0xfae94003, at ../target/arm/hvf/hvf.c:2259)
Steps to reproduce
- Run QEMU with
-accel hvf
+-gdb "tcp::1234"
and a custom kernel (-kernel Image
) - Try to attach using
lldb vmlinux
+(lldb) gdb-remote 1234
Additional information
Debugging QEMU I see the crash is due to the cpu->accel->fd
file descriptor being 0
:
warning: qemu-system-aarch64 was compiled with optimization - stepping may behave oddly; variables may not be available.
frame #4: 0x00000001003dd24c qemu-system-aarch64`hvf_arch_update_guest_debug [inlined] hvf_put_guest_debug_registers(cpu=0x0000000158118000) at hvf.c:2259:9 [opt]
2256 for (i = 0; i < max_hw_bps; i++) {
2257 r = hv_vcpu_set_sys_reg(cpu->accel->fd, dbgbcr_regs[i],
2258 env->cp15.dbgbcr[i]);
-> 2259 assert_hvf_ok(r);
2260 r = hv_vcpu_set_sys_reg(cpu->accel->fd, dbgbvr_regs[i],
2261 env->cp15.dbgbvr[i]);
2262 assert_hvf_ok(r);
(lldb) print cpu->accel->fd
(hvf_vcpuid) 0
(lldb) print dbgbcr_regs[i]
(const uint16_t) 32773
(lldb) print env->cp15.dbgbcr[i]
(uint64_t) 480
Edited by Daniel Gomez