From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Gregory Haskins <ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH 5/9] KVM: Adds ability to signal userspace using a file-descriptor
Date: Tue, 15 May 2007 11:39:11 -0500 [thread overview]
Message-ID: <4649E22F.3090308@us.ibm.com> (raw)
In-Reply-To: <20070515145759.15609.34720.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
This patch series depends on eventfd which means that KVM now requires
2.6.22-rc1.
While KVM will inevitably start requiring newer kernel versions, do we
really need to do it right now? Perhaps we could add dummy eventfd_*
functions to the module compat header? Then at least older kernels will
continue to work with in-kernel APIC disabled.
Regards,
Anthony Liguori
Gregory Haskins wrote:
> Signed-off-by: Gregory Haskins <ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
> ---
>
> drivers/kvm/kvm.h | 1 +
> drivers/kvm/kvm_main.c | 55 +++++++++++++++++++++++++++++++++++++++++++-----
> include/linux/kvm.h | 1 +
> 3 files changed, 51 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
> index d5783dc..e1ba066 100644
> --- a/drivers/kvm/kvm.h
> +++ b/drivers/kvm/kvm.h
> @@ -332,6 +332,7 @@ struct kvm_vcpu_irq {
> int pending;
> int deferred;
> int guest_cpu;
> + int eventfd;
> };
>
> struct kvm_vcpu {
> diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
> index 0c6a62a..7109b66 100644
> --- a/drivers/kvm/kvm_main.c
> +++ b/drivers/kvm/kvm_main.c
> @@ -40,6 +40,7 @@
> #include <linux/file.h>
> #include <linux/fs.h>
> #include <linux/mount.h>
> +#include <linux/eventfd.h>
>
> #include "x86_emulate.h"
> #include "segment_descriptor.h"
> @@ -326,6 +327,7 @@ static struct kvm *kvm_create_vm(void)
> memset(&vcpu->irq, 0, sizeof(vcpu->irq));
> spin_lock_init(&vcpu->irq.lock);
> vcpu->irq.deferred = -1;
> + vcpu->irq.eventfd = -1;
>
> vcpu->cpu = -1;
> vcpu->kvm = kvm;
> @@ -2358,6 +2360,7 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
> {
> struct kvm_vcpu *vcpu = (struct kvm_vcpu*)this->private;
> int direct_ipi = -1;
> + int eventfd = -1;
>
> spin_lock_irq(&vcpu->irq.lock);
>
> @@ -2379,7 +2382,14 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
> */
> direct_ipi = vcpu->irq.guest_cpu;
> BUG_ON(direct_ipi == smp_processor_id());
> - }
> + } else
> + /*
> + * otherwise, we must assume that we could be
> + * blocked anywhere, including userspace. Send
> + * a signal to give everyone a chance to get
> + * notification
> + */
> + eventfd = vcpu->irq.eventfd;
> }
> }
>
> @@ -2401,6 +2411,12 @@ static void kvm_vcpu_intr(struct kvm_irqsink *this,
> smp_call_function_single(direct_ipi,
> kvm_vcpu_guest_intr,
> vcpu, 0, 0);
> +
> + if (eventfd != -1) {
> + struct file *filp = eventfd_fget(eventfd);
> + if (!IS_ERR(filp))
> + eventfd_signal(filp, 1);
> + }
> }
>
> static void kvm_vcpu_irqsink_init(struct kvm_vcpu *vcpu)
> @@ -2584,6 +2600,17 @@ static int kvm_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
> return 0;
> }
>
> +static int kvm_vcpu_ioctl_set_eventfd(struct kvm_vcpu *vcpu, int fd)
> +{
> + if (IS_ERR(eventfd_fget(fd)))
> + return -EINVAL;
> +
> + vcpu->irq.eventfd = fd;
> + smp_wmb();
> +
> + return 0;
> +}
> +
> static long kvm_vcpu_ioctl(struct file *filp,
> unsigned int ioctl, unsigned long arg)
> {
> @@ -2753,6 +2780,15 @@ static long kvm_vcpu_ioctl(struct file *filp,
> r = 0;
> break;
> }
> + case KVM_SET_EVENTFD: {
> + int eventfd = (long)argp;
> +
> + r = kvm_vcpu_ioctl_set_eventfd(vcpu, eventfd);
> + if (r)
> + goto out;
> + r = 0;
> + break;
> + }
> default:
> ;
> }
> @@ -2937,12 +2973,19 @@ static long kvm_dev_ioctl(struct file *filp,
> r = 0;
> break;
> }
> - case KVM_CHECK_EXTENSION:
> - /*
> - * No extensions defined at present.
> - */
> - r = 0;
> + case KVM_CHECK_EXTENSION: {
> + int ext = (long)argp;
> +
> + switch (ext) {
> + case KVM_SET_EVENTFD:
> + r = 1;
> + break;
> + default:
> + r = 0;
> + break;
> + }
> break;
> + }
> case KVM_GET_VCPU_MMAP_SIZE:
> r = -EINVAL;
> if (arg)
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index e6edca8..f13ec8c 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -300,5 +300,6 @@ struct kvm_signal_mask {
> #define KVM_SET_SIGNAL_MASK _IOW(KVMIO, 0x8b, struct kvm_signal_mask)
> #define KVM_GET_FPU _IOR(KVMIO, 0x8c, struct kvm_fpu)
> #define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
> +#define KVM_SET_EVENTFD _IO(KVMIO, 0x8e)
>
> #endif
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> kvm-devel mailing list
> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
>
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-05-15 16:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-15 14:57 [PATCH 0/9] in-kernel APIC v5 (kernel side) Gregory Haskins
[not found] ` <20070515145404.15609.61552.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
2007-05-15 14:57 ` [PATCH 1/9] KVM: Adds support for in-kernel mmio handlers Gregory Haskins
2007-05-15 14:57 ` [PATCH 2/9] KVM: VMX - fix interrupt checking on light-exit Gregory Haskins
2007-05-15 14:57 ` [PATCH 3/9] KVM: Add irqdevice object Gregory Haskins
2007-05-15 14:57 ` [PATCH 4/9] KVM: Adds ability to preempt an executing VCPU Gregory Haskins
2007-05-15 14:57 ` [PATCH 5/9] KVM: Adds ability to signal userspace using a file-descriptor Gregory Haskins
[not found] ` <20070515145759.15609.34720.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
2007-05-15 16:39 ` Anthony Liguori [this message]
[not found] ` <4649E22F.3090308-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-15 16:55 ` Gregory Haskins
[not found] ` <4649AD87.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-05-15 18:44 ` Anthony Liguori
[not found] ` <4649FF7B.10107-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-05-16 11:56 ` Avi Kivity
2007-05-15 14:58 ` [PATCH 6/9] KVM: Add support for in-kernel LAPIC model Gregory Haskins
2007-05-15 14:58 ` [PATCH 7/9] KVM: Adds support for real NMI injection on VMX processors Gregory Haskins
2007-05-15 14:58 ` [PATCH 8/9] KVM: Adds basic plumbing to support TPR shadow features Gregory Haskins
2007-05-15 14:58 ` [PATCH 9/9] KVM: Add statistics from interrupt subsystem Gregory Haskins
-- strict thread matches above, loose matches on Subject: below --
2007-05-15 3:15 [PATCH 0/9] in-kernel APIC v4 (kernel side) Gregory Haskins
[not found] ` <20070515031217.9382.44999.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
2007-05-15 3:15 ` [PATCH 5/9] KVM: Adds ability to signal userspace using a file-descriptor Gregory Haskins
[not found] ` <20070515031536.9382.16826.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
2007-05-15 7:45 ` Avi Kivity
[not found] ` <4649650E.2070102-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-05-15 12:02 ` Gregory Haskins
[not found] ` <464968D6.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-05-15 15:40 ` Davide Libenzi
[not found] ` <Pine.LNX.4.64.0705150832130.30085-GPJ85BhbkB8RepQJljzAVbITYcZ0+W3JAL8bYrjMMd8@public.gmane.org>
2007-05-15 16:18 ` Gregory Haskins
[not found] ` <4649A4E1.BA47.005A.0-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org>
2007-05-15 16:22 ` Christoph Hellwig
[not found] ` <20070515162249.GA19238-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2007-05-15 16:29 ` Gregory Haskins
2007-05-15 17:16 ` Davide Libenzi
[not found] ` <Pine.LNX.4.64.0705151008400.30345-GPJ85BhbkB8RepQJljzAVbITYcZ0+W3JAL8bYrjMMd8@public.gmane.org>
2007-05-16 12:00 ` Avi Kivity
[not found] ` <464AF269.7030402-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-05-16 19:59 ` Davide Libenzi
[not found] ` <Pine.LNX.4.64.0705161201410.12427-GPJ85BhbkB8RepQJljzAVbITYcZ0+W3JAL8bYrjMMd8@public.gmane.org>
2007-05-17 11:33 ` Avi Kivity
[not found] ` <464C3D93.5090605-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-05-17 19:11 ` Davide Libenzi
[not found] ` <Pine.LNX.4.64.0705171010570.31677-GPJ85BhbkB8RepQJljzAVbITYcZ0+W3JAL8bYrjMMd8@public.gmane.org>
2007-05-17 21:57 ` Davide Libenzi
2007-05-20 7:20 ` Avi Kivity
2007-05-16 10:09 ` Avi Kivity
2007-05-16 10:07 ` Avi Kivity
2007-05-09 15:18 [PATCH 0/9] in-kernel APIC v2 Gregory Haskins
[not found] ` <20070509151238.8673.4818.stgit-sLgBBP33vUGnsjUZhwzVf9HuzzzSOjJt@public.gmane.org>
2007-05-09 15:19 ` [PATCH 5/9] KVM: Adds ability to signal userspace using a file-descriptor Gregory Haskins
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=4649E22F.3090308@us.ibm.com \
--to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=ghaskins-Et1tbQHTxzrQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox