Re: KVM devices assignment; PCIe AER?

Alex Williamson
2010-10-27T14:54:59Z

On Tue, 2010-10-26 at 20:51 -0700, Etienne Martineau wrote:
>
> On Tue, 26 Oct 2010, Chris Wright wrote:
>
> >> I would totally agree with you if the alternative implementation to
> >> this legacy mode would be available in a relatively short time
> >> frame. I'm not sure about that?
> >
> > Depends on how quickly you can help whip it into shape ;)
>
> Humm, this is not an easy question;
> IMHO the biggest problem of going with VFIO for devices assignment is
> interruption handling. VFIO knows how to signal an eventfd but doesn't
> know about 'kvm_set_irq' for example. I think that VFIO will require
> some adaptation for that matter.

I've actually been working on porting the qemu vfio driver over to
qemu-kvm recently, and nearly have it working. For MSI-X interrupts
I've ported to the common msix.c code, which abstracts how the interrupt
is actually sent to the guest. I've also added irqfd support in the
msix mask notifier so MSI-X interrupts avoid bouncing through qemu. MSI
support should work the same once Michael's msi.c is upstream.

For INTx interrupts, qemu_set_irq will also work with KVM (it has to or
all of the emulated drivers would break). The problem is getting an EOI
back from the KVM kernel apic. I'm currently working on code that adds
a new KVM ioctl to register an eventfd for the EOI, which then triggers
qemu-kvm to re-enable the interrupt. My hope is that we can add irqfd
support to both of these paths, so INTx is injected directly from VFIO
into KVM, and VFIO can directly consume the KVM EOI.

The hard part of this is actually tracking the GSI the device is using
to register the proper EOI handler. I'm working on some pci bridge
callbacks for that now.

> Because qemu device assignment is working on VFIO I'm making the
> assumption that kvm iommu code can be entirely deprecated. Maybe I'm
> totally wrong here?

Yes, VFIO makes no use of it.

Alex