All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio/s390: get rid of open-coded kvm hypercall
@ 2021-06-21 14:45 Heiko Carstens
  2021-06-21 15:27 ` Cornelia Huck
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Heiko Carstens @ 2021-06-21 14:45 UTC (permalink / raw)
  To: Cornelia Huck, Halil Pasic
  Cc: Vasily Gorbik, Christian Borntraeger, linux-s390, kvm

do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant
of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(),
and get rid of duplicated code.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
 drivers/s390/virtio/virtio_ccw.c | 30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
index 54e686dca6de..d35e7a3f7067 100644
--- a/drivers/s390/virtio/virtio_ccw.c
+++ b/drivers/s390/virtio/virtio_ccw.c
@@ -388,31 +388,6 @@ static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,
 	ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
 }
 
-static inline long __do_kvm_notify(struct subchannel_id schid,
-				   unsigned long queue_index,
-				   long cookie)
-{
-	register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY;
-	register struct subchannel_id __schid asm("2") = schid;
-	register unsigned long __index asm("3") = queue_index;
-	register long __rc asm("2");
-	register long __cookie asm("4") = cookie;
-
-	asm volatile ("diag 2,4,0x500\n"
-		      : "=d" (__rc) : "d" (__nr), "d" (__schid), "d" (__index),
-		      "d"(__cookie)
-		      : "memory", "cc");
-	return __rc;
-}
-
-static inline long do_kvm_notify(struct subchannel_id schid,
-				 unsigned long queue_index,
-				 long cookie)
-{
-	diag_stat_inc(DIAG_STAT_X500);
-	return __do_kvm_notify(schid, queue_index, cookie);
-}
-
 static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
 {
 	struct virtio_ccw_vq_info *info = vq->priv;
@@ -421,7 +396,10 @@ static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
 
 	vcdev = to_vc_device(info->vq->vdev);
 	ccw_device_get_schid(vcdev->cdev, &schid);
-	info->cookie = do_kvm_notify(schid, vq->index, info->cookie);
+	BUILD_BUG_ON(sizeof(struct subchannel_id) != sizeof(unsigned int));
+	info->cookie = kvm_hypercall3(KVM_S390_VIRTIO_CCW_NOTIFY,
+				      *((unsigned int *)&schid),
+				      vq->index, info->cookie);
 	if (info->cookie < 0)
 		return false;
 	return true;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio/s390: get rid of open-coded kvm hypercall
  2021-06-21 14:45 [PATCH] virtio/s390: get rid of open-coded kvm hypercall Heiko Carstens
@ 2021-06-21 15:27 ` Cornelia Huck
  2021-06-21 19:42   ` Heiko Carstens
  2021-06-21 17:05 ` Christian Borntraeger
  2021-06-21 23:50 ` Halil Pasic
  2 siblings, 1 reply; 5+ messages in thread
From: Cornelia Huck @ 2021-06-21 15:27 UTC (permalink / raw)
  To: Heiko Carstens, Halil Pasic
  Cc: Vasily Gorbik, Christian Borntraeger, linux-s390, kvm

On Mon, Jun 21 2021, Heiko Carstens <hca@linux.ibm.com> wrote:

> do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant
> of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(),
> and get rid of duplicated code.
>
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>  drivers/s390/virtio/virtio_ccw.c | 30 ++++--------------------------
>  1 file changed, 4 insertions(+), 26 deletions(-)
>

Hm, I wonder why I didn't use kvm_hypercall3 in the first place. It's in
a header, and therefore should be independent of kvm being configured.

I don't think there's anything else virtio-ccw in flight at the moment,
so maybe you can apply this one directly?

Reviewed-by: Cornelia Huck <cohuck@redhat.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio/s390: get rid of open-coded kvm hypercall
  2021-06-21 14:45 [PATCH] virtio/s390: get rid of open-coded kvm hypercall Heiko Carstens
  2021-06-21 15:27 ` Cornelia Huck
@ 2021-06-21 17:05 ` Christian Borntraeger
  2021-06-21 23:50 ` Halil Pasic
  2 siblings, 0 replies; 5+ messages in thread
From: Christian Borntraeger @ 2021-06-21 17:05 UTC (permalink / raw)
  To: Heiko Carstens, Cornelia Huck, Halil Pasic; +Cc: Vasily Gorbik, linux-s390, kvm

On 21.06.21 16:45, Heiko Carstens wrote:
> do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant
> of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(),
> and get rid of duplicated code.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> ---
>   drivers/s390/virtio/virtio_ccw.c | 30 ++++--------------------------
>   1 file changed, 4 insertions(+), 26 deletions(-)

Certainly a nice improvement in terms of LOCs.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>

  
> diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c
> index 54e686dca6de..d35e7a3f7067 100644
> --- a/drivers/s390/virtio/virtio_ccw.c
> +++ b/drivers/s390/virtio/virtio_ccw.c
> @@ -388,31 +388,6 @@ static void virtio_ccw_drop_indicator(struct virtio_ccw_device *vcdev,
>   	ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area));
>   }
>   
> -static inline long __do_kvm_notify(struct subchannel_id schid,
> -				   unsigned long queue_index,
> -				   long cookie)
> -{
> -	register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY;
> -	register struct subchannel_id __schid asm("2") = schid;
> -	register unsigned long __index asm("3") = queue_index;
> -	register long __rc asm("2");
> -	register long __cookie asm("4") = cookie;
> -
> -	asm volatile ("diag 2,4,0x500\n"
> -		      : "=d" (__rc) : "d" (__nr), "d" (__schid), "d" (__index),
> -		      "d"(__cookie)
> -		      : "memory", "cc");
> -	return __rc;
> -}
> -
> -static inline long do_kvm_notify(struct subchannel_id schid,
> -				 unsigned long queue_index,
> -				 long cookie)
> -{
> -	diag_stat_inc(DIAG_STAT_X500);
> -	return __do_kvm_notify(schid, queue_index, cookie);
> -}
> -
>   static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
>   {
>   	struct virtio_ccw_vq_info *info = vq->priv;
> @@ -421,7 +396,10 @@ static bool virtio_ccw_kvm_notify(struct virtqueue *vq)
>   
>   	vcdev = to_vc_device(info->vq->vdev);
>   	ccw_device_get_schid(vcdev->cdev, &schid);
> -	info->cookie = do_kvm_notify(schid, vq->index, info->cookie);
> +	BUILD_BUG_ON(sizeof(struct subchannel_id) != sizeof(unsigned int));
> +	info->cookie = kvm_hypercall3(KVM_S390_VIRTIO_CCW_NOTIFY,
> +				      *((unsigned int *)&schid),
> +				      vq->index, info->cookie);
   	if (info->cookie < 0)
>   		return false;
>   	return true;
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio/s390: get rid of open-coded kvm hypercall
  2021-06-21 15:27 ` Cornelia Huck
@ 2021-06-21 19:42   ` Heiko Carstens
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2021-06-21 19:42 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Halil Pasic, Vasily Gorbik, Christian Borntraeger, linux-s390, kvm

On Mon, Jun 21, 2021 at 05:27:00PM +0200, Cornelia Huck wrote:
> On Mon, Jun 21 2021, Heiko Carstens <hca@linux.ibm.com> wrote:
> 
> > do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant
> > of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(),
> > and get rid of duplicated code.
> >
> > Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
> > ---
> >  drivers/s390/virtio/virtio_ccw.c | 30 ++++--------------------------
> >  1 file changed, 4 insertions(+), 26 deletions(-)
> >
> 
> Hm, I wonder why I didn't use kvm_hypercall3 in the first place. It's in
> a header, and therefore should be independent of kvm being configured.
> 
> I don't think there's anything else virtio-ccw in flight at the moment,
> so maybe you can apply this one directly?

Yes, sure.

> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thank you!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] virtio/s390: get rid of open-coded kvm hypercall
  2021-06-21 14:45 [PATCH] virtio/s390: get rid of open-coded kvm hypercall Heiko Carstens
  2021-06-21 15:27 ` Cornelia Huck
  2021-06-21 17:05 ` Christian Borntraeger
@ 2021-06-21 23:50 ` Halil Pasic
  2 siblings, 0 replies; 5+ messages in thread
From: Halil Pasic @ 2021-06-21 23:50 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Cornelia Huck, Vasily Gorbik, Christian Borntraeger, linux-s390, kvm

On Mon, 21 Jun 2021 16:45:22 +0200
Heiko Carstens <hca@linux.ibm.com> wrote:

> do_kvm_notify() and __do_kvm_notify() are an (exact) open-coded variant
> of kvm_hypercall3(). Therefore simply make use of kvm_hypercall3(),
> and get rid of duplicated code.
> 
> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-21 23:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 14:45 [PATCH] virtio/s390: get rid of open-coded kvm hypercall Heiko Carstens
2021-06-21 15:27 ` Cornelia Huck
2021-06-21 19:42   ` Heiko Carstens
2021-06-21 17:05 ` Christian Borntraeger
2021-06-21 23:50 ` Halil Pasic

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.