qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbu


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci
Date: Fri, 26 Oct 2012 15:09:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1

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

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