From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRjfb-0000JR-QI for qemu-devel@nongnu.org; Fri, 26 Oct 2012 09:09:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TRjfV-0005D5-M8 for qemu-devel@nongnu.org; Fri, 26 Oct 2012 09:09:51 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:60222) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRjfV-0005Cs-GM for qemu-devel@nongnu.org; Fri, 26 Oct 2012 09:09:45 -0400 Received: by mail-bk0-f45.google.com with SMTP id jf3so1065896bkc.4 for ; Fri, 26 Oct 2012 06:09:44 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <508A8B96.60302@redhat.com> Date: Fri, 26 Oct 2012 15:09:42 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1351013211-1907-1-git-send-email-peter.maydell@linaro.org> <20121026004832.GG7222@truffula.fritz.box> <20121026035812.GK7222@truffula.fritz.box> In-Reply-To: <20121026035812.GK7222@truffula.fritz.box> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] dma: Define dma_context_memory and use in sysbus-ohci List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: Peter Maydell , Peter Crosthwaite , patches@linaro.org, qemu-devel@nongnu.org, Avi Kivity , Gerd Hoffmann 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