qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] sysbus-ohci segfaults with NULL DMAContext*
Date: Tue, 23 Oct 2012 18:15:34 +0200	[thread overview]
Message-ID: <5086C2A6.8010909@redhat.com> (raw)
In-Reply-To: <CAFEAcA_orE6ceF=gEtcFBby0UpvA3xCv1SKxmM2ovs7QfXXfVA@mail.gmail.com>

On 10/23/2012 06:00 PM, Peter Maydell wrote:
> (found while trying to rebase the qemu-linaro OMAP3 patches;
> dunno if it's reproducable in plain mainline easily)
> 
> Commit 9ac6a217 makes ohci_init_pxa() set up the OHCI code
> with a NULL DMAContext*, and asserts in the commit message:
> 
> "in the SysBus case, it uses NULL - i.e. assumes for now that there
> will be no IOMMU translation for a SysBus OHCI."
> 
> However if you actually try to use the device it segfaults:
> 
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 0x7ffff7fb97c0 (LWP 23837)]
> 0x000055555571b47c in dma_memory_rw_relaxed (dma=0x0, addr=2658340864,
> buf=0x7fffffffded0, len=136,
>     dir=DMA_DIRECTION_TO_DEVICE) at ./dma.h:125
> 125             address_space_rw(dma->as, addr, buf, len, dir ==
> DMA_DIRECTION_FROM_DEVICE);
> (gdb) bt
> #0  0x000055555571b47c in dma_memory_rw_relaxed (dma=0x0,
> addr=2658340864, buf=0x7fffffffded0, len=136,
>     dir=DMA_DIRECTION_TO_DEVICE) at ./dma.h:125
> #1  0x000055555571b527 in dma_memory_rw (dma=0x0, addr=2658340864,
> buf=0x7fffffffded0, len=136,
>     dir=DMA_DIRECTION_TO_DEVICE) at ./dma.h:151
> #2  0x000055555571b582 in dma_memory_read (dma=0x0, addr=2658340864,
> buf=0x7fffffffded0, len=136) at ./dma.h:157
> #3  0x000055555571c1ae in ohci_read_hcca (ohci=0x5555566dbf80,
> addr=2658340864, hcca=0x7fffffffded0)
>     at hw/usb/hcd-ohci.c:570
> #4  0x000055555571d9b5 in ohci_frame_boundary (opaque=0x5555566dbf80)
> at hw/usb/hcd-ohci.c:1206
> #5  0x000055555578f424 in qemu_run_timers (clock=0x5555565d4590) at
> qemu-timer.c:392
> #6  0x000055555578f666 in qemu_run_all_timers () at qemu-timer.c:448
> #7  0x0000555555753799 in main_loop_wait (nonblocking=0) at main-loop.c:502
> #8  0x00005555557e157d in main_loop () at vl.c:1652
> #9  0x00005555557e82d4 in main (argc=18, argv=0x7fffffffe478,
> envp=0x7fffffffe510) at vl.c:3787
> 
> 
> Is the problem that we should not be passing a NULL DMAContext*
> around in the first place, or that dma_memory_read() is
> incorrectly not handling the NULL ?

The former.  I changed PCI to always create a DMAContext
(817dcc5368988b), but I didn't consider sysbus-ohci.

After the iommu patchset, DMAContext is a no-op wrapper around
AddressSpace.  We can unwrap it, and use address_space_memory instead.
For now I suggest creating a global DMAContext that wraps
address_space_memory (don't have a good name for it) and use it instead
of NULL.

-- 
error compiling committee.c: too many arguments to function

      reply	other threads:[~2012-10-23 16:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 16:00 [Qemu-devel] sysbus-ohci segfaults with NULL DMAContext* Peter Maydell
2012-10-23 16:15 ` Avi Kivity [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5086C2A6.8010909@redhat.com \
    --to=avi@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).