Skip to contentSkip to conversation

macio: Add unimp region for debugging

PATCH New BALATON Zoltan 1 participant 1 message May 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macio: Add unimp region for debugging

The macio device has a container mmio region that embeds several other devices. Some of these devices are not implemented but because of the container region, the unassigned memory traces don't catch accesses to these. To help debugging, add an unimplemented-device covering the container region to get logs when the guest accesses unassigned areas.

---
Here's a patch that should help getting logs for unimplemented registers in macio with -d unimp which may help finding out where the writes go and what needs to be implemented.

 hw/misc/Kconfig       | 1 +
 hw/misc/macio/macio.c | 9 +++++++++
 2 files changed, 10 insertions(+)
hw/misc/Kconfig +1 -0
index 1e08785b83..4197a786d6 100644
@@ -66,6 +66,7 @@ config MACIO
     select MAC_DBDMA
     select MAC_NVRAM
     select MOS6522
+    select UNIMP
 
 config IVSHMEM_DEVICE
     bool
hw/misc/macio/macio.c +9 -0
index 3f449f91c0..43b683c294 100644
@@ -34,6 +34,7 @@
 #include "hw/char/escc.h"
 #include "hw/misc/macio/macio.h"
 #include "hw/intc/heathrow_pic.h"
+#include "hw/misc/unimp.h"
 #include "trace.h"
 
 #define ESCC_CLOCK 3686400
@@ -94,6 +95,14 @@ static bool macio_common_realize(PCIDevice *d, Error **errp)
 {
     MacIOState *s = MACIO(d);
     SysBusDevice *sbd;
+    DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE);
+
+    qdev_prop_set_string(dev, "name", "macio-unimp");
+    qdev_prop_set_uint64(dev, "size", memory_region_size(&s->bar));
+    sbd = SYS_BUS_DEVICE(dev);
+    sysbus_realize_and_unref(sbd, &error_fatal);
+    memory_region_add_subregion_overlap(&s->bar, 0,
+                                        sysbus_mmio_get_region(sbd, 0), -1000);
 
     if (!qdev_realize(DEVICE(&s->dbdma), BUS(&s->macio_bus), errp)) {
         return false;
Signature · 1 line
2.30.9