gt64xxx: fix crash in gt64120_pci_mapping()
authorAvi Kivity <avi@redhat.com>
Wed, 24 Aug 2011 19:09:41 +0000 (22:09 +0300)
committerEdgar E. Iglesias <edgar.iglesias@gmail.com>
Wed, 24 Aug 2011 19:11:21 +0000 (21:11 +0200)
The map/unmap code was assymetric - unmap used the local MemoryRegion while
map used isa_mmio_init(), which cannot handle dynamic mappings.

Fix by using isa_mmio_setup() and the local MemoryRegion.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
hw/gt64xxx.c

index 6af9782d90f55b43cc8d2cc3fd155fb03359788b..1c3425372addbaa5fdd3a985b1f6581a17c8e890 100644 (file)
@@ -297,7 +297,11 @@ static void gt64120_pci_mapping(GT64120State *s)
       s->PCI0IO_start = s->regs[GT_PCI0IOLD] << 21;
       s->PCI0IO_length = ((s->regs[GT_PCI0IOHD] + 1) - (s->regs[GT_PCI0IOLD] & 0x7f)) << 21;
       isa_mem_base = s->PCI0IO_start;
-      isa_mmio_init(s->PCI0IO_start, s->PCI0IO_length);
+      if (s->PCI0IO_length) {
+          isa_mmio_setup(&s->PCI0IO_mem, s->PCI0IO_length);
+          memory_region_add_subregion(get_system_memory(), s->PCI0IO_start,
+                                      &s->PCI0IO_mem);
+      }
     }
 }