Skip to contentSkip to conversation

hw/ide/macio: Fix segfault caused by NULL DMAContext*

PATCH Applied Peter Maydell 2 participants 2 messages Nov 20, 2012 – Nov 23, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/ide/macio: Fix segfault caused by NULL DMAContext*

Pass qemu_sglist_init the global dma_context_memory rather than a NULL pointer; this fixes a segfault in dma_memory_map() when the guest starts using DMA.

---
Test case: download the squeeze standard image from
http://people.debian.org/~aurel32/qemu/powerpc/
and run with
qemu-system-ppc -hda debian_squeeze_powerpc_standard.qcow2
Without this patch it will crash as soon as Linux tries to talk to the disk (the boot loader is OK as it doesn't DMA).

Obvious for-1.3 bugfix.

 hw/ide/macio.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/ide/macio.c +4 -2
index 720af6e..d2edcc0 100644
@@ -76,7 +76,8 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
 
     s->io_buffer_size = io->len;
 
-    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1, NULL);
+    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
+                     &dma_context_memory);
     qemu_sglist_add(&s->sg, io->addr, io->len);
     io->addr += io->len;
     io->len = 0;
@@ -132,7 +133,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
     s->io_buffer_index = 0;
     s->io_buffer_size = io->len;
 
-    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1, NULL);
+    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
+                     &dma_context_memory);
     qemu_sglist_add(&s->sg, io->addr, io->len);
     io->addr += io->len;
     io->len = 0;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · Peter Maydell

Pass qemu_sglist_init the global dma_context_memory rather than a NULL pointer; this fixes a segfault in dma_memory_map() when the guest starts using DMA.

Thanks, applied to ppc-next.

Alex

Quoted 40 lines

---
Test case: download the squeeze standard image from
http://people.debian.org/~aurel32/qemu/powerpc/
and run with
qemu-system-ppc -hda debian_squeeze_powerpc_standard.qcow2
Without this patch it will crash as soon as Linux tries to talk to the disk (the boot loader is OK as it doesn't DMA).

Obvious for-1.3 bugfix.

hw/ide/macio.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
hw/ide/macio.c +4 -2
index 720af6e..d2edcc0 100644
@@ -76,7 +76,8 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret)
 
    s->io_buffer_size = io->len;
 
-    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1, NULL);
+    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
+                     &dma_context_memory);
    qemu_sglist_add(&s->sg, io->addr, io->len);
    io->addr += io->len;
    io->len = 0;
@@ -132,7 +133,8 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)
    s->io_buffer_index = 0;
    s->io_buffer_size = io->len;
 
-    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1, NULL);
+    qemu_sglist_init(&s->sg, io->len / MACIO_PAGE_SIZE + 1,
+                     &dma_context_memory);
    qemu_sglist_add(&s->sg, io->addr, io->len);
    io->addr += io->len;
    io->len = 0;
Signature · 1 line
1.7.9.5