Skip to contentSkip to conversation

s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL

PATCH In review Aurelien Jarno 2 participants 4 messages Apr 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL

s390_virtio_hypercall can trigger IO events and interrupts, most notably when using virtio-ccw devices.

---
 target/s390x/misc_helper.c | 2 ++
 1 file changed, 2 insertions(+)
target/s390x/misc_helper.c +2 -0
index 4946b56ab3..aec737d707 100644
@@ -307,7 +307,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
     switch (num) {
     case 0x500:
         /* KVM hypercall */
+        qemu_mutex_lock_iothread();
         r = s390_virtio_hypercall(env);
+        qemu_mutex_unlock_iothread();
         break;
     case 0x44:
         /* yield */
Signature · 1 line
2.11.0
#1 lore raw

Hi Aurelien!

Why don't lock inside s390_virtio_hypercall() directly round the diag500 dispatch call?

regards,

Phil.

Quoted 24 lines · Aurelien Jarno

s390_virtio_hypercall can trigger IO events and interrupts, most notably when using virtio-ccw devices.

---
 target/s390x/misc_helper.c | 2 ++
 1 file changed, 2 insertions(+)
target/s390x/misc_helper.c +2 -0
index 4946b56ab3..aec737d707 100644
@@ -307,7 +307,9 @@ void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
     switch (num) {
     case 0x500:
         /* KVM hypercall */
+        qemu_mutex_lock_iothread();
         r = s390_virtio_hypercall(env);
+        qemu_mutex_unlock_iothread();
         break;
     case 0x44:
         /* yield */
#2 lore raw
Quoted 4 lines · Philippe Mathieu-Daudé

Hi Aurelien!

Why don't lock inside s390_virtio_hypercall() directly round the diag500 dispatch call?

s390_virtio_hypercall is shared between TCG and KVM. For KVM the lock is already done before calling s390_virtio_hypercall in kvm_arch_handle_exit.

Signature · 2 lines
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
[email protected]                 http://www.aurel32.net
#3 lore raw
Quoted 8 lines · Aurelien Jarno
Quoted 4 lines · Philippe Mathieu-Daudé

Hi Aurelien!

Why don't lock inside s390_virtio_hypercall() directly round the diag500 dispatch call?

s390_virtio_hypercall is shared between TCG and KVM. For KVM the lock is already done before calling s390_virtio_hypercall in kvm_arch_handle_exit.

Fair enough!