From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4lKJ-0002v7-I5 for qemu-devel@nongnu.org; Thu, 01 Aug 2013 01:21:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4lKA-0005sj-K2 for qemu-devel@nongnu.org; Thu, 01 Aug 2013 01:21:27 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:55125) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4lKA-0005qJ-Cc for qemu-devel@nongnu.org; Thu, 01 Aug 2013 01:21:18 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 1 Aug 2013 06:15:56 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id B798D17D8057 for ; Thu, 1 Aug 2013 06:22:57 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r715L1kZ64815316 for ; Thu, 1 Aug 2013 05:21:01 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r715LCFa031571 for ; Wed, 31 Jul 2013 23:21:12 -0600 Date: Thu, 1 Aug 2013 07:21:11 +0200 From: Heiko Carstens Message-ID: <20130801052111.GA32335@osiris> References: <1375106393-15811-1-git-send-email-jfrei@linux.vnet.ibm.com> <1375106393-15811-3-git-send-email-jfrei@linux.vnet.ibm.com> <20130731110815.602a871e@gondolin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130731110815.602a871e@gondolin> Subject: Re: [Qemu-devel] [PATCH 2/2] KVM: s390: add floating irq controller List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cornelia Huck Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, Dominik Dingel , Alexander Graf , Christian Borntraeger , Jens Freimann On Wed, Jul 31, 2013 at 11:08:15AM +0200, Cornelia Huck wrote: > On Mon, 29 Jul 2013 15:59:53 +0200 > Jens Freimann wrote: > > > This patch adds a floating irq controller as a kvm_device. > > It will be necesary for migration of floating interrupts as well > > as for hardening the reset code by allowing user space to explicitly > > remove all pending floating interrupts. > > > > Signed-off-by: Jens Freimann > > --- > > arch/s390/include/uapi/asm/kvm.h | 5 + > > arch/s390/kvm/interrupt.c | 210 +++++++++++++++++++++++++++++++-------- > > arch/s390/kvm/kvm-s390.c | 1 + > > include/linux/kvm_host.h | 1 + > > include/uapi/linux/kvm.h | 1 + > > virt/kvm/kvm_main.c | 3 + > > 6 files changed, 181 insertions(+), 40 deletions(-) > > > > > +static int flic_set_attr(struct kvm_device *dev, struct kvm_device_attr *attr) > > +{ > > + int r; > > + struct kvm_s390_irq *s390irq; > > + struct kvm_s390_interrupt_info *inti; > > + > > + switch (attr->group) { > > + case KVM_DEV_FLIC_ENQUEUE: > > + inti = kzalloc(sizeof(*inti), GFP_KERNEL); > > + if (!inti) { > > + r = -ENOMEM; > > + goto out; > > + } > > + s390irq = kzalloc(sizeof(*s390irq), GFP_KERNEL); > > + if (!s390irq) { > > + r = -ENOMEM; > > + goto out_free_inti; > > + } > > + if (copy_from_user(s390irq, (u64 __user *)attr->addr, > > + sizeof(s390irq))) { > > + r = -EFAULT; > > + goto out_free_s390irq; > > + } > > Can't you just copy into inti->irq here? You'd get rid of allocating > two structures that way. > > > + switch(s390irq->type) { > > + case KVM_S390_INT_VIRTIO: > > + case KVM_S390_INT_SERVICE: > > + case KVM_S390_INT_IO_MIN...KVM_S390_INT_IO_MAX: > > + case KVM_S390_MCHK: > > + inti->irq = *s390irq; > > + __inject_vm(dev->kvm, inti); > > + default: > > + r = -EINVAL; > > + } > > + break; And, due to missing break statement, it will always return -EINVAL ;)