qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/9] Add stub functions for PCI device models to


From: Avi Kivity
Subject: Re: [Qemu-devel] [PATCH 1/9] Add stub functions for PCI device models to do PCI DMA
Date: Wed, 19 Oct 2011 11:10:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1

On 10/18/2011 03:46 AM, David Gibson wrote:
> On Sun, Oct 16, 2011 at 03:15:53PM +0200, Avi Kivity wrote:
> > On 10/14/2011 04:14 AM, David Gibson wrote:
> > > > Virtio is a very, very special case.  virtio requires coherent RAM 
> > > > access.
> > >
> > > Right.  Virtio's access to memory is *not* emulated PCI DMA, it's
> > > god-like hypervisor access to guest system memory.  It should
> > > correctly bypass any IOMMU, and so should remain as
> > > cpu_physical_memory_rw() or the atomic accessors, rather than being
> > > converted to this new API.
> > 
> > virtio should definitely not bypass an iommu.
>
> So, I just had a chat with Rusty about this.  Perhaps it shouldn't,
> but it does.  The spec is in terms of guest physical addresses, not
> bus/DMA addresses, and more to the point the Linux driver does *not*
> do the necessary dma_map() and unmap operations to treat this as a PCI
> DMA.  So like it or not, god-like hypervisor access rather than
> emulated PCI DMA is what it does.

Wow, how did we manage to break virtio in so many different ways?

Is there a way to unbreak it?  On x86 it will continue to work if we
rewrite the spec in terms of pci dma, what about non-x86?

>
> >  A guest may assign a
> > virtio device to nested guests, and would wish it confined by the
> > emulated iommu.
>
> Well, that would be nice, but it can't be done.  It could be fixed,
> but it would be an incompatible change so it would need a new feature
> bit corresponding changes in the Linux driver to do the dma map/unmap
> if it accepts the "respect IOMMU" feature.

Needs to be done IMO.

>
> > More generally, a guest sees a virtio device as just another pci device,
> > and has no way to tell that it bypasses the iommu.
>
> Well, except the fact that the driver knows its a virtio device,
> because it's a virtio driver.  It's not like you can write a driver
> that uses PCI DMA without knowing the particulars of the device you're
> using.

virtio-pci knows it's pci, there's no excuse.

-- 
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]