Skip to contentSkip to conversation

hw/ppc: Fix iothread locking in the 405 code

PATCH Applied Thomas Huth 3 participants 3 messages Oct 6, 2021 – Oct 7, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ppc: Fix iothread locking in the 405 code

When using u-boot as firmware with the taihu board, QEMU aborts with this assertion:

ERROR:../accel/tcg/tcg-accel-ops.c:79:tcg_handle_interrupt: assertion failed:
(qemu_mutex_iothread_locked())

Running QEMU with "-d in_asm" shows that the crash happens when writing to SPR 0x3f2, so we are missing to lock the iothread in the code path here.

---
 hw/ppc/ppc.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/ppc/ppc.c +4 -0
index f5d012f860..bb57f1c9ed 100644
@@ -336,6 +336,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
 {
     PowerPCCPU *cpu = env_archcpu(env);
 
+    qemu_mutex_lock_iothread();
+
     switch ((val >> 28) & 0x3) {
     case 0x0:
         /* No action */
@@ -353,6 +355,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
         ppc40x_system_reset(cpu);
         break;
     }
+
+    qemu_mutex_unlock_iothread();
 }
 
 /* PowerPC 40x internal IRQ controller */
Signature · 1 line
2.27.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Thomas Huth

When using u-boot as firmware with the taihu board, QEMU aborts with this assertion:

ERROR:../accel/tcg/tcg-accel-ops.c:79:tcg_handle_interrupt: assertion failed:
(qemu_mutex_iothread_locked())

Running QEMU with "-d in_asm" shows that the crash happens when writing to SPR 0x3f2, so we are missing to lock the iothread in the code path here.

Thanks,

C.

Quoted 27 lines
---
  hw/ppc/ppc.c | 4 ++++
  1 file changed, 4 insertions(+)
hw/ppc/ppc.c +4 -0
index f5d012f860..bb57f1c9ed 100644
@@ -336,6 +336,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
  {
      PowerPCCPU *cpu = env_archcpu(env);
 
+    qemu_mutex_lock_iothread();
+
      switch ((val >> 28) & 0x3) {
      case 0x0:
          /* No action */
@@ -353,6 +355,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
          ppc40x_system_reset(cpu);
          break;
      }
+
+    qemu_mutex_unlock_iothread();
  }
 
  /* PowerPC 40x internal IRQ controller */
Applied
#2 lore raw
In reply to Thomas Huth
Quoted 11 lines · Thomas Huth

When using u-boot as firmware with the taihu board, QEMU aborts with this assertion:

ERROR:../accel/tcg/tcg-accel-ops.c:79:tcg_handle_interrupt: assertion failed:
(qemu_mutex_iothread_locked())

Running QEMU with "-d in_asm" shows that the crash happens when writing to SPR 0x3f2, so we are missing to lock the iothread in the code path here.

Applied to ppc-for-6.2, thanks.

Quoted 26 lines
---
 hw/ppc/ppc.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/ppc/ppc.c +4 -0
index f5d012f860..bb57f1c9ed 100644
@@ -336,6 +336,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
 {
     PowerPCCPU *cpu = env_archcpu(env);
 
+    qemu_mutex_lock_iothread();
+
     switch ((val >> 28) & 0x3) {
     case 0x0:
         /* No action */
@@ -353,6 +355,8 @@ void store_40x_dbcr0(CPUPPCState *env, uint32_t val)
         ppc40x_system_reset(cpu);
         break;
     }
+
+    qemu_mutex_unlock_iothread();
 }
 
 /* PowerPC 40x internal IRQ controller */
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson