Skip to contentSkip to conversation

sparc: Fix assertion caused by empty memory slot with 0 byte

PATCH Applied Stefan Weil 2 participants 2 messages Apr 14, 2011 – Apr 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: Fix assertion caused by empty memory slot with 0 byte

If the memory size given on the command line is equal to the maximum size of memory defined by the hardware, there is no "empty slot" after physical memory.

The following command

qemu-system-sparc -m 256

raised an assertion:
exec.c:2614: cpu_register_physical_memory_offset: Assertion `size' failed

This can be fixed either at the caller side (don't call empty_slot_init) or in empty_slot_init (do nothing) when size == 0. The second solution was choosen here because it is more robust.

---
 hw/empty_slot.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
hw/empty_slot.c +12 -9
index 664b8d9..da8adc4 100644
@@ -53,18 +53,21 @@ static CPUWriteMemoryFunc * const empty_slot_write[3] = {
 
 void empty_slot_init(target_phys_addr_t addr, uint64_t slot_size)
 {
-    DeviceState *dev;
-    SysBusDevice *s;
-    EmptySlot *e;
+    if (slot_size > 0) {
+        /* Only empty slots larger than 0 byte need handling. */
+        DeviceState *dev;
+        SysBusDevice *s;
+        EmptySlot *e;
 
-    dev = qdev_create(NULL, "empty_slot");
-    s = sysbus_from_qdev(dev);
-    e = FROM_SYSBUS(EmptySlot, s);
-    e->size = slot_size;
+        dev = qdev_create(NULL, "empty_slot");
+        s = sysbus_from_qdev(dev);
+        e = FROM_SYSBUS(EmptySlot, s);
+        e->size = slot_size;
 
-    qdev_init_nofail(dev);
+        qdev_init_nofail(dev);
 
-    sysbus_mmio_map(s, 0, addr);
+        sysbus_mmio_map(s, 0, addr);
+    }
 }
 
 static int empty_slot_init1(SysBusDevice *dev)
Signature · 1 line
1.7.2.5
Applied
#1 lore raw

Thanks, applied.

Quoted 59 lines · Stefan Weil

If the memory size given on the command line is equal to the maximum size of memory defined by the hardware, there is no "empty slot" after physical memory.

The following command

               qemu-system-sparc -m 256

raised an assertion:
exec.c:2614: cpu_register_physical_memory_offset: Assertion `size' failed

This can be fixed either at the caller side (don't call empty_slot_init) or in empty_slot_init (do nothing) when size == 0. The second solution was choosen here because it is more robust.

---
 hw/empty_slot.c |   21 ++++++++++++---------

 1 files changed, 12 insertions(+), 9 deletions(-)
hw/empty_slot.c +12 -10
index 664b8d9..da8adc4 100644
@@ -53,18 +53,21 @@ static CPUWriteMemoryFunc * const empty_slot_write[3] = {
 
  void empty_slot_init(target_phys_addr_t addr, uint64_t slot_size)
  {
-    DeviceState *dev;
-    SysBusDevice *s;
-    EmptySlot *e;
+    if (slot_size > 0) {
+        /* Only empty slots larger than 0 byte need handling. */
+        DeviceState *dev;
+        SysBusDevice *s;
+        EmptySlot *e;
 
-    dev = qdev_create(NULL, "empty_slot");
-    s = sysbus_from_qdev(dev);
-    e = FROM_SYSBUS(EmptySlot, s);
-    e->size = slot_size;
+        dev = qdev_create(NULL, "empty_slot");
+        s = sysbus_from_qdev(dev);
+        e = FROM_SYSBUS(EmptySlot, s);
+        e->size = slot_size;
 
-    qdev_init_nofail(dev);
+        qdev_init_nofail(dev);
 
-    sysbus_mmio_map(s, 0, addr);
+        sysbus_mmio_map(s, 0, addr);
+    }
  }
 
  static int empty_slot_init1(SysBusDevice *dev)
--

1.7.2.5