From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cornelia Huck Subject: Re: [PATCH v4 6/6] KVM: s390: Wire up ioeventfd. Date: Thu, 28 Feb 2013 11:20:13 +0100 Message-ID: <20130228112013.39fb7974@gondolin> References: <1362043352-56889-1-git-send-email-cornelia.huck@de.ibm.com> <1362043352-56889-7-git-send-email-cornelia.huck@de.ibm.com> <20130228095045.GC7806@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , Gleb Natapov , Christian Borntraeger , Carsten Otte , Alexander Graf , Heiko Carstens , Martin Schwidefsky , KVM , linux-s390 , qemu-devel To: "Michael S. Tsirkin" Return-path: Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:40258 "EHLO e06smtp18.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751388Ab3B1KUW (ORCPT ); Thu, 28 Feb 2013 05:20:22 -0500 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Feb 2013 10:18:00 -0000 In-Reply-To: <20130228095045.GC7806@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 28 Feb 2013 11:50:45 +0200 "Michael S. Tsirkin" wrote: > On Thu, Feb 28, 2013 at 10:22:32AM +0100, Cornelia Huck wrote: > > Enable ioeventfd support on s390 and hook up diagnose 500 virtio-ccw > > notifications. > > > > Signed-off-by: Cornelia Huck > > --- > > arch/s390/kvm/Kconfig | 1 + > > arch/s390/kvm/Makefile | 2 +- > > arch/s390/kvm/diag.c | 26 ++++++++++++++++++++++++++ > > arch/s390/kvm/kvm-s390.c | 1 + > > 4 files changed, 29 insertions(+), 1 deletion(-) > > > > diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig > > index b58dd86..3c43e30 100644 > > --- a/arch/s390/kvm/Kconfig > > +++ b/arch/s390/kvm/Kconfig > > @@ -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 > > diff --git a/arch/s390/kvm/Makefile b/arch/s390/kvm/Makefile > > index 3975722..8fe9d65 100644 > > --- a/arch/s390/kvm/Makefile > > +++ b/arch/s390/kvm/Makefile > > @@ -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 > > > > diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c > > index a390687..96907f2 100644 > > --- a/arch/s390/kvm/diag.c > > +++ b/arch/s390/kvm/diag.c > > @@ -13,6 +13,7 @@ > > > > #include > > #include > > +#include > > #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; > > Yes but it returns 8 on success. You probably want 0. So: > return ret < 0 ? ret : 0; Whoops. Doesn't seem to have hurt, though. v6 will come up shortly. > > > +} > > + > > 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; > > } > > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > > index f822d36..04d2454 100644 > > --- a/arch/s390/kvm/kvm-s390.c > > +++ b/arch/s390/kvm/kvm-s390.c > > @@ -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: > > -- > > 1.7.12.4 >