All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Jens Freimann <jfrei@linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org,
	Dominik Dingel <dingel@linux.vnet.ibm.com>,
	Alexander Graf <agraf@suse.de>
Subject: Re: [PATCH 2/2] KVM: s390: add floating irq controller
Date: Wed, 31 Jul 2013 11:08:15 +0200	[thread overview]
Message-ID: <20130731110815.602a871e@gondolin> (raw)
In-Reply-To: <1375106393-15811-3-git-send-email-jfrei@linux.vnet.ibm.com>

On Mon, 29 Jul 2013 15:59:53 +0200
Jens Freimann <jfrei@linux.vnet.ibm.com> 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 <jfrei@linux.vnet.ibm.com>
> ---
>  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;
> +	case KVM_DEV_FLIC_CLEAR_IRQS:
> +		clear_floating_interrupts(dev->kvm);
> +	default:
> +		r = -EINVAL;
> +		goto out;
> +	}
> +
> +out_free_s390irq:
> +	kfree(s390irq);
> +out_free_inti:
> +	kfree(inti);
> +out:
> +	return r;
> +}


WARNING: multiple messages have this Message-ID (diff)
From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: Jens Freimann <jfrei@linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Dominik Dingel <dingel@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH 2/2] KVM: s390: add floating irq controller
Date: Wed, 31 Jul 2013 11:08:15 +0200	[thread overview]
Message-ID: <20130731110815.602a871e@gondolin> (raw)
In-Reply-To: <1375106393-15811-3-git-send-email-jfrei@linux.vnet.ibm.com>

On Mon, 29 Jul 2013 15:59:53 +0200
Jens Freimann <jfrei@linux.vnet.ibm.com> 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 <jfrei@linux.vnet.ibm.com>
> ---
>  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;
> +	case KVM_DEV_FLIC_CLEAR_IRQS:
> +		clear_floating_interrupts(dev->kvm);
> +	default:
> +		r = -EINVAL;
> +		goto out;
> +	}
> +
> +out_free_s390irq:
> +	kfree(s390irq);
> +out_free_inti:
> +	kfree(inti);
> +out:
> +	return r;
> +}

  reply	other threads:[~2013-07-31  9:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 13:59 [PATCH 0/2] KVM: s390: add floating irq controller Jens Freimann
2013-07-29 13:59 ` [Qemu-devel] " Jens Freimann
2013-07-29 13:59 ` [PATCH 1/2] KVM: s390: add and extend interrupt information data structs Jens Freimann
2013-07-29 13:59   ` [Qemu-devel] " Jens Freimann
2013-07-29 13:59 ` [PATCH 2/2] KVM: s390: add floating irq controller Jens Freimann
2013-07-29 13:59   ` [Qemu-devel] " Jens Freimann
2013-07-31  9:08   ` Cornelia Huck [this message]
2013-07-31  9:08     ` Cornelia Huck
2013-07-31 17:09     ` Jens Freimann
2013-07-31 17:09       ` [Qemu-devel] " Jens Freimann
2013-08-01  5:21     ` Heiko Carstens
2013-08-01  5:21       ` [Qemu-devel] " Heiko Carstens
2013-08-01 12:47       ` Jens Freimann
2013-08-01 12:47         ` [Qemu-devel] " Jens Freimann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130731110815.602a871e@gondolin \
    --to=cornelia.huck@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=dingel@linux.vnet.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.