On Fri, Jan 18, 2013 at 05:14:02PM +0100, Paolo Bonzini wrote: ... > > This relies on the assumption that the ring (which is contiguous in the > > guest's physical address space) is also contiguous in the host's virtual > > address space. In principle the property could be easily verified once > > the ring is set up. > > IIRC, the amount of contiguous memory is written by address_space_map in > the plen parameter. > > In your case: > > > + s->txring = address_space_map(pci_dma_context(&s->dev)->as, > > + base, &desclen, 0 /* is_write */); > > that would be desclen on return from address_space_map.
ok thanks. > > And of course, am i missing some important detail ? > > Unfortunately yes. > > First, host memory mappings could change (though they rarely do on PC). > The result of address_space_map is not guaranteed to be stable. To > avoid problems with this, however, you could use something like > hw/dataplane/hostmem.c and even avoid address_space_map altogether. I'll look into that. Hopefully there is something that i can use as a notification that the mapping has changed... > Second, that pci_dma_*() could have the addresses translated by an > IOMMU. virtio is documented to have "real" physical memory addresses, > but this does not apply to other devices. I see. I suppose the ability to have an iommu depends on the specific NIC ? I am only planning to use the above shortcut for e1000. thanks a lot for the quick feedback luigi