KVM: s390: Wire up ioeventfd.
authorCornelia Huck <cornelia.huck@de.ibm.com>
Thu, 28 Feb 2013 11:33:21 +0000 (12:33 +0100)
committerMarcelo Tosatti <mtosatti@redhat.com>
Tue, 5 Mar 2013 22:12:17 +0000 (19:12 -0300)
Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw
notifications.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/s390/kvm/Kconfig
arch/s390/kvm/Makefile
arch/s390/kvm/diag.c
arch/s390/kvm/kvm-s390.c

index 60f9f8ae0fc8b61f977501ad0e46968b77cbed8e..70b46eacf8e163fbd6973428ed9ed5a4b07aefb0 100644 (file)
@@ -22,6 +22,7 @@ config KVM
        select PREEMPT_NOTIFIERS
        select ANON_INODES
        select HAVE_KVM_CPU_RELAX_INTERCEPT
+       select HAVE_KVM_EVENTFD
        ---help---
          Support hosting paravirtualized guest machines using the SIE
          virtualization capability on the mainframe. This should work
index 3975722bb19d87b81381d25570804bb66685a485..8fe9d65a4585b0670c5a1c622d774632b3f39b18 100644 (file)
@@ -6,7 +6,7 @@
 # it under the terms of the GNU General Public License (version 2 only)
 # as published by the Free Software Foundation.
 
-common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o)
+common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o eventfd.o)
 
 ccflags-y := -Ivirt/kvm -Iarch/s390/kvm
 
index a390687feb1359d6b579024d51787e4eeff0207e..1c01a99129896b42868c3dcb67cc2ceda66be97d 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/kvm.h>
 #include <linux/kvm_host.h>
+#include <asm/virtio-ccw.h>
 #include "kvm-s390.h"
 #include "trace.h"
 #include "trace-s390.h"
@@ -104,6 +105,29 @@ static int __diag_ipl_functions(struct kvm_vcpu *vcpu)
        return -EREMOTE;
 }
 
+static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
+{
+       int ret, idx;
+
+       /* No virtio-ccw notification? Get out quickly. */
+       if (!vcpu->kvm->arch.css_support ||
+           (vcpu->run->s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY))
+               return -EOPNOTSUPP;
+
+       idx = srcu_read_lock(&vcpu->kvm->srcu);
+       /*
+        * The layout is as follows:
+        * - gpr 2 contains the subchannel id (passed as addr)
+        * - gpr 3 contains the virtqueue index (passed as datamatch)
+        */
+       ret = kvm_io_bus_write(vcpu->kvm, KVM_VIRTIO_CCW_NOTIFY_BUS,
+                               vcpu->run->s.regs.gprs[2],
+                               8, &vcpu->run->s.regs.gprs[3]);
+       srcu_read_unlock(&vcpu->kvm->srcu, idx);
+       /* kvm_io_bus_write returns -EOPNOTSUPP if it found no match. */
+       return ret < 0 ? ret : 0;
+}
+
 int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
 {
        int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16;
@@ -118,6 +142,8 @@ int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
                return __diag_time_slice_end_directed(vcpu);
        case 0x308:
                return __diag_ipl_functions(vcpu);
+       case 0x500:
+               return __diag_virtio_hypercall(vcpu);
        default:
                return -EOPNOTSUPP;
        }
index 6cae4ad647a9b86a614d66c78421073b3291eaf2..33161b4a8280ee333f7c228fef42cc466d2d0f13 100644 (file)
@@ -142,6 +142,7 @@ int kvm_dev_ioctl_check_extension(long ext)
        case KVM_CAP_ONE_REG:
        case KVM_CAP_ENABLE_CAP:
        case KVM_CAP_S390_CSS_SUPPORT:
+       case KVM_CAP_IOEVENTFD:
                r = 1;
                break;
        case KVM_CAP_NR_VCPUS: