From: "Michael S. Tsirkin" <mst@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: Gregory Haskins <ghaskins@novell.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
davidel@xmailserver.org
Subject: Re: [KVM PATCH v3 2/2] kvm: add support for irqfd via eventfd-notification interface
Date: Sun, 3 May 2009 22:04:27 +0300 [thread overview]
Message-ID: <20090503190427.GB14483@redhat.com> (raw)
In-Reply-To: <49FDCD7C.7070605@redhat.com>
On Sun, May 03, 2009 at 07:59:40PM +0300, Avi Kivity wrote:
> Michael S. Tsirkin wrote:
>> On Mon, Apr 27, 2009 at 02:33:34PM -0400, Gregory Haskins wrote:
>>
>>> This allows an eventfd to be registered as an irq source with a guest. Any
>>> signaling operation on the eventfd (via userspace or kernel) will inject
>>> the registered GSI at the next available window.
>>>
>>> Signed-off-by: Gregory Haskins <ghaskins@novell.com>
>>>
>>
>> If we ever want to use this with e.g. MSI-X emulation in guest, and want
>> to be stricly compliant to MSI-X, we'll need a way for guest to mask
>> interrupts, and for host to report that a masked interrupt is pending.
>> Ideally, all this will be doable with a couple of mmapped pages to avoid
>> vmexits/system calls.
>>
>>
>
> We could do this in two ways:
>
> - move msix entry emulation into the kernel
It's not too bad IMO: MSIX is just a table with a list
of vectors, you check the mask bit on each interrupt,
if masked mark vector pending and poll until unmasked.
> - require the device to support replacing its irqfd, and juggle it like so:
> - guest disables msi
> - replace device model fd with eventfd belonging to us
> - when the device fires its eventfd, set the irq pending bit
> - guest enables msi
> - if the pending bit is set, fire the interrupt?
> - replace device model fd with the real irqfd
Looks like a lot of code. No?
> I'm leaning towards the latter, though it's not an easy call.
Actually there's a third option: add KVM_MASK_IRQ, KVM_UNMASK_IRQ ioctls
which will block/unblock guest from getting interrupt on this irq,
whatever the source. Interrupts are queued in kernel while masked. A
third ioctl KVM_PENDING_IRQS will return the status for a set if IRQs.
qemu would call these ioctls when guest edits the MSIX vector control or
reads the pending bit array.
>>> +static void
>>> +irqfd_inject(struct work_struct *work)
>>> +{
>>> + struct _irqfd *irqfd = container_of(work, struct _irqfd, work);
>>> + struct kvm *kvm = irqfd->kvm;
>>> +
>>> + mutex_lock(&kvm->lock);
>>> + kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 1);
>>> + kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, irqfd->gsi, 0);
>>> + mutex_unlock(&kvm->lock);
>>>
>>
>> This will do weird stuff (deliver the irq twice) if the irq is
>> MSI/MSI-X. I know this was discussed already and is a temporary
>> shortcut, but maybe add a comment that we really want kvm_toggle_irq,
>> so that we won't forget?
>>
>
> If so, that's a bug. MSI should ignore kvm_set_irq(..., 0).
--
MST
next prev parent reply other threads:[~2009-05-03 19:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-27 18:33 [KVM PATCH v3 0/2] irqfd Gregory Haskins
2009-04-27 18:33 ` [KVM PATCH v3 1/2] eventfd: export fget and signal interfaces for module use Gregory Haskins
2009-04-27 18:33 ` [KVM PATCH v3 2/2] kvm: add support for irqfd via eventfd-notification interface Gregory Haskins
2009-04-30 13:07 ` Michael S. Tsirkin
2009-05-03 16:59 ` Avi Kivity
2009-05-03 19:04 ` Michael S. Tsirkin [this message]
2009-05-03 19:17 ` Avi Kivity
2009-05-03 19:25 ` Michael S. Tsirkin
2009-05-03 6:44 ` Al Viro
2009-05-03 18:07 ` Davide Libenzi
2009-05-03 19:01 ` Al Viro
2009-05-03 19:22 ` file descriptor abuses Al Viro
2009-05-03 20:11 ` [KVM PATCH v3 2/2] kvm: add support for irqfd via eventfd-notification interface Davide Libenzi
2009-05-03 20:31 ` Al Viro
2009-04-29 6:10 ` [KVM PATCH v3 0/2] irqfd Andrew Morton
2009-04-29 8:18 ` Avi Kivity
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=20090503190427.GB14483@redhat.com \
--to=mst@redhat.com \
--cc=avi@redhat.com \
--cc=davidel@xmailserver.org \
--cc=ghaskins@novell.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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