Skip to content

qemu-system-nios2 not working on s390x (big endian) hosts

Host environment

  • Operating system: Linux / RHEL 9
  • Architecture: s390x
  • QEMU flavor: qemu-system-nios2
  • QEMU version: current master branch (commit 7ce5a15f)
  • QEMU command line:
    qemu-system-nios2 -nographic -kernel vmlinux.elf

Emulated/Virtualized environment

  • Operating system: Linux
  • OS/kernel version: 4.11.3
  • Architecture: nios2

Description of problem

qemu-system-nios2 fails to boot a Linux kernel on s390x hosts.

Steps to reproduce

  1. wget https://qemu-advcal.gitlab.io/qac-best-of-multiarch/download/day14.tar.xz
  2. tar -xJf day14.tar.xz
  3. cd day14/
  4. qemu-system-nios2 -nographic -kernel vmlinux.elf

Additional information

When running with "-d in_asm", it seems like the code initially starts executing ok, but in one of the early translation blocks, there is a difference when comparing the log with a run from a x86 host:

IN: fdt_check_header
0xc81afd48:  ldw	r3,0(r4)
0xc81afd4c:  srli	r5,r3,24
0xc81afd50:  slli	r2,r3,24
0xc81afd54:  or	r2,r2,r5
0xc81afd58:  slli	r5,r3,8
0xc81afd5c:  srli	r3,r3,8
0xc81afd60:  andhi	r5,r5,255
0xc81afd64:  andi	r3,r3,65280
0xc81afd68:  or	r2,r2,r5
0xc81afd6c:  or	r2,r2,r3
0xc81afd70:  movhi	r3,53262
0xc81afd74:  addi	r3,r3,-275
0xc81afd78:  bne	r2,r3,0xc81afde8

On the x86 host, the branch at the end is not taken, while on the s390x host, the branch is taken.

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