Il 26/10/2012 05:58, David Gibson ha scritto:
>> > static inline int dma_memory_rw_relaxed(DMAContext *dma, dma_addr_t addr,
>> >                                         void *buf, dma_addr_t len,
>> >                                         DMADirection dir)
>> > {
>> >     if (!dma_has_iommu(dma)) {
>> >         /* Fast-path for no IOMMU */
>> >         address_space_rw(dma->as, addr, buf, len, dir ==
>> > DMA_DIRECTION_FROM_DEVICE);
>> >         return 0;
>> >     } else {
>> >         return iommu_dma_memory_rw(dma, addr, buf, len, dir);
>> >     }
>> > }
>> > 
>> > Dereferencing of dma->as segfaults sd dma==NULL in the cas you described.
> Ok.  My inclination would be to special case that in that function,
> setting as to the standard memory as if !dma, but others may have a
> different opinion.

Me too, because I'm seeing the exact same segfault with virtio-scsi.  
Reproducible with:

x86_64-softmmu/qemu-system-x86_64 -device virtio-scsi-pci -drive if=none,id=cd 
-device scsi-cd,drive=cd

(you don't even need a medium in the drive, it segfaults as soon as the BIOS 
probes
the device).

As soon as Avi's iommu patches go in, in fact, dma->as will just be as.
Even if as == NULL were to be outlawed and you'd be forced to write
get_address_space_memory(), taking the pain to create dummy DMAContexts
now is just not worth it.

Paolo

Reply via email to