diff mbox

[v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL

Message ID 20170423223240.17917-1-aurelien@aurel32.net (mailing list archive)
State New, archived
Headers show

Commit Message

Aurelien Jarno April 23, 2017, 10:32 p.m. UTC
s390_virtio_hypercall can trigger IO events and interrupts, most notably
when using virtio-ccw devices.

Reviewed-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target/s390x/misc_helper.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Philippe Mathieu-Daudé April 23, 2017, 10:38 p.m. UTC | #1
Hi Aurelien!

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

regards,

Phil.

On 04/23/2017 07:32 PM, Aurelien Jarno wrote:
> s390_virtio_hypercall can trigger IO events and interrupts, most notably
> when using virtio-ccw devices.
>
> Reviewed-by: Alexander Graf <agraf@suse.de>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
>  target/s390x/misc_helper.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
> index 4946b56ab3..aec737d707 100644
> --- a/target/s390x/misc_helper.c
> +++ b/target/s390x/misc_helper.c
> @@ -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 */
>
Aurelien Jarno April 23, 2017, 10:47 p.m. UTC | #2
On 2017-04-23 19:38, Philippe Mathieu-Daudé wrote:
> 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.
Philippe Mathieu-Daudé April 23, 2017, 11:09 p.m. UTC | #3
On 04/23/2017 07:47 PM, Aurelien Jarno wrote:
> On 2017-04-23 19:38, Philippe Mathieu-Daudé wrote:
>> 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!

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox

Patch

diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index 4946b56ab3..aec737d707 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -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 */