Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio/s390: get rid of open-coded kvm hypercall

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: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Link: https://lore.kernel.org/r/20210621144522.1304273-1-hca@linux.ibm.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Heiko Carstens and committed by
Vasily Gorbik
e5e1bdf0 c1e18c17

+4 -26
+4 -26
drivers/s390/virtio/virtio_ccw.c
··· 388 388 ccw_device_dma_free(vcdev->cdev, thinint_area, sizeof(*thinint_area)); 389 389 } 390 390 391 - static inline long __do_kvm_notify(struct subchannel_id schid, 392 - unsigned long queue_index, 393 - long cookie) 394 - { 395 - register unsigned long __nr asm("1") = KVM_S390_VIRTIO_CCW_NOTIFY; 396 - register struct subchannel_id __schid asm("2") = schid; 397 - register unsigned long __index asm("3") = queue_index; 398 - register long __rc asm("2"); 399 - register long __cookie asm("4") = cookie; 400 - 401 - asm volatile ("diag 2,4,0x500\n" 402 - : "=d" (__rc) : "d" (__nr), "d" (__schid), "d" (__index), 403 - "d"(__cookie) 404 - : "memory", "cc"); 405 - return __rc; 406 - } 407 - 408 - static inline long do_kvm_notify(struct subchannel_id schid, 409 - unsigned long queue_index, 410 - long cookie) 411 - { 412 - diag_stat_inc(DIAG_STAT_X500); 413 - return __do_kvm_notify(schid, queue_index, cookie); 414 - } 415 - 416 391 static bool virtio_ccw_kvm_notify(struct virtqueue *vq) 417 392 { 418 393 struct virtio_ccw_vq_info *info = vq->priv; ··· 396 421 397 422 vcdev = to_vc_device(info->vq->vdev); 398 423 ccw_device_get_schid(vcdev->cdev, &schid); 399 - info->cookie = do_kvm_notify(schid, vq->index, info->cookie); 424 + BUILD_BUG_ON(sizeof(struct subchannel_id) != sizeof(unsigned int)); 425 + info->cookie = kvm_hypercall3(KVM_S390_VIRTIO_CCW_NOTIFY, 426 + *((unsigned int *)&schid), 427 + vq->index, info->cookie); 400 428 if (info->cookie < 0) 401 429 return false; 402 430 return true;