[Qemu-devel] [PATCH v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL

Aurelien Jarno posted 1 patch 6 years, 12 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170423223240.17917-1-aurelien@aurel32.net
Test checkpatch passed
Test docker passed
Test s390x passed
target/s390x/misc_helper.c | 2 ++
1 file changed, 2 insertions(+)
[Qemu-devel] [PATCH v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL
Posted by Aurelien Jarno 6 years, 12 months ago
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 */
-- 
2.11.0


Re: [Qemu-devel] [PATCH v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL
Posted by Philippe Mathieu-Daudé 6 years, 12 months ago
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 */
>

Re: [Qemu-devel] [PATCH v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL
Posted by Aurelien Jarno 6 years, 12 months ago
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.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

Re: [Qemu-devel] [PATCH v2] s390x/misc_helper.c: wrap s390_virtio_hypercall in BQL
Posted by Philippe Mathieu-Daudé 6 years, 12 months ago
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>