qemu-system-mipsel regression, Linux generated with Buildroot does not boot anymore

Host environment

  • Operating system: Debian/GNU Linux 11
  • OS/kernel version: 5.10
  • Architecture: MIPS Little Endian
  • QEMU flavor: qemu-system-mipsel
  • QEMU version: 9.0.2
  • QEMU command line: qemu-system-mipsel -M malta -kernel vmlinux -drive file=rootfs.ext2,format=raw -append "rootwait root=/dev/sda " -net nic,model=pcnet -net user -cpu P5600 -nographic

Emulated/Virtualized environment

  • Operating system: Linux
  • OS/kernel version: 6.6.18
  • Architecture: MIPS Little Endian r5 (mips32r5el)

Description of problem

Buildroot Toolchain Builders try to release a new version. See a message from Thomas Petazzoni with the remaining issues: https://lore.kernel.org/buildroot/20240730223542.273693e5@windsurf/T/#u

All toolchains generate a system that fails to boot:

Run /sbin/init as init process process '/bin/busybox' started with executable stack Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004

The interesting thing is that those images boot fine with Qemu v8.2.6, but they fail to boot with Qemu v9.0.2.

I tracked it down to this commit: commit 4e999bf4 Author: Richard Henderson richard.henderson@linaro.org Date: Sun Jan 28 15:58:52 2024 +1000

target/mips: Pass ptw_mmu_idx down from mips_cpu_tlb_fill

Rather than adjust env->hflags so that the value computed
by cpu_mmu_index() changes, compute the mmu_idx that we
want directly and pass it down.

Introduce symbolic constants for MMU_{KERNEL,ERL}_IDX.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Unfortunately just reverting this commit in 9.0.2 does not help, Qemu segfaults on Linux Kernel boot then.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information