On Debian 13 AWS EC2 a1.metal starting LineageOS 23.2 https://github.com/jqssun/android-lineage-qemu via QEMU:

```bash
read -r -d '' QEMU_OPTS << EOM
-m 8192 \
-device virtio-blk-pci,drive=vda,bootindex=0 \
-device virtio-blk-pci,drive=vdb,bootindex=1 \
-drive if=pflash,unit=1,file=$(find ./LineageOS_on_*.utm/Data/efi_vars.fd) \
-drive file=$(find ./LineageOS_on_*.utm/Data/vda.qcow2),if=none,id=vda,discard=unmap,detect-zeroes=unmap \
-drive file=$(find ./LineageOS_on_*.utm/Data/vdb.qcow2),if=none,id=vdb,discard=unmap,detect-zeroes=unmap \
-device virtio-net-pci,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp:0.0.0.0:5555-:5555,hostfwd=tcp:0.0.0.0:5554-:5554 \
-device usb-tablet,bus=usb-bus.0 \
-device usb-mouse,bus=usb-bus.0 \
-device usb-kbd,bus=usb-bus.0 \
-device virtio-serial \
-device virtio-rng-pci \
-chardev stdio,mux=on,id=charconsole \
-serial chardev:charconsole
EOM
VMF_CODE=$(find /usr/share/ -name $([ "$(uname -m)" = "x86_64" ] && echo OVMF_CODE_4M || echo AAVMF_CODE).fd 2>/dev/null)
read -r -d '' LINUX_QEMU_OPTS << EOM
-device virtio-gpu-pci -display sdl,gl=off \
-drive if=pflash,unit=0,file=$VMF_CODE,file.locking=off,format=raw,readonly=on \
-device usb-ehci,id=usb-bus \
$QEMU_OPTS
EOM
qemu-system-aarch64 -machine virt,gic-version=3 -cpu host -accel kvm $LINUX_QEMU_OPTS
```
```
[ 69.495196][ T213] Unable to handle kernel paging request at virtual address ffffffe9c0022ffc
[ 69.499681][ T213] Mem abort info:
[ 69.503581][ T213] ESR = 0x0000000096000007
[ 69.506486][ T213] EC = 0x25: DABT (current EL), IL = 32 bits
[ 69.514025][ T213] SET = 0, FnV = 0
[ 69.520992][ T213] EA = 0, S1PTW = 0
[ 69.523321][ T213] FSC = 0x07: level 3 translation fault
[ 69.533669][ T213] Data abort info:
[ 69.537456][ T1] mke2fs: mke2fs 1.47.2 (1-Jan-2025)
[ 69.540768][ T213] ISV = 0, ISS = 0x00000007, ISS2 = 0x00000000
[ 69.545132][ T213] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 69.551564][ T213] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 69.555499][ T213] swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000064631000
[ 69.559787][ T1] mke2fs: Discarding device blocks: done
[ 69.564948][ T213] [ffffffe9c0022ffc] pgd=1000000064e40003, p4d=1000000064e40003, pud=1000000064e40003, pmd=1000000106fef003, pte=0000000000000000
[ 69.573122][ T1] mke2fs: Creating filesystem with 8192 4k blocks and 8192 inodes
[ 69.577245][ T1] mke2fs:
[ 69.579165][ T213] Internal error: Oops: 0000000096000007 [#1] PREEMPT SMP
[ 69.582425][ T213] Modules linked in: cfg80211 btusb btrtl btbcm btintel bluetooth rfkill zram zsmalloc
[ 69.586732][ T213] CPU: 0 UID: 0 PID: 213 Comm: dlkm_loader_mai Not tainted 6.12.81-4k-g4f6bf47200d9 #1 909546a981c6e5494922172970e4abd055bf286a
[ 69.592327][ T213] Hardware name: QEMU KVM Virtual Machine, BIOS 2025.02-8+deb13u1 11/08/2025
[ 69.596313][ T213] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 69.599939][ T213] pc : __pi_scs_handle_fde_frame+0xe4/0x160
[ 69.602865][ T213] lr : __pi_$x+0x5c/0xb8
[ 69.605167][ T213] sp : ffffffc0805e3b00
[ 69.607432][ T213] x29: ffffffc0805e3b00 x28: ffffffc0805fd0c0 x27: ffffffc0805fd0c0
[ 69.611076][ T213] x26: 0000000000000000 x25: ffffffe9c412b608 x24: ffffffe9c0026340
[ 69.614794][ T213] x23: ffffffc0805f36f8 x22: ffffffe9c32ccc7f x21: ffffffe9c0033009
[ 69.618420][ T213] x20: ffffffe9c003306c x19: 00000000000003bc x18: ffffffc0805dd000
[ 69.622019][ T213] x17: ffffffe9c192f9d0 x16: 000000000000002d x15: ffffffe9c003307d
[ 69.625765][ T213] x14: ffffffe9c0023000 x13: 000000000000001e x12: ffffffe9c003307e
[ 69.629360][ T213] x11: ffffffe9c0023000 x10: 00000000d50323bf x9 : 00000000d503233f
[ 69.632940][ T213] x8 : ffffffe9c2c88808 x7 : 7f7f7f7f7f7f7f7f x6 : 001d7affff51797e
[ 69.636516][ T213] x5 : ffffffffffffffff x4 : 0000000000000018 x3 : 011e7c0100527a7f
[ 69.640082][ T213] x2 : ffffffffffffffff x1 : 0000000000000000 x0 : 00000000fffffff8
[ 69.643699][ T213] Call trace:
[ 69.645536][ T213] __pi_scs_handle_fde_frame+0xe4/0x160
[ 69.648203][ T213] module_finalize+0xf4/0x7e0
[ 69.650540][ T213] post_relocation+0xbc/0xd8
[ 69.652820][ T213] load_module+0x1254/0x1508
[ 69.655088][ T213] __arm64_sys_finit_module+0x264/0x300
[ 69.759636][ T213] invoke_syscall+0x58/0x10c
[ 69.761870][ T213] el0_svc_common+0xa8/0xdc
[ 69.764065][ T213] do_el0_svc+0x1c/0x28
[ 69.766131][ T213] el0_svc+0x4c/0xd8
[ 69.768079][ T213] el0t_64_sync_handler+0x70/0xbc
[ 69.770442][ T213] el0t_64_sync+0x1bc/0x1c0
[ 69.772590][ T213] Code: 510009cd 17ffffec 3707fd61 aa0b03ee (b85fcdcf)
[ 69.775618][ T213] ---[ end trace 0000000000000000 ]---
[ 100.542523][ T213] Kernel panic - not syncing: Oops: Fatal exception
[ 100.545460][ T213] Kernel Offset: 0x29418e0000 from 0xffffffc080000000
[ 100.548421][ T213] PHYS_OFFSET: 0x40000000
[ 100.550497][ T213] CPU features: 0x00000040,0000804b,00200000,4200421b
[ 100.553695][ T213] Memory Limit: none
```

at some point. How to solve this error?
Yesterday 12:30am

The error you're encountering is a kernel panic in the LineageOS 23.2 VM running under QEMU on an a1.metal EC2 instance. The specific error is a translation fault (level 3) at virtual address ffffffe9c0022ffc, which typically indicates a memory access violation or a missing page table entry. This is often caused by:

  1. Incorrect QEMU configuration for ARM64 (aarch64) emulation.
  2. Missing or incompatible firmware (e.g., OVMF_CODE_4M.fd or AAVMF_CODE.fd).
  3. Kernel or module incompatibility with the host or QEMU setup.
  4. Memory or CPU settings not aligned with the guest OS expectations.

Step-by-Step Debugging & Fixes


1. Verify QEMU and KVM Support

  • Ensure KVM is enabled for ARM64 on your a1.metal instance:

    bash
    sudo apt install cpu-checker
    kvm-ok

    If KVM is not available, you may need to enable it in the BIOS or use nested virtualization.

  • Confirm QEMU is compiled with ARM64 and KVM support:

    bash
    qemu-system-aarch64 -version

    Look for KVM in the output.


2. Check Firmware Paths

  • The error suggests the VM is failing during early boot, possibly due to missing or incorrect UEFI firmware.
  • On Debian, the correct paths for ARM64 UEFI firmware are:
    • /usr/share/qemu-efi-aarch64/QEMU_EFI.fd (for QEMU's built-in UEFI)
    • /usr/share/AAVMF/AAVMF_CODE.fd (for AAVMF, ARM64-specific)
  • Replace:
    bash
    VMF_CODE=$(find /usr/share/ -name $([ "$(uname -m)" = "x86_64" ] && echo OVMF_CODE_4M || echo AAVMF_CODE).fd 2>/dev/null)
    with:
    bash
    VMF_CODE="/usr/share/AAVMF/AAVMF_CODE.fd"
    or:
    bash
    VMF_CODE="/usr/share/qemu-efi-aarch64/QEMU_EFI.fd"
    Ensure the file exists:
    bash
    ls -l $VMF_CODE

3. Adjust QEMU Command for ARM64

  • The a1.metal instance uses ARM64 Neoverse-N1 CPUs. Explicitly specify the CPU type:
    bash
    -cpu neoverse-n1
  • Replace -machine virt,gic-version=3 with:
    bash
    -machine virt,gic-version=max
  • Add -bios to explicitly point to the firmware:
    bash
    -bios $VMF_CODE
  • Remove -accel kvm if KVM is not working and try with TCG (slower):
    bash
    -accel tcg

4. Memory and Disk Configuration

  • The error occurs during filesystem creation (mke2fs), which may indicate insufficient memory or disk space.
  • Increase RAM to 16GB (or more if possible):
    bash
    -m 16384
  • Ensure the disk images (vda.qcow2, vdb.qcow2) are properly created and have enough space:
    bash
    qemu-img info ./LineageOS_on_*.utm/Data/vda.qcow2

5. Kernel and Initramfs

  • The kernel panic suggests a module (dlkm_loader_mai) is failing. This could be a LineageOS-specific driver.
  • Try booting with a minimal kernel command line to bypass module loading:
    • Add -kernel and -initrd to your QEMU command if you have a custom kernel/initramfs.
    • Example:
      bash
      -kernel /path/to/Image -initrd /path/to/initramfs.img
  • If using a prebuilt LineageOS image, ensure it is compatible with QEMU/ARM64.

6. Debugging the Kernel Panic

  • The error DABT (current EL), IL = 32 bits suggests a 32-bit access in a 64-bit context. This could be due to:
    • A 32-bit module being loaded in a 64-bit kernel.
    • Misaligned memory access in the kernel or drivers.
  • Check if LineageOS 23.2 is built for ARM64 (aarch64) and not ARM32.
  • If you built the image yourself, ensure the kernel is configured for ARM64:
    bash
    uname -m  # Should return "aarch64"

7. Network and Device Configuration

  • The -netdev user mode may not work well with ARM64. Try:
    bash
    -netdev type=tap,id=net0,ifname=tap0,script=no,downscript=no \
    -device virtio-net-pci,netdev=net0
  • Remove unnecessary USB devices (tablet, mouse, keyboard) to simplify:
    bash
    -device usb-ehci,id=usb-bus \
    -device usb-kbd,bus=usb-bus.0

8. Try a Simpler QEMU Command

Start with a minimal configuration to isolate the issue:

bash
qemu-system-aarch64 \
  -machine virt,gic-version=max \
  -cpu neoverse-n1 \
  -accel kvm \
  -m 16384 \
  -bios /usr/share/AAVMF/AAVMF_CODE.fd \
  -drive file=./LineageOS_on_*.utm/Data/vda.qcow2,format=qcow2,if=virtio \
  -netdev user,id=net0 \
  -device virtio-net-pci,netdev=net0 \
  -nographic

If this works, gradually add back other options.


9. Check LineageOS Compatibility

  • The jqssun/android-lineage-qemu project may have specific requirements for QEMU versions or patches.
  • Review the project's README or issues for ARM64-specific notes.
  • Ensure you are using the correct branch (e.g., lineage-23.2).

10. Enable QEMU Logging

Add -d int,cpu_reset to your QEMU command to capture more detailed logs:

bash
qemu-system-aarch64 -d int,cpu_reset -D /tmp/qemu.log $LINUX_QEMU_OPTS

Check /tmp/qemu.log for clues.


11. Alternative: Use qemu-system-x86_64

If your a1.metal instance supports x86_64 emulation (unlikely, but worth checking), try:

bash
qemu-system-x86_64 -enable-kvm -m 8192 ...

However, a1.metal is ARM64-only, so this is not applicable.


Final Suggested Command

Here’s a revised QEMU command based on the above:

bash
VMF_CODE="/usr/share/AAVMF/AAVMF_CODE.fd"
qemu-system-aarch64 \
  -machine virt,gic-version=max \
  -cpu neoverse-n1 \
  -accel kvm \
  -m 16384 \
  -bios $VMF_CODE \
  -drive if=pflash,unit=0,file=$VMF_CODE,format=raw,readonly=on \
  -drive file=./LineageOS_on_*.utm/Data/vda.qcow2,format=qcow2,if=virtio,id=vda \
  -drive file=./LineageOS_on_*.utm/Data/vdb.qcow2,format=qcow2,if=virtio,id=vdb \
  -device virtio-net-pci,netdev=net0 \
  -netdev user,id=net0 \
  -device usb-ehci,id=usb-bus \
  -device usb-kbd,bus=usb-bus.0 \
  -nographic

Next Steps

  1. Test with a minimal QEMU command (Step 8).
  2. Check the firmware path (Step 2).
  3. Verify LineageOS image compatibility (Step 9).
  4. Review QEMU logs (Step 10).

If the issue persists, share:

  • The exact QEMU version (qemu-system-aarch64 -version).
  • The output of ls -l /usr/share/AAVMF/ and ls -l /usr/share/qemu-efi-aarch64/.
  • The full QEMU command you are using.
Yesterday 12:30am

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more