I have compiled QEMU 10.1-rc4 from source on ppc64el.

Running
qemu-system-riscv64 -M virt -cpu rv64,h=off -nographic
results in an error:

...
Boot HART MIDELEG         : 0x0000000000001666
Boot HART MEDELEG         : 0x0000000000f0b509
**
ERROR:../target/riscv/pmu.c:216:riscv_pmu_icount_update_priv: assertion
failed: (newpriv <= PRV_S)
Bail out! ERROR:../target/riscv/pmu.c:216:riscv_pmu_icount_update_priv:
assertion failed: (newpriv <= PRV_S)
Aborted (core dumped)

The problem seems to be introduced with patch
68c05fb53036 ("target/riscv: Combine set_mode and set_virt functions.")

After this patch QEMU exits unexpectedly without showing the error. But
anyway it is not expected to exit from running OpenSBI. Before that
patch OpenSBI just hangs when no kernel image is provided.

This is the call sequence leading to the problem in QEMU 10.1-rc4:

riscv_pmu_icount_update_priv() is first called with newpriv = 1 (S-Mode)
then with newpriv = 3 (M-mode)

riscv_cpu_set_mode(env, PRV_M, virt) is executed in
riscv_cpu_do_interrupt().
When trapping to M-mode virt should always be false as M-mode is not
virtualized.
virt should always be false if the hypervisor extension (h) is disabled.

This is the call stack:

#0  riscv_pmu_icount_update_priv (env=<optimized out>,
newpriv=<optimized out>, new_virt=<optimized out>) at
../target/riscv/pmu.c:212
212             snapshot_prev = env->pmu_fixed_ctrs[1].counter_prev;
(gdb) up
#1  riscv_pmu_update_fixed_ctrs (env=env@entry=0x101595950,
newpriv=newpriv@entry=3, new_virt=new_virt@entry=false) at
../target/riscv/pmu.c:272
272         riscv_pmu_icount_update_priv(env, newpriv, new_virt);
(gdb)
#2  0x000000010085018c in riscv_cpu_set_mode (env=env@entry=0x101595950,
newpriv=newpriv@entry=3, virt_en=virt_en@entry=false) at
../target/riscv/cpu_helper.c:1040
1040            riscv_pmu_update_fixed_ctrs(env, newpriv, virt_en);
(gdb)
#3  0x00000001008514d4 in riscv_cpu_do_interrupt (cs=<optimized out>) at
../target/riscv/cpu_helper.c:2454
2454            riscv_cpu_set_mode(env, PRV_M, virt);
(gdb)
#4  0x000000010076e7c4 in cpu_handle_exception (cpu=0x101592bc0,
ret=<synthetic pointer>) at ../accel/tcg/cpu-exec.c:727
727             tcg_ops->do_interrupt(cpu);
(gdb)
#5  cpu_exec_loop (cpu=cpu@entry=0x101592bc0,
sc=sc@entry=0x7ffff12bd880) at ../accel/tcg/cpu-exec.c:921
921         while (!cpu_handle_exception(cpu, &ret)) {
(gdb)
#6  0x000000010076ea9c in cpu_exec_setjmp (cpu=cpu@entry=0x101592bc0,
sc=sc@entry=0x7ffff12bd880) at ../accel/tcg/cpu-exec.c:999
999         return cpu_exec_loop(cpu, sc);
(gdb)
#7  0x000000010076f290 in cpu_exec (cpu=cpu@entry=0x101592bc0) at
../accel/tcg/cpu-exec.c:1025
1025        ret = cpu_exec_setjmp(cpu, &sc);
(gdb)
#8  0x000000010079f094 in tcg_cpu_exec (cpu=cpu@entry=0x101592bc0) at
../accel/tcg/tcg-accel-ops.c:82
82          ret = cpu_exec(cpu);
(gdb)
#9  0x000000010079f7bc in mttcg_cpu_thread_fn
(arg=arg@entry=0x101592bc0) at ../accel/tcg/tcg-accel-ops-mttcg.c:94
94                  r = tcg_cpu_exec(cpu);
(gdb)
#10 0x0000000100c4513c in qemu_thread_start (args=<optimized out>) at
../util/qemu-thread-posix.c:393
393         r = start_routine(arg);
(gdb)
Download failed: Invalid argument.  Continuing without source file
./nptl/pthread_create.c.
#11 0x00007ffff54b53ec in start_thread (arg=0x7ffff12be6a0) at
pthread_create.c:448
(gdb)
Download failed: Invalid argument.  Continuing without source file
./misc/../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S.
#12 0x00007ffff5568978 in __GI___clone3 () at
../sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S:114

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2120835

Title:
  EDK2 tests for riscv emulation fail against qemu 10.1 on ppc64

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/edk2/+bug/2120835/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to