Skip to contentSkip to conversation

BQL patches for the lm32 target

PATCH Superseded Michael Walle 1 participant 3 messages May 21, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover BQL patches for the lm32 target

I'll send a pull request next week if there are no comments on the patches.

Michael Walle (2):
lm32: take BQL before writing IP/IM register
target/lm32: hold BQL in gdbstub

 target/lm32/gdbstub.c   | 4 ++++
 target/lm32/op_helper.c | 4 ++++
 2 files changed, 8 insertions(+)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/2 lm32: take BQL before writing IP/IM register

Writing to these registers may raise an interrupt request. Actually, this prevents the milkymist board from starting.

---
 target/lm32/op_helper.c | 4 ++++
 1 file changed, 4 insertions(+)
target/lm32/op_helper.c +4 -0
index 577f8306e3..234d55e056 100644
@@ -102,12 +102,16 @@ void HELPER(wcsr_dc)(CPULM32State *env, uint32_t dc)
 
 void HELPER(wcsr_im)(CPULM32State *env, uint32_t im)
 {
+    qemu_mutex_lock_iothread();
     lm32_pic_set_im(env->pic_state, im);
+    qemu_mutex_unlock_iothread();
 }
 
 void HELPER(wcsr_ip)(CPULM32State *env, uint32_t im)
 {
+    qemu_mutex_lock_iothread();
     lm32_pic_set_ip(env->pic_state, im);
+    qemu_mutex_unlock_iothread();
 }
 
 void HELPER(wcsr_jtx)(CPULM32State *env, uint32_t jtx)
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/2 target/lm32: hold BQL in gdbstub

In reply to Michael Walle

Changing the IP/IM registers may cause interrupts, so hold the BQL.

---
 target/lm32/gdbstub.c | 4 ++++
 1 file changed, 4 insertions(+)
target/lm32/gdbstub.c +4 -0
index cf929dd392..2cdeef8f5e 100644
@@ -82,10 +82,14 @@ int lm32_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
             env->ie = tmp;
             break;
         case 37:
+            qemu_mutex_lock_iothread();
             lm32_pic_set_im(env->pic_state, tmp);
+            qemu_mutex_unlock_iothread();
             break;
         case 38:
+            qemu_mutex_lock_iothread();
             lm32_pic_set_ip(env->pic_state, tmp);
+            qemu_mutex_unlock_iothread();
             break;
         }
     }
Signature · 1 line
2.11.0