From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGKr0-0004zt-3T for qemu-devel@nongnu.org; Tue, 18 Oct 2011 21:21:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGKqz-0001w7-0O for qemu-devel@nongnu.org; Tue, 18 Oct 2011 21:21:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGKqy-0001w2-NC for qemu-devel@nongnu.org; Tue, 18 Oct 2011 21:21:56 -0400 Date: Wed, 19 Oct 2011 03:22:50 +0200 From: "Michael S. Tsirkin" Message-ID: <20111019012250.GA11470@redhat.com> References: <4E883CF4.6060606@redhat.com> <20111002105238.GE30747@redhat.com> <4E8843DB.1020404@redhat.com> <20111002111700.GF30747@redhat.com> <4E885286.30905@redhat.com> <20111002121426.GK30747@redhat.com> <4E89B5D1.4080600@us.ibm.com> <20111014021407.GB4580@truffala.fritz.box> <4E9AD909.1000509@redhat.com> <20111018014650.GB6655@truffala.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111018014650.GB6655@truffala.fritz.box> Subject: Re: [Qemu-devel] [PATCH 1/9] Add stub functions for PCI device models to do PCI DMA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity , Anthony Liguori , qemu-devel@nongnu.org, joerg.roedel@amd.com, rth@twiddle.net, agraf@suse.de, eduard.munteanu@linux360.ro, kraxel@redhat.com, Paul 'Rusty' Russell , Jason Wang On Tue, Oct 18, 2011 at 12:46:50PM +1100, 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. Fine, but I'm convinced virtio is not unique in that it wants atomic accesses. I just looked at hw/rtl8139.c as one example. It uses a high bit in a 32 bit register to signal descriptor ownership. Thus we need to read that bit first, or read the register atomically. Current code does cpu_physical_memory_read which does neither of these things, but it seems to be a bug. An atomic load would be the best solution. -- MST