helper_access_check_cp_reg() raising Undefined Instruction on big-endian host
As of commit 222059a0, when running the Avocado test from commit 27dfbafa ("tests/acceptance: Add a boot test for the xlnx-versal-virt machine") on a s390x host, I get:
$ gdb -q ./qemu-system-aarch64
(gdb) b raise_exception if target_el==2
(gdb) r -display none -machine xlnx-versal-virt -m 2G -accel tcg -kernel ~/avocado/data/cache/by_location/86dbba0cf1f2cb724a2a5a3f3b29eb4126f52d45/linux -initrd ~/avocado/data/cache/by_location/86dbba0cf1f2cb724a2a5a3f3b29eb4126f52d45/initrd.gz -serial mon:stdio -d in_asm -trace memory\* -d int,in_asm
[...]
----------------
IN:
0xffff000008990268: a9bf7bfd stp x29, x30, [sp, #-0x10]!
0xffff00000899026c: 910003fd mov x29, sp
0xffff000008990270: aa1e03e0 mov x0, x30
0xffff000008990274: d503201f nop
0xffff000008990278: d53be220 mrs x0, cntp_ctl_el0
0xffff00000899027c: 927f7800 and x0, x0, #0xfffffffe
0xffff000008990280: d51be220 msr cntp_ctl_el0, x0
[Switching to Thread 0x3ffea9bf900 (LWP 3773576)]
Thread 3 "qemu-system-aar" hit Breakpoint 17, raise_exception (env=env@entry=0x3ffeaab3540, excp=excp@entry=1, syndrome=syndrome@entry=1647507461, target_el=2)
at ../../target/arm/op_helper.c:49
49 CPUState *cs = env_cpu(env);
(gdb) bt
#0 raise_exception (env=env@entry=0x3ffeaab3540, excp=excp@entry=1, syndrome=syndrome@entry=1647507461, target_el=2) at ../../target/arm/op_helper.c:49
#1 0x000002aa007f3f52 in helper_access_check_cp_reg (env=0x3ffeaab3540, rip=0x2aa01c394f0, syndrome=1647507461, isread=<optimized out>) at ../../target/arm/op_helper.c:705
#2 0x000003ffa45ba2c8 in code_gen_buffer ()
#3 0x000002aa00ae9c62 in cpu_tb_exec (tb_exit=<synthetic pointer>, itb=0x3ffa45ba100 <code_gen_buffer+6004964>, cpu=<optimized out>) at ../../accel/tcg/cpu-exec.c:438
#4 cpu_loop_exec_tb (tb_exit=<synthetic pointer>, last_tb=<synthetic pointer>, pc=<optimized out>, tb=0x3ffa45ba100 <code_gen_buffer+6004964>, cpu=<optimized out>)
at ../../accel/tcg/cpu-exec.c:868
#5 cpu_exec (cpu=<optimized out>) at ../../accel/tcg/cpu-exec.c:1032
#6 0x0000000000000400 in ()
(gdb) c
Continuing.
Taking exception 1 [Undefined Instruction] on CPU 0
...from EL1 to EL2
...with ESR 0x18/0x6232f805
...with ELR 0xffff000008990278
...to EL2 PC 0xb66400 PSTATE 0x3c9
It works fine on x86_64 host.