qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v1 8/8] usb/ehci: Put RAM in undefined MMIO regions


From: Peter Crosthwaite
Subject: [Qemu-devel] [PATCH v1 8/8] usb/ehci: Put RAM in undefined MMIO regions
Date: Thu, 25 Oct 2012 19:47:19 +1000

Just put RAM regions in the unimplemented spaces in the MMIO region. These
regions have undefined behaviour, but this at least stops QEMU from segfaulting
when the guest bangs on these registers (and sucessfully fakes reading and
writing the registers with no side effects).

Signed-off-by: Peter Crosthwaite <address@hidden>
---

 hw/usb/hcd-ehci.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
index 78f9dfd..b6418bc 100644
--- a/hw/usb/hcd-ehci.c
+++ b/hw/usb/hcd-ehci.c
@@ -396,6 +396,8 @@ struct EHCIState {
     MemoryRegion mem_caps;
     MemoryRegion mem_opreg;
     MemoryRegion mem_ports;
+    MemoryRegion mem_other_low;
+    MemoryRegion mem_other_high;
     int companion_count;
 
     /* properties */
@@ -2773,17 +2775,27 @@ static void usb_ehci_initfn(EHCIState *s, DeviceState 
*dev)
     qemu_add_vm_change_state_handler(usb_ehci_vm_state_change, s);
 
     memory_region_init(&s->mem, "ehci", MMIO_SIZE);
+    if (s->capabase) {
+        memory_region_init_ram(&s->mem_other_low, "other-low", s->capabase);
+    }
     memory_region_init_io(&s->mem_caps, &ehci_mmio_caps_ops, s,
                           "capabilities", s->opregbase);
     memory_region_init_io(&s->mem_opreg, &ehci_mmio_opreg_ops, s,
                           "operational", PORTSC_BEGIN);
     memory_region_init_io(&s->mem_ports, &ehci_mmio_port_ops, s,
                           "ports", PORTSC_END - PORTSC_BEGIN);
+    memory_region_init_ram(&s->mem_other_high, "other-high", MMIO_SIZE -
+                           s->opregbase - (PORTSC_END - PORTSC_BEGIN));
 
+    if (s->capabase) {
+        memory_region_add_subregion(&s->mem, 0, &s->mem_other_low);
+    }
     memory_region_add_subregion(&s->mem, s->capabase, &s->mem_caps);
     memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
     memory_region_add_subregion(&s->mem, s->opregbase + PORTSC_BEGIN,
                                 &s->mem_ports);
+    memory_region_add_subregion(&s->mem, s->opregbase + PORTSC_END,
+                                &s->mem_other_high);
 }
 
 static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
-- 
1.7.0.4




reply via email to

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