Skip to contentSkip to conversation

Pegasos2 clean up and pegasos1 emulation

PATCH Superseded BALATON Zoltan 4 participants 42 messages Oct 18, 2025 – Nov 8, 2025 Arm/Amlogic Meson SoC support

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Pegasos2 clean up and pegasos1 emulation

This series changes how the fdt for VOF is generated in pegasos2 by moving the static parts to a dtb and only generate the changing parts such as memory size and PCI devices programmatically. This simplifies the code and allows simply adding emulation of Pegasos I which has a different north bridge and slightly different memory map but otherwise very similar and can be emulated by reusing parts from the amigaone machine. The machine was tested with a Pegasos I ROM image and MorphOS.

The first VOF patch (submitted separetely before, the reviewed v3 is included here) fixes handling the name property in VOF that cannot be represented in a dts as that always takes the path as the name and cannot accept an explicit name property but we need the name property to appear when guest queries properties which previously was worked around by adding it to every node.

The series also adds an extended DEFINE_MACHINE macro that is later used for more easily define the abstract machine type and hide most of the QOM boiler plate.

Regards,
BALATON Zoltan

Link to previous version:
https://patchew.org/QEMU/[email protected]/

v3:
- rebase on master

v2:
- rebase on master
- added some R-b tags from Philippe
- move first patch later (was first to allow merging separately)
- clarify blurb above

BALATON Zoltan (13):
ppc/vof: Make nextprop behave more like Open Firmware hw/ppc/pegasos2: Remove explicit name properties from device tree hw/ppc/pegasos2: Change device tree generation hw/ppc/pegasos2: Remove fdt pointer from machine state hw/ppc/pegasos2: Rename mv field in machine state hw/ppc/pegasos2: Add south bridge pointer in the machine state hw/ppc/pegasos2: Move PCI IRQ routing setup to a function hw/ppc/pegasos2: Move hardware specific parts out of machine reset hw/ppc/pegasos2: Introduce abstract superclass hw/ppc/pegasos2: Add bus frequency to machine state hw/boards: Extend DEFINE_MACHINE macro to cover more use cases hw/ppc/pegasos2: Add Pegasos I emulation hw/ppc/pegasos2: Add VOF support for pegasos1

 MAINTAINERS              |   1 +
 hw/ppc/pegasos2.c        | 770 +++++++++++++++++++--------------------
 hw/ppc/vof.c             |  50 ++-
 include/hw/boards.h      |  16 +-
 pc-bios/dtb/meson.build  |   2 +
 pc-bios/dtb/pegasos1.dtb | Bin 0 -> 857 bytes
 pc-bios/dtb/pegasos1.dts | 125 +++++++
 pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
 pc-bios/dtb/pegasos2.dts | 167 +++++++++
 9 files changed, 718 insertions(+), 413 deletions(-)
 create mode 100644 pc-bios/dtb/pegasos1.dtb
 create mode 100644 pc-bios/dtb/pegasos1.dts
 create mode 100644 pc-bios/dtb/pegasos2.dtb
 create mode 100644 pc-bios/dtb/pegasos2.dts
Signature · 1 line
2.41.3
#1 lore raw

PATCH v3 1/13 ppc/vof: Make nextprop behave more like Open Firmware

The FDT does not normally store name properties but reconstructs it from path but Open Firmware specification says each node should at least have this property. This is correctly handled in getprop but nextprop should also return it even if not present as a property.

Explicit name properties are still allowed because they are needed e.g. on the root node that guests expect to have specific names as seen on real machines instead of being empty so sometimes the node name may need to be overriden. For example on pegasos MorphOS checks the name of "/" and expects to find bplan,Pegasos2 which is how it identifies the machine.

---
 hw/ppc/vof.c | 50 +++++++++++++++++++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 17 deletions(-)
hw/ppc/vof.c +33 -17
index f14efa3a7c..5ecfc68910 100644
@@ -353,34 +353,50 @@ static uint32_t vof_nextprop(const void *fdt, uint32_t phandle,
 {
     int offset, nodeoff = fdt_node_offset_by_phandle(fdt, phandle);
     char prev[OF_PROPNAME_LEN_MAX + 1];
-    const char *tmp;
+    const char *tmp = NULL;
+    bool match = false;
 
     if (readstr(prevaddr, prev, sizeof(prev))) {
         return PROM_ERROR;
     }
-
-    fdt_for_each_property_offset(offset, fdt, nodeoff) {
-        if (!fdt_getprop_by_offset(fdt, offset, &tmp, NULL)) {
-            return 0;
+    /*
+     * "name" may or may not be present in fdt but we should still return it.
+     * Do that first and then skip it if seen later.
+     */
+    if (prev[0] == '\0') {
+        tmp = "name";
+    } else {
+        if (strcmp(prev, "name") == 0) {
+            prev[0] = '\0';
         }
-        if (prev[0] == '\0' || strcmp(prev, tmp) == 0) {
-            if (prev[0] != '\0') {
-                offset = fdt_next_property_offset(fdt, offset);
-                if (offset < 0) {
-                    return 0;
-                }
-            }
+        fdt_for_each_property_offset(offset, fdt, nodeoff) {
             if (!fdt_getprop_by_offset(fdt, offset, &tmp, NULL)) {
                 return 0;
             }
-
-            if (VOF_MEM_WRITE(nameaddr, tmp, strlen(tmp) + 1) != MEMTX_OK) {
-                return PROM_ERROR;
+            if (strcmp(tmp, "name") == 0) {
+                continue;
+            }
+            if (match) {
+                break;
             }
-            return 1;
+            if (strcmp(prev, tmp) == 0) {
+                match = true;
+                continue;
+            }
+            if (prev[0] == '\0') {
+                break;
+            }
+        }
+        if (offset < 0) {
+            return 0;
         }
     }
-
+    if (tmp) {
+        if (VOF_MEM_WRITE(nameaddr, tmp, strlen(tmp) + 1) != MEMTX_OK) {
+            return PROM_ERROR;
+        }
+        return 1;
+    }
     return 0;
 }
 
Signature · 1 line
2.41.3
#2 lore raw

PATCH v3 2/13 hw/ppc/pegasos2: Remove explicit name properties from device tree

In reply to BALATON Zoltan

These are not needed any more now that VOF can handle it.

---
 hw/ppc/pegasos2.c | 17 -----------------
 1 file changed, 17 deletions(-)
hw/ppc/pegasos2.c +0 -17
index e15cf96427..73995624e5 100644
@@ -662,7 +662,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 1);
     qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 2);
     qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "isa");
-    qemu_fdt_setprop_string(fi->fdt, fi->path, "name", "isa");
 
     /* additional devices */
     g_string_printf(name, "%s/lpt@i3bc", fi->path);
@@ -677,7 +676,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(8);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "lpt");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "lpt");
 
     g_string_printf(name, "%s/fdc@i3f0", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -691,7 +689,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(8);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "fdc");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "fdc");
 
     g_string_printf(name, "%s/timer@i40", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -701,7 +698,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(8);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "timer");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "timer");
 
     g_string_printf(name, "%s/rtc@i70", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -716,7 +712,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(2);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "rtc");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "rtc");
 
     g_string_printf(name, "%s/keyboard@i60", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -729,7 +724,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(5);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "keyboard");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "keyboard");
 
     g_string_printf(name, "%s/8042@i60", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -743,7 +737,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(5);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "8042");
 
     g_string_printf(name, "%s/serial@i2f8", fi->path);
     qemu_fdt_add_subnode(fi->fdt, name->str);
@@ -757,7 +750,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     cells[2] = cpu_to_be32(8);
     qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "serial");
-    qemu_fdt_setprop_string(fi->fdt, name->str, "name", "serial");
 
     g_string_free(name, TRUE);
 }
@@ -846,7 +838,6 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
         j += 5;
     }
     qemu_fdt_setprop(fi->fdt, node->str, "reg", cells, j * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, node->str, "name", name ?: pn);
     if (pci_get_byte(&d->config[PCI_INTERRUPT_PIN])) {
         qemu_fdt_setprop_cell(fi->fdt, node->str, "interrupts",
                               pci_get_byte(&d->config[PCI_INTERRUPT_PIN]));
@@ -916,7 +907,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#size-cells", 2);
     qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#address-cells", 3);
     qemu_fdt_setprop_string(fdt, "/pci@c0000000", "device_type", "pci");
-    qemu_fdt_setprop_string(fdt, "/pci@c0000000", "name", "pci");
 
     fi.path = "/pci@c0000000";
     pci_bus = mv64361_get_pci_bus(pm->mv, 0);
@@ -951,7 +941,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#size-cells", 2);
     qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#address-cells", 3);
     qemu_fdt_setprop_string(fdt, "/pci@80000000", "device_type", "pci");
-    qemu_fdt_setprop_string(fdt, "/pci@80000000", "name", "pci");
 
     fi.path = "/pci@80000000";
     pci_bus = mv64361_get_pci_bus(pm->mv, 1);
@@ -959,7 +948,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
 
     qemu_fdt_add_subnode(fdt, "/failsafe");
     qemu_fdt_setprop_string(fdt, "/failsafe", "device_type", "serial");
-    qemu_fdt_setprop_string(fdt, "/failsafe", "name", "failsafe");
 
     qemu_fdt_add_subnode(fdt, "/rtas");
     qemu_fdt_setprop_cell(fdt, "/rtas", "system-reboot", RTAS_SYSTEM_REBOOT);
@@ -989,14 +977,12 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-display-device", 0);
     qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", 20);
     qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-version", 1);
-    qemu_fdt_setprop_string(fdt, "/rtas", "name", "rtas");
 
     /* cpus */
     qemu_fdt_add_subnode(fdt, "/cpus");
     qemu_fdt_setprop_cell(fdt, "/cpus", "#cpus", 1);
     qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1);
     qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0);
-    qemu_fdt_setprop_string(fdt, "/cpus", "name", "cpus");
 
     /* FIXME Get CPU name from CPU object */
     const char *cp = "/cpus/PowerPC,G4";
@@ -1048,7 +1034,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     cells[1] = 0;
     qemu_fdt_setprop(fdt, cp, "reg", cells, 2 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fdt, cp, "device_type", "cpu");
-    qemu_fdt_setprop_string(fdt, cp, "name", strrchr(cp, '/') + 1);
 
     /* memory */
     qemu_fdt_add_subnode(fdt, "/memory@0");
@@ -1056,7 +1041,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     cells[1] = cpu_to_be32(machine->ram_size);
     qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fdt, "/memory@0", "device_type", "memory");
-    qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory");
 
     qemu_fdt_add_subnode(fdt, "/chosen");
     if (pm->initrd_addr && pm->initrd_size) {
@@ -1067,7 +1051,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     }
     qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                             machine->kernel_cmdline ?: "");
-    qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen");
 
     qemu_fdt_add_subnode(fdt, "/openprom");
     qemu_fdt_setprop_string(fdt, "/openprom", "model", "Pegasos2,1.1");
Signature · 1 line
2.41.3
#3 lore raw

PATCH v3 3/13 hw/ppc/pegasos2: Change device tree generation

In reply to BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

---
 hw/ppc/pegasos2.c        | 292 +++++++--------------------------------
 pc-bios/dtb/meson.build  |   1 +
 pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
 pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++
 4 files changed, 220 insertions(+), 240 deletions(-)
 create mode 100644 pc-bios/dtb/pegasos2.dtb
 create mode 100644 pc-bios/dtb/pegasos2.dts
hw/ppc/pegasos2.c +52 -240
index 73995624e5..646755a3cc 100644
@@ -58,16 +58,8 @@
 #define BUS_FREQ_HZ 133333333
 
 #define PCI0_CFG_ADDR 0xcf8
-#define PCI0_MEM_BASE 0xc0000000
-#define PCI0_MEM_SIZE 0x20000000
-#define PCI0_IO_BASE  0xf8000000
-#define PCI0_IO_SIZE  0x10000
-
 #define PCI1_CFG_ADDR 0xc78
-#define PCI1_MEM_BASE 0x80000000
-#define PCI1_MEM_SIZE 0x40000000
 #define PCI1_IO_BASE  0xfe000000
-#define PCI1_IO_SIZE  0x10000
 
 #define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2")
 OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)
@@ -411,7 +403,11 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
         error_report("Memory for initrd is in use");
         exit(1);
     }
+
     fdt = build_fdt(machine, &sz);
+    if (!fdt) {
+        exit(1);
+    }
     /* FIXME: VOF assumes entry is same as load address */
     d[0] = cpu_to_be64(pm->kernel_entry);
     d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr));
@@ -654,113 +650,12 @@ static void dt_usb(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
     qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "usb");
 }
 
-static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi)
-{
-    GString *name = g_string_sized_new(64);
-    uint32_t cells[3];
-
-    qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 1);
-    qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 2);
-    qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "isa");
-
-    /* additional devices */
-    g_string_printf(name, "%s/lpt@i3bc", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(7);
-    cells[1] = 0;
-    qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
-                     cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x3bc);
-    cells[2] = cpu_to_be32(8);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "lpt");
-
-    g_string_printf(name, "%s/fdc@i3f0", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(6);
-    cells[1] = 0;
-    qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
-                     cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x3f0);
-    cells[2] = cpu_to_be32(8);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "fdc");
-
-    g_string_printf(name, "%s/timer@i40", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x40);
-    cells[2] = cpu_to_be32(8);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "timer");
-
-    g_string_printf(name, "%s/rtc@i70", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_string(fi->fdt, name->str, "compatible", "ds1385-rtc");
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(8);
-    cells[1] = 0;
-    qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
-                     cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x70);
-    cells[2] = cpu_to_be32(2);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "rtc");
-
-    g_string_printf(name, "%s/keyboard@i60", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    cells[0] = cpu_to_be32(1);
-    cells[1] = 0;
-    qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
-                     cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x60);
-    cells[2] = cpu_to_be32(5);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "keyboard");
-
-    g_string_printf(name, "%s/8042@i60", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "#interrupt-cells", 2);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "#size-cells", 0);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "#address-cells", 1);
-    qemu_fdt_setprop_string(fi->fdt, name->str, "interrupt-controller", "");
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x60);
-    cells[2] = cpu_to_be32(5);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "");
-
-    g_string_printf(name, "%s/serial@i2f8", fi->path);
-    qemu_fdt_add_subnode(fi->fdt, name->str);
-    qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0);
-    cells[0] = cpu_to_be32(3);
-    cells[1] = 0;
-    qemu_fdt_setprop(fi->fdt, name->str, "interrupts",
-                     cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(1);
-    cells[1] = cpu_to_be32(0x2f8);
-    cells[2] = cpu_to_be32(8);
-    qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "serial");
-
-    g_string_free(name, TRUE);
-}
-
 static struct {
     const char *id;
     const char *name;
     void (*dtf)(PCIBus *bus, PCIDevice *d, FDTInfo *fi);
 } device_map[] = {
     { "pci11ab,6460", "host", NULL },
-    { "pci1106,8231", "isa", dt_isa },
     { "pci1106,571", "ide", dt_ide },
     { "pci1106,3044", "firewire", NULL },
     { "pci1106,3038", "usb", dt_usb },
@@ -780,7 +675,10 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
                                      pci_get_word(&d->config[PCI_VENDOR_ID]),
                                      pci_get_word(&d->config[PCI_DEVICE_ID]));
 
-    if (pci_get_word(&d->config[PCI_CLASS_DEVICE])  ==
+    if (!strcmp(pn, "pci1106,8231")) {
+        return; /* ISA bridge and devices are included in dtb */
+    }
+    if (pci_get_word(&d->config[PCI_CLASS_DEVICE]) ==
         PCI_CLASS_NETWORK_ETHERNET) {
         name = "ethernet";
     } else if (pci_get_word(&d->config[PCI_CLASS_DEVICE]) >> 8 ==
@@ -858,131 +756,9 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
     g_string_free(node, TRUE);
 }
 
-static void *build_fdt(MachineState *machine, int *fdt_size)
+static void add_cpu_info(void *fdt, PowerPCCPU *cpu)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
-    PowerPCCPU *cpu = pm->cpu;
-    PCIBus *pci_bus;
-    FDTInfo fi;
-    uint32_t cells[16];
-    void *fdt = create_device_tree(fdt_size);
-
-    fi.fdt = fdt;
-
-    /* root node */
-    qemu_fdt_setprop_string(fdt, "/", "CODEGEN,description",
-                            "Pegasos CHRP PowerPC System");
-    qemu_fdt_setprop_string(fdt, "/", "CODEGEN,board", "Pegasos2");
-    qemu_fdt_setprop_string(fdt, "/", "CODEGEN,vendor", "bplan GmbH");
-    qemu_fdt_setprop_string(fdt, "/", "revision", "2B");
-    qemu_fdt_setprop_string(fdt, "/", "model", "Pegasos2");
-    qemu_fdt_setprop_string(fdt, "/", "device_type", "chrp");
-    qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 1);
-    qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2");
-
-    /* pci@c0000000 */
-    qemu_fdt_add_subnode(fdt, "/pci@c0000000");
-    cells[0] = 0;
-    cells[1] = 0;
-    qemu_fdt_setprop(fdt, "/pci@c0000000", "bus-range",
-                     cells, 2 * sizeof(cells[0]));
-    qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "pci-bridge-number", 1);
-    cells[0] = cpu_to_be32(PCI0_MEM_BASE);
-    cells[1] = cpu_to_be32(PCI0_MEM_SIZE);
-    qemu_fdt_setprop(fdt, "/pci@c0000000", "reg", cells, 2 * sizeof(cells[0]));
-    cells[0] = cpu_to_be32(0x01000000);
-    cells[1] = 0;
-    cells[2] = 0;
-    cells[3] = cpu_to_be32(PCI0_IO_BASE);
-    cells[4] = 0;
-    cells[5] = cpu_to_be32(PCI0_IO_SIZE);
-    cells[6] = cpu_to_be32(0x02000000);
-    cells[7] = 0;
-    cells[8] = cpu_to_be32(PCI0_MEM_BASE);
-    cells[9] = cpu_to_be32(PCI0_MEM_BASE);
-    cells[10] = 0;
-    cells[11] = cpu_to_be32(PCI0_MEM_SIZE);
-    qemu_fdt_setprop(fdt, "/pci@c0000000", "ranges",
-                     cells, 12 * sizeof(cells[0]));
-    qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#size-cells", 2);
-    qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#address-cells", 3);
-    qemu_fdt_setprop_string(fdt, "/pci@c0000000", "device_type", "pci");
-
-    fi.path = "/pci@c0000000";
-    pci_bus = mv64361_get_pci_bus(pm->mv, 0);
-    pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
-
-    /* pci@80000000 */
-    qemu_fdt_add_subnode(fdt, "/pci@80000000");
-    cells[0] = 0;
-    cells[1] = 0;
-    qemu_fdt_setprop(fdt, "/pci@80000000", "bus-range",
-                     cells, 2 * sizeof(cells[0]));
-    qemu_fdt_setprop_cell(fdt, "/pci@80000000", "pci-bridge-number", 0);
-    cells[0] = cpu_to_be32(PCI1_MEM_BASE);
-    cells[1] = cpu_to_be32(PCI1_MEM_SIZE);
-    qemu_fdt_setprop(fdt, "/pci@80000000", "reg", cells, 2 * sizeof(cells[0]));
-    qemu_fdt_setprop_cell(fdt, "/pci@80000000", "8259-interrupt-acknowledge",
-                          0xf1000cb4);
-    cells[0] = cpu_to_be32(0x01000000);
-    cells[1] = 0;
-    cells[2] = 0;
-    cells[3] = cpu_to_be32(PCI1_IO_BASE);
-    cells[4] = 0;
-    cells[5] = cpu_to_be32(PCI1_IO_SIZE);
-    cells[6] = cpu_to_be32(0x02000000);
-    cells[7] = 0;
-    cells[8] = cpu_to_be32(PCI1_MEM_BASE);
-    cells[9] = cpu_to_be32(PCI1_MEM_BASE);
-    cells[10] = 0;
-    cells[11] = cpu_to_be32(PCI1_MEM_SIZE);
-    qemu_fdt_setprop(fdt, "/pci@80000000", "ranges",
-                     cells, 12 * sizeof(cells[0]));
-    qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#size-cells", 2);
-    qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#address-cells", 3);
-    qemu_fdt_setprop_string(fdt, "/pci@80000000", "device_type", "pci");
-
-    fi.path = "/pci@80000000";
-    pci_bus = mv64361_get_pci_bus(pm->mv, 1);
-    pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
-
-    qemu_fdt_add_subnode(fdt, "/failsafe");
-    qemu_fdt_setprop_string(fdt, "/failsafe", "device_type", "serial");
-
-    qemu_fdt_add_subnode(fdt, "/rtas");
-    qemu_fdt_setprop_cell(fdt, "/rtas", "system-reboot", RTAS_SYSTEM_REBOOT);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "hibernate", RTAS_HIBERNATE);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "suspend", RTAS_SUSPEND);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "power-off", RTAS_POWER_OFF);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "set-indicator", RTAS_SET_INDICATOR);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "display-character",
-                          RTAS_DISPLAY_CHARACTER);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "write-pci-config",
-                          RTAS_WRITE_PCI_CONFIG);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "read-pci-config",
-                          RTAS_READ_PCI_CONFIG);
-    /* Pegasos2 firmware misspells check-exception and guests use that */
-    qemu_fdt_setprop_cell(fdt, "/rtas", "check-execption",
-                          RTAS_CHECK_EXCEPTION);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "event-scan", RTAS_EVENT_SCAN);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "set-time-of-day",
-                          RTAS_SET_TIME_OF_DAY);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "get-time-of-day",
-                          RTAS_GET_TIME_OF_DAY);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-store", RTAS_NVRAM_STORE);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-fetch", RTAS_NVRAM_FETCH);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "restart-rtas", RTAS_RESTART_RTAS);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-error-log-max", 0);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-event-scan-rate", 0);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-display-device", 0);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", 20);
-    qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-version", 1);
-
-    /* cpus */
-    qemu_fdt_add_subnode(fdt, "/cpus");
-    qemu_fdt_setprop_cell(fdt, "/cpus", "#cpus", 1);
-    qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1);
-    qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0);
+    uint32_t cells[2];
 
     /* FIXME Get CPU name from CPU object */
     const char *cp = "/cpus/PowerPC,G4";
@@ -1034,15 +810,44 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     cells[1] = 0;
     qemu_fdt_setprop(fdt, cp, "reg", cells, 2 * sizeof(cells[0]));
     qemu_fdt_setprop_string(fdt, cp, "device_type", "cpu");
+}
+
+static void *load_dtb(const char *filename, int *fdt_size)
+{
+    void *fdt;
+    char *name = qemu_find_file(QEMU_FILE_TYPE_DTB, filename);
+
+    if (!name) {
+        error_report("Could not find dtb file '%s'", filename);
+        return NULL;
+    }
+    fdt = load_device_tree(name, fdt_size);
+    if (!fdt) {
+        error_report("Could not load dtb file '%s'", name);
+    }
+    g_free(name);
+    return fdt;
+}
 
-    /* memory */
-    qemu_fdt_add_subnode(fdt, "/memory@0");
+static void *build_fdt(MachineState *machine, int *fdt_size)
+{
+    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
+    FDTInfo fi;
+    PCIBus *pci_bus;
+    uint32_t cells[2];
+    void *fdt = load_dtb("pegasos2.dtb", fdt_size);
+
+    if (!fdt) {
+        return NULL;
+    }
+    qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2");
+
+    /* Set memory size */
     cells[0] = 0;
     cells[1] = cpu_to_be32(machine->ram_size);
     qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0]));
-    qemu_fdt_setprop_string(fdt, "/memory@0", "device_type", "memory");
 
-    qemu_fdt_add_subnode(fdt, "/chosen");
+    /* Boot parameters */
     if (pm->initrd_addr && pm->initrd_size) {
         qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
                               pm->initrd_addr + pm->initrd_size);
@@ -1052,8 +857,15 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
                             machine->kernel_cmdline ?: "");
 
-    qemu_fdt_add_subnode(fdt, "/openprom");
-    qemu_fdt_setprop_string(fdt, "/openprom", "model", "Pegasos2,1.1");
+    add_cpu_info(fdt, pm->cpu);
+
+    fi.fdt = fdt;
+    fi.path = "/pci@c0000000";
+    pci_bus = mv64361_get_pci_bus(pm->mv, 0);
+    pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
+    fi.path = "/pci@80000000";
+    pci_bus = mv64361_get_pci_bus(pm->mv, 1);
+    pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
 
     return fdt;
 }
pc-bios/dtb/meson.build +1 -0
index 993032949f..f14648f3a4 100644
@@ -1,6 +1,7 @@
 dtbs = [
   'bamboo.dtb',
   'canyonlands.dtb',
+  'pegasos2.dtb',
   'petalogix-ml605.dtb',
   'petalogix-s3adsp1800.dtb',
 ]
pc-bios/dtb/pegasos2.dtb new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..29c35216ec2d77e4083a3ef618ca185925fb5d61
GIT binary patch
pc-bios/dtb/pegasos2.dts new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
2.41.3
Reviewed-by on v3 3/13
#4 lore raw

Re: [PATCH v3 03/13] hw/ppc/pegasos2: Change device tree generation

Quoted 20 lines · BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

---
  hw/ppc/pegasos2.c        | 292 +++++++--------------------------------
  pc-bios/dtb/meson.build  |   1 +
  pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
  pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++
  4 files changed, 220 insertions(+), 240 deletions(-)

create mode 100644 pc-bios/dtb/pegasos2.dtb
create mode 100644 pc-bios/dtb/pegasos2.dts

  #define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2")
  OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)

hw/ppc/pegasos2.c static void pegasos2_machine_reset(MachineState *machine, ResetType type) · line 409

Quoted 7 lines
hw/ppc/pegasos2.c +3 -0
@@ -411,7 +403,11 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
          error_report("Memory for initrd is in use");
          exit(1);
      }
+
      fdt = build_fdt(machine, &sz);
+    if (!fdt) {
+        exit(1);

To avoid confusing users, either report an error or abort.

hw/ppc/pegasos2.c static void *build_fdt(MachineState *machine, int *fdt_size) · line 818

Quoted 10 lines
hw/ppc/pegasos2.c +5 -0
+    }
      /* FIXME: VOF assumes entry is same as load address */
      d[0] = cpu_to_be64(pm->kernel_entry);
      d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr));
 
 
+static void *load_dtb(const char *filename, int *fdt_size)
+{
+    void *fdt;
+    char *name = qemu_find_file(QEMU_FILE_TYPE_DTB, filename);

g_autofree? Otherwise,

Quoted 12 lines
hw/ppc/pegasos2.c +12 -0
+
+    if (!name) {
+        error_report("Could not find dtb file '%s'", filename);
+        return NULL;
+    }
+    fdt = load_device_tree(name, fdt_size);
+    if (!fdt) {
+        error_report("Could not load dtb file '%s'", name);
+    }
+    g_free(name);
+    return fdt;
+}
#5 lore raw

Re: [PATCH v3 03/13] hw/ppc/pegasos2: Change device tree generation

Quoted 18 lines · Philippe Mathieu-Daudé
Quoted 15 lines · BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

---
  hw/ppc/pegasos2.c        | 292 +++++++--------------------------------
  pc-bios/dtb/meson.build  |   1 +
  pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
  pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++
  4 files changed, 220 insertions(+), 240 deletions(-)

create mode 100644 pc-bios/dtb/pegasos2.dtb
create mode 100644 pc-bios/dtb/pegasos2.dts

Quoted 13 lines

hw/ppc/pegasos2.c static void pegasos2_machine_reset(MachineState · line 410

Quoted 11 lines
  #define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2")
  OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)
hw/ppc/pegasos2.c +3 -0
@@ -411,7 +403,11 @@ static void pegasos2_machine_reset(MachineState 
 *machine, ResetType type)
          error_report("Memory for initrd is in use");
          exit(1);
      }
+
      fdt = build_fdt(machine, &sz);
+    if (!fdt) {
+        exit(1);

To avoid confusing users, either report an error or abort.

Errors are reported by build_fdt so no need to report again here.

Quoted 7 lines
Quoted 5 lines
hw/ppc/pegasos2.c +1 -0
+    }
      /* FIXME: VOF assumes entry is same as load address */
      d[0] = cpu_to_be64(pm->kernel_entry);
      d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - 

pm->kernel_addr));

Quoted 6 lines

hw/ppc/pegasos2.c static void *build_fdt(MachineState *machine, int *fdt_size) · line 818

Quoted 4 lines
hw/ppc/pegasos2.c +4 -0
+static void *load_dtb(const char *filename, int *fdt_size)
+{
+    void *fdt;
+    char *name = qemu_find_file(QEMU_FILE_TYPE_DTB, filename);

g_autofree? Otherwise,

This function is simple enough to not need autofree but maybe it would be better to ensure it's not forgotten. I may change that if need to respin for some other reason.

Regards,
BALATON Zoltan

Quoted 16 lines
Quoted 12 lines
hw/ppc/pegasos2.c +12 -0
+
+    if (!name) {
+        error_report("Could not find dtb file '%s'", filename);
+        return NULL;
+    }
+    fdt = load_device_tree(name, fdt_size);
+    if (!fdt) {
+        error_report("Could not load dtb file '%s'", name);
+    }
+    g_free(name);
+    return fdt;
+}
#6 lore raw

Re: [PATCH v3 03/13] hw/ppc/pegasos2: Change device tree generation

Quoted 33 lines · BALATON Zoltan
Quoted 18 lines · Philippe Mathieu-Daudé
Quoted 15 lines · BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

---
  hw/ppc/pegasos2.c        | 292 +++++++-------------------------------- pc-bios/dtb/meson.build  |   1 +
  pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++

  4 files changed, 220 insertions(+), 240 deletions(-)

  create mode 100644 pc-bios/dtb/pegasos2.dtb
  create mode 100644 pc-bios/dtb/pegasos2.dts

Quoted 13 lines

hw/ppc/pegasos2.c static void pegasos2_machine_reset(MachineState · line 410

Quoted 11 lines

  #define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2") OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)

hw/ppc/pegasos2.c +3 -0
@@ -411,7 +403,11 @@ static void pegasos2_machine_reset(MachineState 
 *machine, ResetType type)
           error_report("Memory for initrd is in use");
           exit(1);
       }
+
       fdt = build_fdt(machine, &sz);
+    if (!fdt) {
+        exit(1);

To avoid confusing users, either report an error or abort.

Quoted 1 line

Errors are reported by build_fdt so no need to report again here.

I'll defer to Markus for error style.

Quoted 36 lines
Quoted 8 lines
Quoted 6 lines
hw/ppc/pegasos2.c +1 -0
+    }
       /* FIXME: VOF assumes entry is same as load address */
       d[0] = cpu_to_be64(pm->kernel_entry);

      d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm-

Quoted 1 line

kernel_addr));

Quoted 6 lines

hw/ppc/pegasos2.c static void *build_fdt(MachineState *machine, int *fdt_size) · line 818

Quoted 4 lines
hw/ppc/pegasos2.c +4 -0
+static void *load_dtb(const char *filename, int *fdt_size)
+{
+    void *fdt;
+    char *name = qemu_find_file(QEMU_FILE_TYPE_DTB, filename);

g_autofree? Otherwise,

This function is simple enough to not need autofree but maybe it would be better to ensure it's not forgotten. I may change that if need to respin for some other reason.

Regards,
BALATON Zoltan

Quoted 16 lines
Quoted 12 lines
hw/ppc/pegasos2.c +12 -0
+
+    if (!name) {
+        error_report("Could not find dtb file '%s'", filename);
+        return NULL;
+    }
+    fdt = load_device_tree(name, fdt_size);
+    if (!fdt) {
+        error_report("Could not load dtb file '%s'", name);
+    }
+    g_free(name);
+    return fdt;
+}
#7 lore raw

Re: [PATCH v3 03/13] hw/ppc/pegasos2: Change device tree generation

In reply to BALATON Zoltan
Quoted 7 lines · BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

Quoted 8 lines
---
  hw/ppc/pegasos2.c        | 292 +++++++--------------------------------
  pc-bios/dtb/meson.build  |   1 +
  pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
  pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++
  4 files changed, 220 insertions(+), 240 deletions(-)

create mode 100644 pc-bios/dtb/pegasos2.dtb
create mode 100644 pc-bios/dtb/pegasos2.dts

Please update MAINTAINERS entries.

#8 lore raw

Re: [PATCH v3 03/13] hw/ppc/pegasos2: Change device tree generation

Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 7 lines · BALATON Zoltan

We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic.

Quoted 8 lines
---
  hw/ppc/pegasos2.c        | 292 +++++++--------------------------------
  pc-bios/dtb/meson.build  |   1 +
  pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
  pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++
  4 files changed, 220 insertions(+), 240 deletions(-)

create mode 100644 pc-bios/dtb/pegasos2.dtb
create mode 100644 pc-bios/dtb/pegasos2.dts

Quoted 1 line

Please update MAINTAINERS entries.

Covered in last patch that also adds pegasos1.dt[sb]. I could move that in this patch if you think that's better.

Regards,
BALATON Zoltan

#9 lore raw

PATCH v3 4/13 hw/ppc/pegasos2: Remove fdt pointer from machine state

In reply to BALATON Zoltan

The machine class has a field for storing the fdt so we don't need our own and can use that instead.

---
 hw/ppc/pegasos2.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
hw/ppc/pegasos2.c +2 -5
index 646755a3cc..7dc7803c64 100644
@@ -74,7 +74,6 @@ struct Pegasos2MachineState {
     qemu_irq mv_pirq[PCI_NUM_PINS];
     qemu_irq via_pirq[PCI_NUM_PINS];
     Vof *vof;
-    void *fdt_blob;
     uint64_t kernel_addr;
     uint64_t kernel_entry;
     uint64_t kernel_size;
@@ -413,13 +412,11 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
     d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr));
     qemu_fdt_setprop(fdt, "/chosen", "qemu,boot-kernel", d, sizeof(d));
 
-    g_free(pm->fdt_blob);
-    pm->fdt_blob = fdt;
-
     vof_build_dt(fdt, pm->vof);
     vof_client_open_store(fdt, pm->vof, "/chosen", "stdout", "/failsafe");
 
     /* Set machine->fdt for 'dumpdtb' QMP/HMP command */
+    g_free(machine->fdt);
     machine->fdt = fdt;
 
     pm->cpu->vhyp = PPC_VIRTUAL_HYPERVISOR(machine);
@@ -559,7 +556,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
     } else if (env->gpr[3] == KVMPPC_H_RTAS) {
         env->gpr[3] = pegasos2_rtas(cpu, pm, env->gpr[4]);
     } else if (env->gpr[3] == KVMPPC_H_VOF_CLIENT) {
-        int ret = vof_client_call(MACHINE(pm), pm->vof, pm->fdt_blob,
+        int ret = vof_client_call(MACHINE(pm), pm->vof, MACHINE(pm)->fdt,
                                   env->gpr[4]);
         env->gpr[3] = (ret ? H_PARAMETER : H_SUCCESS);
     } else {
Signature · 1 line
2.41.3
Reviewed-by on v3 4/13
#10 lore raw

Re: [PATCH v3 04/13] hw/ppc/pegasos2: Remove fdt pointer from machine state

Quoted 2 lines · BALATON Zoltan

The machine class has a field for storing the fdt so we don't need our own and can use that instead.

OK as of today, but I expect MachineState::fdt to be reworked (if not removed) as it doesn't scale with heterogeneous machines.

Quoted 5 lines
---
  hw/ppc/pegasos2.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
#11 lore raw

PATCH v3 5/13 hw/ppc/pegasos2: Rename mv field in machine state

In reply to BALATON Zoltan

Use more generic name for the field used to store the north bridge in the machine state.

---
 hw/ppc/pegasos2.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
hw/ppc/pegasos2.c +10 -10
index 7dc7803c64..9b50cd3dab 100644
@@ -68,7 +68,7 @@ struct Pegasos2MachineState {
     MachineState parent_obj;
 
     PowerPCCPU *cpu;
-    DeviceState *mv;
+    DeviceState *nb; /* north bridge */
     IRQState pci_irqs[PCI_NUM_PINS];
     OrIRQState orirq[PCI_NUM_PINS];
     qemu_irq mv_pirq[PCI_NUM_PINS];
@@ -166,12 +166,12 @@ static void pegasos2_init(MachineState *machine)
     }
 
     /* Marvell Discovery II system controller */
-    pm->mv = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
+    pm->nb = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
                           qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_INT)));
     for (i = 0; i < PCI_NUM_PINS; i++) {
-        pm->mv_pirq[i] = qdev_get_gpio_in_named(pm->mv, "gpp", 12 + i);
+        pm->mv_pirq[i] = qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i);
     }
-    pci_bus = mv64361_get_pci_bus(pm->mv, 1);
+    pci_bus = mv64361_get_pci_bus(pm->nb, 1);
 
     /* VIA VT8231 South Bridge (multifunction PCI device) */
     via = OBJECT(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA));
@@ -190,7 +190,7 @@ static void pegasos2_init(MachineState *machine)
                               object_resolve_path_component(via, "rtc"),
                               "date");
     qdev_connect_gpio_out_named(DEVICE(via), "intr", 0,
-                                qdev_get_gpio_in_named(pm->mv, "gpp", 31));
+                                qdev_get_gpio_in_named(pm->nb, "gpp", 31));
 
     dev = PCI_DEVICE(object_resolve_path_component(via, "ide"));
     pci_ide_create_devs(dev);
@@ -208,7 +208,7 @@ static void pegasos2_init(MachineState *machine)
         DeviceState *pd;
         g_autofree const char *pn = g_strdup_printf("pcihost%d", h);
 
-        pd = DEVICE(object_resolve_path_component(OBJECT(pm->mv), pn));
+        pd = DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn));
         assert(pd);
         for (i = 0; i < PCI_NUM_PINS; i++) {
             OrIRQState *ori = &pm->orirq[i];
@@ -267,7 +267,7 @@ static void pegasos2_init(MachineState *machine)
 static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm,
                                      uint32_t addr, uint32_t len)
 {
-    MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->mv), 0);
+    MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0);
     uint64_t val = 0xffffffffULL;
     memory_region_dispatch_read(r, addr, &val, size_memop(len) | MO_LE,
                                 MEMTXATTRS_UNSPECIFIED);
@@ -277,7 +277,7 @@ static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm,
 static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr,
                                   uint32_t len, uint32_t val)
 {
-    MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->mv), 0);
+    MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0);
     memory_region_dispatch_write(r, addr, val, size_memop(len) | MO_LE,
                                  MEMTXATTRS_UNSPECIFIED);
 }
@@ -858,10 +858,10 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
 
     fi.fdt = fdt;
     fi.path = "/pci@c0000000";
-    pci_bus = mv64361_get_pci_bus(pm->mv, 0);
+    pci_bus = mv64361_get_pci_bus(pm->nb, 0);
     pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
     fi.path = "/pci@80000000";
-    pci_bus = mv64361_get_pci_bus(pm->mv, 1);
+    pci_bus = mv64361_get_pci_bus(pm->nb, 1);
     pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi);
 
     return fdt;
Signature · 1 line
2.41.3
#12 lore raw

PATCH v3 6/13 hw/ppc/pegasos2: Add south bridge pointer in the machine state

In reply to BALATON Zoltan

Add field for the south bridge in machine state to have both north and south bridges in it.

---
 hw/ppc/pegasos2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ppc/pegasos2.c +3 -1
index 9b50cd3dab..66bceec5ef 100644
@@ -69,6 +69,7 @@ struct Pegasos2MachineState {
 
     PowerPCCPU *cpu;
     DeviceState *nb; /* north bridge */
+    DeviceState *sb; /* south bridge */
     IRQState pci_irqs[PCI_NUM_PINS];
     OrIRQState orirq[PCI_NUM_PINS];
     qemu_irq mv_pirq[PCI_NUM_PINS];
@@ -174,7 +175,8 @@ static void pegasos2_init(MachineState *machine)
     pci_bus = mv64361_get_pci_bus(pm->nb, 1);
 
     /* VIA VT8231 South Bridge (multifunction PCI device) */
-    via = OBJECT(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA));
+    pm->sb = DEVICE(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA));
+    via = OBJECT(pm->sb);
 
     /* Set properties on individual devices before realizing the south bridge */
     if (machine->audiodev) {
Signature · 1 line
2.41.3
#13 lore raw

PATCH v3 7/13 hw/ppc/pegasos2: Move PCI IRQ routing setup to a function

In reply to BALATON Zoltan

Collect steps of setting up PCI IRQ routing in one function.

---
 hw/ppc/pegasos2.c | 66 +++++++++++++++++++++++------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)
hw/ppc/pegasos2.c +33 -33
index 66bceec5ef..26a571f82e 100644
@@ -107,6 +107,38 @@ static void pegasos2_pci_irq(void *opaque, int n, int level)
     qemu_set_irq(pm->via_pirq[n], level);
 }
 
+/* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */
+static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm)
+{
+    for (int h = 0; h < 2; h++) {
+        DeviceState *pd;
+        g_autofree const char *pn = g_strdup_printf("pcihost%d", h);
+
+        pd = DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn));
+        assert(pd);
+        for (int i = 0; i < PCI_NUM_PINS; i++) {
+            OrIRQState *ori = &pm->orirq[i];
+
+            if (h == 0) {
+                g_autofree const char *n = g_strdup_printf("pci-orirq[%d]", i);
+
+                object_initialize_child_with_props(OBJECT(pm), n,
+                                                   ori, sizeof(*ori),
+                                                   TYPE_OR_IRQ, &error_fatal,
+                                                   "num-lines", "2", NULL);
+                qdev_realize(DEVICE(ori), NULL, &error_fatal);
+                qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i);
+                qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]);
+                pm->mv_pirq[i] = qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i);
+                pm->via_pirq[i] = qdev_get_gpio_in_named(pm->sb, "pirq", i);
+            }
+            qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h));
+        }
+    }
+    qdev_connect_gpio_out_named(pm->sb, "intr", 0,
+                                qdev_get_gpio_in_named(pm->nb, "gpp", 31));
+}
+
 static void pegasos2_init(MachineState *machine)
 {
     Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
@@ -118,7 +150,6 @@ static void pegasos2_init(MachineState *machine)
     I2CBus *i2c_bus;
     const char *fwname = machine->firmware ?: PROM_FILENAME;
     char *filename;
-    int i;
     ssize_t sz;
     uint8_t *spd_data;
 
@@ -169,9 +200,6 @@ static void pegasos2_init(MachineState *machine)
     /* Marvell Discovery II system controller */
     pm->nb = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
                           qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_INT)));
-    for (i = 0; i < PCI_NUM_PINS; i++) {
-        pm->mv_pirq[i] = qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i);
-    }
     pci_bus = mv64361_get_pci_bus(pm->nb, 1);
 
     /* VIA VT8231 South Bridge (multifunction PCI device) */
@@ -185,14 +213,9 @@ static void pegasos2_init(MachineState *machine)
     }
 
     pci_realize_and_unref(PCI_DEVICE(via), pci_bus, &error_abort);
-    for (i = 0; i < PCI_NUM_PINS; i++) {
-        pm->via_pirq[i] = qdev_get_gpio_in_named(DEVICE(via), "pirq", i);
-    }
     object_property_add_alias(OBJECT(machine), "rtc-time",
                               object_resolve_path_component(via, "rtc"),
                               "date");
-    qdev_connect_gpio_out_named(DEVICE(via), "intr", 0,
-                                qdev_get_gpio_in_named(pm->nb, "gpp", 31));
 
     dev = PCI_DEVICE(object_resolve_path_component(via, "ide"));
     pci_ide_create_devs(dev);
@@ -205,30 +228,7 @@ static void pegasos2_init(MachineState *machine)
     /* other PC hardware */
     pci_vga_init(pci_bus);
 
-    /* PCI interrupt routing: lines from pci.0 and pci.1 are ORed */
-    for (int h = 0; h < 2; h++) {
-        DeviceState *pd;
-        g_autofree const char *pn = g_strdup_printf("pcihost%d", h);
-
-        pd = DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn));
-        assert(pd);
-        for (i = 0; i < PCI_NUM_PINS; i++) {
-            OrIRQState *ori = &pm->orirq[i];
-
-            if (h == 0) {
-                g_autofree const char *n = g_strdup_printf("pci-orirq[%d]", i);
-
-                object_initialize_child_with_props(OBJECT(pm), n,
-                                                   ori, sizeof(*ori),
-                                                   TYPE_OR_IRQ, &error_fatal,
-                                                   "num-lines", "2", NULL);
-                qdev_realize(DEVICE(ori), NULL, &error_fatal);
-                qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i);
-                qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]);
-            }
-            qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h));
-        }
-    }
+    pegasos2_setup_pci_irq(pm);
 
     if (machine->kernel_filename) {
         sz = load_elf(machine->kernel_filename, NULL, NULL, NULL,
Signature · 1 line
2.41.3
#14 lore raw

PATCH v3 8/13 hw/ppc/pegasos2: Move hardware specific parts out of machine reset

In reply to BALATON Zoltan

Move the chipset reset which is pegasos2 specific out from machine reset to a separate function and move parts not specific to pegasos2 from build_fdt to machine reset so now build_fdt contains pegasos2 specific parts and can be renamed accordingly.

---
 hw/ppc/pegasos2.c | 79 ++++++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 38 deletions(-)
hw/ppc/pegasos2.c +41 -38
index 26a571f82e..e3c1ee9347 100644
@@ -57,10 +57,6 @@
 
 #define BUS_FREQ_HZ 133333333
 
-#define PCI0_CFG_ADDR 0xcf8
-#define PCI1_CFG_ADDR 0xc78
-#define PCI1_IO_BASE  0xfe000000
-
 #define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2")
 OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)
 
@@ -82,7 +78,7 @@ struct Pegasos2MachineState {
     uint64_t initrd_size;
 };
 
-static void *build_fdt(MachineState *machine, int *fdt_size);
+static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size);
 
 static void pegasos2_cpu_reset(void *opaque)
 {
@@ -284,6 +280,9 @@ static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr,
                                  MEMTXATTRS_UNSPECIFIED);
 }
 
+#define PCI0_CFG_ADDR 0xcf8
+#define PCI1_CFG_ADDR 0xc78
+
 static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus,
                                          uint32_t addr, uint32_t len)
 {
@@ -308,23 +307,12 @@ static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus,
 
 static void pegasos2_superio_write(uint8_t addr, uint8_t val)
 {
-    cpu_physical_memory_write(PCI1_IO_BASE + 0x3f0, &addr, 1);
-    cpu_physical_memory_write(PCI1_IO_BASE + 0x3f1, &val, 1);
+    cpu_physical_memory_write(0xfe0003f0, &addr, 1);
+    cpu_physical_memory_write(0xfe0003f1, &val, 1);
 }
 
-static void pegasos2_machine_reset(MachineState *machine, ResetType type)
+static void pegasos2_chipset_reset(Pegasos2MachineState *pm)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
-    void *fdt;
-    uint64_t d[2];
-    int sz;
-
-    qemu_devices_reset(type);
-    if (!pm->vof) {
-        return; /* Firmware should set up machine so nothing to do */
-    }
-
-    /* Otherwise, set up devices that board firmware would normally do */
     pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff);
     pegasos2_mv_reg_write(pm, 0x278, 4, 0xa31fc);
     pegasos2_mv_reg_write(pm, 0xf300, 4, 0x11ff0400);
@@ -387,6 +375,23 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
 
     pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 6) << 8) |
                               PCI_INTERRUPT_LINE, 2, 0x309);
+}
+
+static void pegasos2_machine_reset(MachineState *machine, ResetType type)
+{
+    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
+    void *fdt;
+    uint32_t c[2];
+    uint64_t d[2];
+    int sz;
+
+    qemu_devices_reset(type);
+    if (!pm->vof) {
+        return; /* Firmware should set up machine so nothing to do */
+    }
+
+    /* Otherwise, set up devices that board firmware would normally do */
+    pegasos2_chipset_reset(pm);
 
     /* Device tree and VOF set up */
     vof_init(pm->vof, machine->ram_size, &error_fatal);
@@ -405,10 +410,25 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
         exit(1);
     }
 
-    fdt = build_fdt(machine, &sz);
+    fdt = pegasos2_build_fdt(pm, &sz);
     if (!fdt) {
         exit(1);
     }
+
+    /* Set memory size */
+    c[0] = 0;
+    c[1] = cpu_to_be32(machine->ram_size);
+    qemu_fdt_setprop(fdt, "/memory@0", "reg", c, sizeof(c));
+
+    /* Boot parameters */
+    if (pm->initrd_addr && pm->initrd_size) {
+        qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
+                              pm->initrd_addr + pm->initrd_size);
+        qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
+                              pm->initrd_addr);
+    }
+    qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
+                            machine->kernel_cmdline ?: "");
     /* FIXME: VOF assumes entry is same as load address */
     d[0] = cpu_to_be64(pm->kernel_entry);
     d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr));
@@ -828,12 +848,10 @@ static void *load_dtb(const char *filename, int *fdt_size)
     return fdt;
 }
 
-static void *build_fdt(MachineState *machine, int *fdt_size)
+static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
     FDTInfo fi;
     PCIBus *pci_bus;
-    uint32_t cells[2];
     void *fdt = load_dtb("pegasos2.dtb", fdt_size);
 
     if (!fdt) {
@@ -841,21 +859,6 @@ static void *build_fdt(MachineState *machine, int *fdt_size)
     }
     qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2");
 
-    /* Set memory size */
-    cells[0] = 0;
-    cells[1] = cpu_to_be32(machine->ram_size);
-    qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0]));
-
-    /* Boot parameters */
-    if (pm->initrd_addr && pm->initrd_size) {
-        qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end",
-                              pm->initrd_addr + pm->initrd_size);
-        qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start",
-                              pm->initrd_addr);
-    }
-    qemu_fdt_setprop_string(fdt, "/chosen", "bootargs",
-                            machine->kernel_cmdline ?: "");
-
     add_cpu_info(fdt, pm->cpu);
 
     fi.fdt = fdt;
Signature · 1 line
2.41.3
#15 lore raw

PATCH v3 9/13 hw/ppc/pegasos2: Introduce abstract superclass

In reply to BALATON Zoltan

Rename machine state struct to PegasosMachineState as it will be used for pegasos1 too.

---
 hw/ppc/pegasos2.c | 66 ++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 32 deletions(-)
hw/ppc/pegasos2.c +34 -32
index e3c1ee9347..f7999520e4 100644
@@ -57,10 +57,10 @@
 
 #define BUS_FREQ_HZ 133333333
 
-#define TYPE_PEGASOS2_MACHINE  MACHINE_TYPE_NAME("pegasos2")
-OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE)
+#define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos")
+OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE)
 
-struct Pegasos2MachineState {
+struct PegasosMachineState {
     MachineState parent_obj;
 
     PowerPCCPU *cpu;
@@ -78,12 +78,12 @@ struct Pegasos2MachineState {
     uint64_t initrd_size;
 };
 
-static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size);
+static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size);
 
 static void pegasos2_cpu_reset(void *opaque)
 {
     PowerPCCPU *cpu = opaque;
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(current_machine);
+    PegasosMachineState *pm = PEGASOS_MACHINE(current_machine);
 
     cpu_reset(CPU(cpu));
     cpu->env.spr[SPR_HID1] = 7ULL << 28;
@@ -96,7 +96,7 @@ static void pegasos2_cpu_reset(void *opaque)
 
 static void pegasos2_pci_irq(void *opaque, int n, int level)
 {
-    Pegasos2MachineState *pm = opaque;
+    PegasosMachineState *pm = opaque;
 
     /* PCI interrupt lines are connected to both MV64361 and VT8231 */
     qemu_set_irq(pm->mv_pirq[n], level);
@@ -104,7 +104,7 @@ static void pegasos2_pci_irq(void *opaque, int n, int level)
 }
 
 /* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */
-static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm)
+static void pegasos2_setup_pci_irq(PegasosMachineState *pm)
 {
     for (int h = 0; h < 2; h++) {
         DeviceState *pd;
@@ -137,7 +137,7 @@ static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm)
 
 static void pegasos2_init(MachineState *machine)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
+    PegasosMachineState *pm = PEGASOS_MACHINE(machine);
     CPUPPCState *env;
     MemoryRegion *rom = g_new(MemoryRegion, 1);
     PCIBus *pci_bus;
@@ -262,7 +262,7 @@ static void pegasos2_init(MachineState *machine)
     }
 }
 
-static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm,
+static uint32_t pegasos2_mv_reg_read(PegasosMachineState *pm,
                                      uint32_t addr, uint32_t len)
 {
     MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0);
@@ -272,7 +272,7 @@ static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm,
     return val;
 }
 
-static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr,
+static void pegasos2_mv_reg_write(PegasosMachineState *pm, uint32_t addr,
                                   uint32_t len, uint32_t val)
 {
     MemoryRegion *r = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0);
@@ -283,7 +283,7 @@ static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr,
 #define PCI0_CFG_ADDR 0xcf8
 #define PCI1_CFG_ADDR 0xc78
 
-static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus,
+static uint32_t pegasos2_pci_config_read(PegasosMachineState *pm, int bus,
                                          uint32_t addr, uint32_t len)
 {
     hwaddr pcicfg = bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR;
@@ -296,7 +296,7 @@ static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus,
     return val;
 }
 
-static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus,
+static void pegasos2_pci_config_write(PegasosMachineState *pm, int bus,
                                       uint32_t addr, uint32_t len, uint32_t val)
 {
     hwaddr pcicfg = bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR;
@@ -311,7 +311,7 @@ static void pegasos2_superio_write(uint8_t addr, uint8_t val)
     cpu_physical_memory_write(0xfe0003f1, &val, 1);
 }
 
-static void pegasos2_chipset_reset(Pegasos2MachineState *pm)
+static void pegasos2_chipset_reset(PegasosMachineState *pm)
 {
     pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff);
     pegasos2_mv_reg_write(pm, 0x278, 4, 0xa31fc);
@@ -379,7 +379,7 @@ static void pegasos2_chipset_reset(Pegasos2MachineState *pm)
 
 static void pegasos2_machine_reset(MachineState *machine, ResetType type)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine);
+    PegasosMachineState *pm = PEGASOS_MACHINE(machine);
     void *fdt;
     uint32_t c[2];
     uint64_t d[2];
@@ -463,7 +463,7 @@ enum pegasos2_rtas_tokens {
     RTAS_SYSTEM_REBOOT = 20,
 };
 
-static target_ulong pegasos2_rtas(PowerPCCPU *cpu, Pegasos2MachineState *pm,
+static target_ulong pegasos2_rtas(PowerPCCPU *cpu, PegasosMachineState *pm,
                                   target_ulong args_real)
 {
     AddressSpace *as = CPU(cpu)->as;
@@ -566,7 +566,7 @@ static bool pegasos2_cpu_in_nested(PowerPCCPU *cpu)
 
 static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
 {
-    Pegasos2MachineState *pm = PEGASOS2_MACHINE(vhyp);
+    PegasosMachineState *pm = PEGASOS_MACHINE(vhyp);
     CPUPPCState *env = &cpu->env;
 
     /* The TCG path should also be holding the BQL at this point */
@@ -629,24 +629,26 @@ static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
     vmc->setprop = pegasos2_setprop;
 }
 
-static const TypeInfo pegasos2_machine_info = {
-    .name          = TYPE_PEGASOS2_MACHINE,
-    .parent        = TYPE_MACHINE,
-    .class_init    = pegasos2_machine_class_init,
-    .instance_size = sizeof(Pegasos2MachineState),
-    .interfaces = (const InterfaceInfo[]) {
-        { TYPE_PPC_VIRTUAL_HYPERVISOR },
-        { TYPE_VOF_MACHINE_IF },
-        { }
+static const TypeInfo pegasos_machine_types[] = {
+    {
+        .name          = TYPE_PEGASOS_MACHINE,
+        .parent        = TYPE_MACHINE,
+        .instance_size = sizeof(PegasosMachineState),
+        .abstract      = true,
+    },
+    {
+        .name          = MACHINE_TYPE_NAME("pegasos2"),
+        .parent        = TYPE_PEGASOS_MACHINE,
+        .class_init    = pegasos2_machine_class_init,
+        .interfaces = (const InterfaceInfo[]) {
+              { TYPE_PPC_VIRTUAL_HYPERVISOR },
+              { TYPE_VOF_MACHINE_IF },
+              { }
+        },
     },
 };
 
-static void pegasos2_machine_register_types(void)
-{
-    type_register_static(&pegasos2_machine_info);
-}
-
-type_init(pegasos2_machine_register_types)
+DEFINE_TYPES(pegasos_machine_types)
 
 /* FDT creation for passing to firmware */
 
@@ -848,7 +850,7 @@ static void *load_dtb(const char *filename, int *fdt_size)
     return fdt;
 }
 
-static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size)
+static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size)
 {
     FDTInfo fi;
     PCIBus *pci_bus;
Signature · 1 line
2.41.3
#17 lore raw

PATCH v3 10/13 hw/ppc/pegasos2: Add bus frequency to machine state

In reply to BALATON Zoltan

Store the bus frequency in the machine state and set it from instance init method.

---
 hw/ppc/pegasos2.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
hw/ppc/pegasos2.c +16 -9
index f7999520e4..ae3f01231d 100644
@@ -55,8 +55,6 @@
 #define H_PRIVILEGE  -3  /* Caller not privileged */
 #define H_PARAMETER  -4  /* Parameter invalid, out-of-range or conflicting */
 
-#define BUS_FREQ_HZ 133333333
-
 #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos")
 OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE)
 
@@ -66,6 +64,7 @@ struct PegasosMachineState {
     PowerPCCPU *cpu;
     DeviceState *nb; /* north bridge */
     DeviceState *sb; /* south bridge */
+    int bus_freq_hz;
     IRQState pci_irqs[PCI_NUM_PINS];
     OrIRQState orirq[PCI_NUM_PINS];
     qemu_irq mv_pirq[PCI_NUM_PINS];
@@ -135,7 +134,7 @@ static void pegasos2_setup_pci_irq(PegasosMachineState *pm)
                                 qdev_get_gpio_in_named(pm->nb, "gpp", 31));
 }
 
-static void pegasos2_init(MachineState *machine)
+static void pegasos_init(MachineState *machine)
 {
     PegasosMachineState *pm = PEGASOS_MACHINE(machine);
     CPUPPCState *env;
@@ -158,7 +157,7 @@ static void pegasos2_init(MachineState *machine)
     }
 
     /* Set time-base frequency */
-    cpu_ppc_tb_init(env, BUS_FREQ_HZ / 4);
+    cpu_ppc_tb_init(env, pm->bus_freq_hz / 4);
     qemu_register_reset(pegasos2_cpu_reset, pm->cpu);
 
     /* RAM */
@@ -603,6 +602,13 @@ static bool pegasos2_setprop(MachineState *ms, const char *path,
     return true;
 }
 
+static void pegasos2_init(Object *obj)
+{
+    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
+
+    pm->bus_freq_hz = 133333333;
+}
+
 static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -610,7 +616,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
     VofMachineIfClass *vmc = VOF_MACHINE_CLASS(oc);
 
     mc->desc = "Genesi/bPlan Pegasos II";
-    mc->init = pegasos2_init;
+    mc->init = pegasos_init;
     mc->reset = pegasos2_machine_reset;
     mc->block_default_type = IF_IDE;
     mc->default_boot_order = "cd";
@@ -640,6 +646,7 @@ static const TypeInfo pegasos_machine_types[] = {
         .name          = MACHINE_TYPE_NAME("pegasos2"),
         .parent        = TYPE_PEGASOS_MACHINE,
         .class_init    = pegasos2_machine_class_init,
+        .instance_init = pegasos2_init,
         .interfaces = (const InterfaceInfo[]) {
               { TYPE_PPC_VIRTUAL_HYPERVISOR },
               { TYPE_VOF_MACHINE_IF },
@@ -777,7 +784,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, void *opaque)
     g_string_free(node, TRUE);
 }
 
-static void add_cpu_info(void *fdt, PowerPCCPU *cpu)
+static void add_cpu_info(void *fdt, PowerPCCPU *cpu, int bus_freq)
 {
     uint32_t cells[2];
 
@@ -824,8 +831,8 @@ static void add_cpu_info(void *fdt, PowerPCCPU *cpu)
     qemu_fdt_setprop_cell(fdt, cp, "reservation-granule-size", 4);
     qemu_fdt_setprop_cell(fdt, cp, "timebase-frequency",
                           cpu->env.tb_env->tb_freq);
-    qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", BUS_FREQ_HZ);
-    qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", BUS_FREQ_HZ * 7.5);
+    qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", bus_freq);
+    qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", bus_freq * 7.5);
     qemu_fdt_setprop_cell(fdt, cp, "cpu-version", cpu->env.spr[SPR_PVR]);
     cells[0] = 0;
     cells[1] = 0;
@@ -861,7 +868,7 @@ static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size)
     }
     qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2");
 
-    add_cpu_info(fdt, pm->cpu);
+    add_cpu_info(fdt, pm->cpu, pm->bus_freq_hz);
 
     fi.fdt = fdt;
     fi.path = "/pci@c0000000";
Signature · 1 line
2.41.3
#18 lore raw

Re: [PATCH v3 10/13] hw/ppc/pegasos2: Add bus frequency to machine state

Quoted 22 lines · BALATON Zoltan

Store the bus frequency in the machine state and set it from instance init method.

---
  hw/ppc/pegasos2.c | 25 ++++++++++++++++---------
  1 file changed, 16 insertions(+), 9 deletions(-)
hw/ppc/pegasos2.c +0 -2
index f7999520e4..ae3f01231d 100644
@@ -55,8 +55,6 @@
  #define H_PRIVILEGE  -3  /* Caller not privileged */
  #define H_PARAMETER  -4  /* Parameter invalid, out-of-range or conflicting */
 
-#define BUS_FREQ_HZ 133333333
-
  #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos")
  OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE)
 

hw/ppc/pegasos2.c struct PegasosMachineState { · line 67

Quoted 4 lines
hw/ppc/pegasos2.c +1 -0
@@ -66,6 +64,7 @@ struct PegasosMachineState {
      PowerPCCPU *cpu;
      DeviceState *nb; /* north bridge */
      DeviceState *sb; /* south bridge */
+    int bus_freq_hz;

IMHO this field belongs to PegasosMachineClass, being read-only.

Quoted 25 lines
hw/ppc/pegasos2.c +8 -1
      IRQState pci_irqs[PCI_NUM_PINS];
      OrIRQState orirq[PCI_NUM_PINS];
      qemu_irq mv_pirq[PCI_NUM_PINS];
 
 
+static void pegasos2_init(Object *obj)
+{
+    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
+
+    pm->bus_freq_hz = 133333333;
+}
+
  static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
  {
      MachineClass *mc = MACHINE_CLASS(oc);
@@ -610,7 +616,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
      VofMachineIfClass *vmc = VOF_MACHINE_CLASS(oc);
 
      mc->desc = "Genesi/bPlan Pegasos II";
-    mc->init = pegasos2_init;
+    mc->init = pegasos_init;
      mc->reset = pegasos2_machine_reset;
      mc->block_default_type = IF_IDE;
      mc->default_boot_order = "cd";

hw/ppc/pegasos2.c static const TypeInfo pegasos_machine_types[] = { · line 652

Quoted 7 lines
hw/ppc/pegasos2.c +1 -0
@@ -640,6 +646,7 @@ static const TypeInfo pegasos_machine_types[] = {
          .name          = MACHINE_TYPE_NAME("pegasos2"),
          .parent        = TYPE_PEGASOS_MACHINE,
          .class_init    = pegasos2_machine_class_init,
+        .instance_init = pegasos2_init,
          .interfaces = (const InterfaceInfo[]) {
                { TYPE_PPC_VIRTUAL_HYPERVISOR },
                { TYPE_VOF_MACHINE_IF },

If you want pegasos2_init(), move the definition here to avoid churn in patch #12.

#19 lore raw

Re: [PATCH v3 10/13] hw/ppc/pegasos2: Add bus frequency to machine state

Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 19 lines · BALATON Zoltan

Store the bus frequency in the machine state and set it from instance init method.

---
  hw/ppc/pegasos2.c | 25 ++++++++++++++++---------
  1 file changed, 16 insertions(+), 9 deletions(-)
hw/ppc/pegasos2.c +0 -0
index f7999520e4..ae3f01231d 100644
@@ -55,8 +55,6 @@
  #define H_PRIVILEGE  -3  /* Caller not privileged */
  #define H_PARAMETER  -4  /* Parameter invalid, out-of-range or 

conflicting */
-#define BUS_FREQ_HZ 133333333
-
#define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos")

Quoted 8 lines
Quoted 6 lines

OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) @@ -66,6 +64,7 @@ struct PegasosMachineState {
PowerPCCPU *cpu;
DeviceState *nb; /* north bridge */
DeviceState *sb; /* south bridge */
+ int bus_freq_hz;

IMHO this field belongs to PegasosMachineClass, being read-only.

Reasons for not putting there:

1. I need it in machine init and build_fdt which get the machine state not machine class so would need to copy to machine state even if it was defined in the class.

2. We don't have a PegasosMachineState and it does not seem necessary to add one just for this single value which would then be never used other than copying it to the PegasosMachineState in init.

So for simplicity I've stored it the existing state along other values which seems to be simple enough. I don't see putting it in the class would be simpler.

Quoted 28 lines
Quoted 28 lines
      IRQState pci_irqs[PCI_NUM_PINS];
      OrIRQState orirq[PCI_NUM_PINS];
      qemu_irq mv_pirq[PCI_NUM_PINS];
hw/ppc/pegasos2.c +7 -0
+static void pegasos2_init(Object *obj)
+{
+    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
+
+    pm->bus_freq_hz = 133333333;
+}
+
  static void pegasos2_machine_class_init(ObjectClass *oc, const void 

*data)

  {
      MachineClass *mc = MACHINE_CLASS(oc);
hw/ppc/pegasos2.c +1 -1
@@ -610,7 +616,7 @@ static void pegasos2_machine_class_init(ObjectClass 
 *oc, const void *data)
      VofMachineIfClass *vmc = VOF_MACHINE_CLASS(oc);
        mc->desc = "Genesi/bPlan Pegasos II";
-    mc->init = pegasos2_init;
+    mc->init = pegasos_init;
      mc->reset = pegasos2_machine_reset;
      mc->block_default_type = IF_IDE;
      mc->default_boot_order = "cd";
@@ -640,6 +646,7 @@ static const TypeInfo pegasos_machine_types[] = {
          .name          = MACHINE_TYPE_NAME("pegasos2"),
          .parent        = TYPE_PEGASOS_MACHINE,
Quoted 8 lines

hw/ppc/pegasos2.c static const TypeInfo pegasos_machine_types[] = { · line 652

Quoted 5 lines
hw/ppc/pegasos2.c +1 -0
          .class_init    = pegasos2_machine_class_init,
+        .instance_init = pegasos2_init,
          .interfaces = (const InterfaceInfo[]) {
                { TYPE_PPC_VIRTUAL_HYPERVISOR },
                { TYPE_VOF_MACHINE_IF },

If you want pegasos2_init(), move the definition here to avoid churn in patch #12.

I don't understand what causes the churn as the function is the same, patch 12 only adds one line to it but maybe renaming surrounding functions confused git to generate patch that moves this function and not ammends it. What can I move here to avoid that?

Regards,
BALATON Zoltan

#20 lore raw

PATCH v3 11/13 hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

In reply to BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
 include/hw/boards.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +14 -2
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
         } \
     } while (0)
 
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
     static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
     { \
         MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
     } \
     static const TypeInfo machine_initfn##_typeinfo = { \
         .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
+        .parent     = TYPE_##PARENT_NAME, \
         .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \
     }; \
     static void machine_initfn##_register_types(void) \
     { \
@@ -779,6 +783,14 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+                            false, __VA_ARGS__)
+
 extern GlobalProperty hw_compat_10_1[];
 extern const size_t hw_compat_10_1_len;
 
Signature · 1 line
2.41.3
#21 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

Quoted 25 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--
  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -1
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
          } \
      } while (0)
 
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
      static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
      { \
          MachineClass *mc = MACHINE_CLASS(oc); \

include/hw/boards.h struct MachineState { · line 778

Quoted 9 lines
include/hw/boards.h +4 -1
@@ -770,8 +771,11 @@ struct MachineState {
      } \
      static const TypeInfo machine_initfn##_typeinfo = { \
          .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
+        .parent     = TYPE_##PARENT_NAME, \
          .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Quoted 18 lines
include/hw/boards.h +8 -0
      }; \
      static void machine_initfn##_register_types(void) \
      { \
@@ -779,6 +783,14 @@ struct MachineState {
      } \
      type_init(machine_initfn##_register_types)
 
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, machine_initfn, \
+                            false, __VA_ARGS__)
+
  extern GlobalProperty hw_compat_10_1[];
  extern const size_t hw_compat_10_1_len;
 
#22 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

+Pierrick

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--

  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -1
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
           } \
       } while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
       { \
           MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
Quoted 8 lines

include/hw/boards.h struct MachineState { · line 777

Quoted 8 lines
include/hw/boards.h +3 -1
       } \
       static const TypeInfo machine_initfn##_typeinfo = { \
           .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
+        .parent     = TYPE_##PARENT_NAME, \
           .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \

IIUC we don't want to have abstract type with interfaces, but only QOM leaves. So maybe better always use .abstract = false in DEFINE_MACHINE_EXTENDED()?

Quoted 22 lines

include/hw/boards.h struct MachineState { · line 778

Quoted 1 line
include/hw/boards.h +1 -0
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Quoted 18 lines
include/hw/boards.h +8 -0
       }; \
       static void machine_initfn##_register_types(void) \
       { \
@@ -779,6 +783,14 @@ struct MachineState {
       } \
       type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, __VA_ARGS__)
+
   extern GlobalProperty hw_compat_10_1[];
   extern const size_t hw_compat_10_1_len;
#23 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

Quoted 45 lines · Philippe Mathieu-Daudé

+Pierrick

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--

  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -1
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
           } \
       } while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
       { \
           MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
Quoted 8 lines

include/hw/boards.h struct MachineState { · line 777

Quoted 8 lines
include/hw/boards.h +3 -1
       } \
       static const TypeInfo machine_initfn##_typeinfo = { \
           .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
+        .parent     = TYPE_##PARENT_NAME, \
           .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \

IIUC we don't want to have abstract type with interfaces, but only QOM leaves. So maybe better always use .abstract = false in DEFINE_MACHINE_EXTENDED()?

Quoted 4 lines

include/hw/boards.h struct MachineState { · line 778

Quoted 1 line
include/hw/boards.h +1 -0
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
include/hw/boards.h +1 -0
       }; \
       static void machine_initfn##_register_types(void) \
       { \
@@ -779,6 +783,14 @@ struct MachineState {
       } \
       type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
Quoted 8 lines

include/hw/boards.h struct MachineState { · line 792

Quoted 8 lines
include/hw/boards.h +6 -0
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, __VA_ARGS__)

Hmm how can be sure the __VA_ARGS__ argument is { NULL } terminated?

Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
include/hw/boards.h +1 -0
+
   extern GlobalProperty hw_compat_10_1[];
   extern const size_t hw_compat_10_1_len;
#24 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

Quoted 55 lines · Philippe Mathieu-Daudé
Quoted 54 lines · Philippe Mathieu-Daudé

+Pierrick

Quoted 25 lines · Philippe Mathieu-Daudé
Quoted 24 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--

  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -1
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
           } \
       } while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
       { \
           MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
Quoted 8 lines

include/hw/boards.h struct MachineState { · line 777

Quoted 8 lines
include/hw/boards.h +3 -1
       } \
       static const TypeInfo machine_initfn##_typeinfo = { \
           .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
+        .parent     = TYPE_##PARENT_NAME, \
           .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \

IIUC we don't want to have abstract type with interfaces, but only QOM leaves. So maybe better always use .abstract = false in DEFINE_MACHINE_EXTENDED()?

Quoted 13 lines

include/hw/boards.h struct MachineState { · line 778

Quoted 1 line
include/hw/boards.h +1 -0
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Quoted 9 lines
include/hw/boards.h +2 -0
       }; \
       static void machine_initfn##_register_types(void) \
       { \
@@ -779,6 +783,14 @@ struct MachineState {
       } \
       type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

include/hw/boards.h struct MachineState { · line 792

Quoted 6 lines
include/hw/boards.h +5 -0
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, __VA_ARGS__)

Hmm how can be sure the __VA_ARGS__ argument is { NULL } terminated?

The same way as for OBJECT_DEFINE_TYPE_EXTENDED. This is modelled after that as noted in the commit message.

Regards,
BALATON Zoltan

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
include/hw/boards.h +1 -0
+
   extern GlobalProperty hw_compat_10_1[];
   extern const size_t hw_compat_10_1_len;
#25 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

In reply to Philippe Mathieu-Daudé
Quoted 32 lines · Philippe Mathieu-Daudé

+Pierrick

Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--

  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -2
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
           } \
       } while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
       { \
           MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
       } \
       static const TypeInfo machine_initfn##_typeinfo = { \
           .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
Quoted 8 lines
Quoted 4 lines

include/hw/boards.h struct MachineState { · line 777

Quoted 4 lines
include/hw/boards.h +3 -0
+        .parent     = TYPE_##PARENT_NAME, \
           .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \

IIUC we don't want to have abstract type with interfaces, but only QOM leaves. So maybe better always use .abstract = false in DEFINE_MACHINE_EXTENDED()?

Where did you get that from? What about these then:

static const TypeInfo pnv_psi_info
static const TypeInfo spapr_machine_info static const TypeInfo e1000_base_info
static const TypeInfo ivshmem_common_info static const TypeInfo macio_type_info
static const TypeInfo bus_info
static const TypeInfo device_type_info
static const TypeInfo hppa_machine_types static const TypeInfo qxl_pci_type_info
static const TypeInfo pic_common_type
static const TypeInfo xive2_router_info
static const TypeInfo arm_gic_common_type static const TypeInfo arm_gicv3_common_type static const TypeInfo ioapic_common_type static const TypeInfo loongarch_extioi_common_types static const TypeInfo rp_info
static const TypeInfo virt_machine_info (hw/arm/virt.c) static const TypeInfo mps2tz_info
static const TypeInfo armsse_info
static const TypeInfo m48txx_isa_type_info static const TypeInfo m48txx_sysbus_type_info static const TypeInfo pci_ide_type_info
static const TypeInfo ccw_machine_info
static const TypeInfo virtio_ccw_md_info static const TypeInfo pc_machine_info
static const TypeInfo x86_machine_info
static const TypeInfo vfio_pci_device_info static const TypeInfo ehci_pci_type_info static const TypeInfo xhci_pci_info
static const TypeInfo uhci_pci_type_info static const TypeInfo via_pm_info
static const TypeInfo via_isa_info
static const TypeInfo piix_pci_type_info static const TypeInfo pcie_slot_type_info static const TypeInfo pci_bridge_type_info static const TypeInfo intel_hda_info
static const TypeInfo virtio_md_pci_info

Quoted 3 lines
Quoted 3 lines

include/hw/boards.h struct MachineState { · line 778

Quoted 1 line
include/hw/boards.h +1 -0
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Do you have an example for that? I'm not sure what do you mean.

Regards,
BALATON Zoltan

Quoted 20 lines
Quoted 18 lines
Quoted 18 lines
include/hw/boards.h +8 -0
       }; \
       static void machine_initfn##_register_types(void) \
       { \
@@ -779,6 +783,14 @@ struct MachineState {
       } \
       type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, __VA_ARGS__)
+
   extern GlobalProperty hw_compat_10_1[];
   extern const size_t hw_compat_10_1_len;
#26 lore raw

Re: [PATCH v3 11/13] hw/boards: Extend DEFINE_MACHINE macro to cover more use cases

+ Eduardo, Marcel (since changes in boards.h)

Quoted 111 lines · BALATON Zoltan
Quoted 32 lines · Philippe Mathieu-Daudé

+Pierrick

Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · BALATON Zoltan

Add a more general DEFINE_MACHINE_EXTENDED macro and define simpler versions with less parameters based on that. This is inspired by how the OBJECT_DEFINE macros do this in a similar way to allow using the shortened definition in more complex cases too.

---
  include/hw/boards.h | 16 ++++++++++++++--

  1 file changed, 14 insertions(+), 2 deletions(-)
include/hw/boards.h +2 -2
index 665b620121..fd3d549ff5 100644
@@ -762,7 +762,8 @@ struct MachineState {
           } \
       } while (0)
-#define DEFINE_MACHINE(namestr, machine_initfn) \
+#define DEFINE_MACHINE_EXTENDED(namestr, PARENT_NAME, InstanceName, \
+                                machine_initfn, ABSTRACT, ...) \
       static void machine_initfn##_class_init(ObjectClass *oc, const void *data) \
       { \
           MachineClass *mc = MACHINE_CLASS(oc); \
@@ -770,8 +771,11 @@ struct MachineState {
       } \
       static const TypeInfo machine_initfn##_typeinfo = { \
           .name       = MACHINE_TYPE_NAME(namestr), \
-        .parent     = TYPE_MACHINE, \
Quoted 8 lines
Quoted 4 lines

include/hw/boards.h struct MachineState { · line 777

Quoted 4 lines
include/hw/boards.h +3 -0
+        .parent     = TYPE_##PARENT_NAME, \
           .class_init = machine_initfn##_class_init, \
+        .instance_size = sizeof(InstanceName), \
+        .abstract = ABSTRACT, \

IIUC we don't want to have abstract type with interfaces, but only QOM leaves. So maybe better always use .abstract = false in DEFINE_MACHINE_EXTENDED()?

Where did you get that from? What about these then:

static const TypeInfo pnv_psi_info
static const TypeInfo spapr_machine_info static const TypeInfo e1000_base_info
static const TypeInfo ivshmem_common_info static const TypeInfo macio_type_info
static const TypeInfo bus_info
static const TypeInfo device_type_info
static const TypeInfo hppa_machine_types static const TypeInfo qxl_pci_type_info
static const TypeInfo pic_common_type
static const TypeInfo xive2_router_info
static const TypeInfo arm_gic_common_type static const TypeInfo arm_gicv3_common_type static const TypeInfo ioapic_common_type static const TypeInfo loongarch_extioi_common_types static const TypeInfo rp_info
static const TypeInfo virt_machine_info (hw/arm/virt.c) static const TypeInfo mps2tz_info
static const TypeInfo armsse_info
static const TypeInfo m48txx_isa_type_info static const TypeInfo m48txx_sysbus_type_info static const TypeInfo pci_ide_type_info
static const TypeInfo ccw_machine_info
static const TypeInfo virtio_ccw_md_info static const TypeInfo pc_machine_info
static const TypeInfo x86_machine_info
static const TypeInfo vfio_pci_device_info static const TypeInfo ehci_pci_type_info static const TypeInfo xhci_pci_info
static const TypeInfo uhci_pci_type_info static const TypeInfo via_pm_info
static const TypeInfo via_isa_info
static const TypeInfo piix_pci_type_info static const TypeInfo pcie_slot_type_info static const TypeInfo pci_bridge_type_info static const TypeInfo intel_hda_info
static const TypeInfo virtio_md_pci_info

Quoted 3 lines
Quoted 3 lines

include/hw/boards.h struct MachineState { · line 778

Quoted 1 line
include/hw/boards.h +1 -0
+        .interfaces = (const InterfaceInfo[]) { __VA_ARGS__ } , \

IIUC Richard asked for array argument in order to save .rodata?

Do you have an example for that? I'm not sure what do you mean.

Regards,
BALATON Zoltan

Quoted 20 lines
Quoted 18 lines
Quoted 18 lines
include/hw/boards.h +8 -0
       }; \
       static void machine_initfn##_register_types(void) \
       { \
@@ -779,6 +783,14 @@ struct MachineState {
       } \
       type_init(machine_initfn##_register_types)
+#define DEFINE_MACHINE(namestr, machine_initfn) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, { })
+
+#define DEFINE_MACHINE_WITH_INTERFACES(namestr, machine_initfn, ...) \
+    DEFINE_MACHINE_EXTENDED(namestr, MACHINE, MachineState, 
 machine_initfn, \
+                            false, __VA_ARGS__)
+
   extern GlobalProperty hw_compat_10_1[];
   extern const size_t hw_compat_10_1_len;
#27 lore raw

PATCH v3 12/13 hw/ppc/pegasos2: Add Pegasos I emulation

In reply to BALATON Zoltan

The Pegasos II is a redesign of the original Pegasos (later marked I) that replaces the north bridge and has updated firmware but otherwise these are very similar. The Pegasos uses the same north bridge that AmigaOne used which we already emulate so we can also easily emulate Pegasos I.

---
 hw/ppc/pegasos2.c | 170 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 124 insertions(+), 46 deletions(-)
hw/ppc/pegasos2.c +124 -46
index ae3f01231d..a88d93ae04 100644
@@ -1,5 +1,5 @@
 /*
- * QEMU PowerPC CHRP (Genesi/bPlan Pegasos II) hardware System Emulator
+ * QEMU PowerPC CHRP (Genesi/bPlan Pegasos I/II) hardware System Emulator
  *
  * Copyright (c) 2018-2021 BALATON Zoltan
  *
@@ -15,6 +15,7 @@
 #include "hw/pci/pci_host.h"
 #include "hw/irq.h"
 #include "hw/or-irq.h"
+#include "hw/pci-host/articia.h"
 #include "hw/pci-host/mv64361.h"
 #include "hw/isa/vt82c686.h"
 #include "hw/ide/pci.h"
@@ -55,12 +56,18 @@
 #define H_PRIVILEGE  -3  /* Caller not privileged */
 #define H_PARAMETER  -4  /* Parameter invalid, out-of-range or conflicting */
 
+typedef enum {
+    PEGASOS1 = 1,
+    PEGASOS2 = 2,
+} PegasosMachineType;
+
 #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos")
 OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE)
 
 struct PegasosMachineState {
     MachineState parent_obj;
 
+    PegasosMachineType type;
     PowerPCCPU *cpu;
     DeviceState *nb; /* north bridge */
     DeviceState *sb; /* south bridge */
@@ -79,7 +86,7 @@ struct PegasosMachineState {
 
 static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size);
 
-static void pegasos2_cpu_reset(void *opaque)
+static void pegasos_cpu_reset(void *opaque)
 {
     PowerPCCPU *cpu = opaque;
     PegasosMachineState *pm = PEGASOS_MACHINE(current_machine);
@@ -89,6 +96,8 @@ static void pegasos2_cpu_reset(void *opaque)
     if (pm->vof) {
         cpu->env.gpr[1] = 2 * VOF_STACK_SIZE - 0x20;
         cpu->env.nip = 0x100;
+    } else if (pm->type == PEGASOS1) {
+        cpu->env.nip = 0xfffc0100;
     }
     cpu_ppc_tb_reset(&cpu->env);
 }
@@ -139,13 +148,15 @@ static void pegasos_init(MachineState *machine)
     PegasosMachineState *pm = PEGASOS_MACHINE(machine);
     CPUPPCState *env;
     MemoryRegion *rom = g_new(MemoryRegion, 1);
-    PCIBus *pci_bus;
+    PCIBus *pci_bus = NULL;
     Object *via;
     PCIDevice *dev;
     I2CBus *i2c_bus;
     const char *fwname = machine->firmware ?: PROM_FILENAME;
     char *filename;
+    hwaddr prom_addr;
     ssize_t sz;
+    int devfn;
     uint8_t *spd_data;
 
     /* init CPU */
@@ -158,7 +169,7 @@ static void pegasos_init(MachineState *machine)
 
     /* Set time-base frequency */
     cpu_ppc_tb_init(env, pm->bus_freq_hz / 4);
-    qemu_register_reset(pegasos2_cpu_reset, pm->cpu);
+    qemu_register_reset(pegasos_cpu_reset, pm->cpu);
 
     /* RAM */
     if (machine->ram_size > 2 * GiB) {
@@ -176,12 +187,16 @@ static void pegasos_init(MachineState *machine)
     if (!machine->firmware && !pm->vof) {
         pm->vof = g_malloc0(sizeof(*pm->vof));
     }
-    memory_region_init_rom(rom, NULL, "pegasos2.rom", PROM_SIZE, &error_fatal);
-    memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom);
+    prom_addr = PROM_ADDR;
+    if (pm->type == PEGASOS1) {
+        prom_addr += PROM_SIZE;
+    }
+    memory_region_init_rom(rom, NULL, "rom", PROM_SIZE, &error_fatal);
+    memory_region_add_subregion(get_system_memory(), prom_addr, rom);
     sz = load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                   ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0);
     if (sz <= 0) {
-        sz = load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM_SIZE);
+        sz = load_image_targphys(filename, pm->vof ? 0 : prom_addr, PROM_SIZE);
     }
     if (sz <= 0 || sz > PROM_SIZE) {
         error_report("Could not load firmware '%s'", filename);
@@ -192,13 +207,37 @@ static void pegasos_init(MachineState *machine)
         pm->vof->fw_size = sz;
     }
 
-    /* Marvell Discovery II system controller */
-    pm->nb = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
-                          qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_INT)));
-    pci_bus = mv64361_get_pci_bus(pm->nb, 1);
+    /* north bridge */
+    switch (pm->type) {
+    case PEGASOS1:
+    {
+        MemoryRegion *pci_mem, *mr;
+
+        /* Articia S */
+        pm->nb = DEVICE(sysbus_create_simple(TYPE_ARTICIA, 0xfe000000, NULL));
+        pci_mem = sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 1);
+        mr = g_new(MemoryRegion, 1);
+        memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-low", pci_mem,
+                                 0, 0x1000000);
+        memory_region_add_subregion(get_system_memory(), 0xfd000000, mr);
+        mr = g_new(MemoryRegion, 1);
+        memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-high", pci_mem,
+                                 0x80000000, 0x7d000000);
+        memory_region_add_subregion(get_system_memory(), 0x80000000, mr);
+        pci_bus = PCI_BUS(qdev_get_child_bus(pm->nb, "pci.0"));
+        break;
+    }
+    case PEGASOS2:
+        /* Marvell Discovery II system controller */
+        pm->nb = DEVICE(sysbus_create_simple(TYPE_MV64361, -1,
+                        qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_INT)));
+        pci_bus = mv64361_get_pci_bus(pm->nb, 1);
+        break;
+    }
 
     /* VIA VT8231 South Bridge (multifunction PCI device) */
-    pm->sb = DEVICE(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA));
+    devfn = PCI_DEVFN(pm->type == PEGASOS1 ? 7 : 12, 0);
+    pm->sb = DEVICE(pci_new_multifunction(devfn, TYPE_VT8231_ISA));
     via = OBJECT(pm->sb);
 
     /* Set properties on individual devices before realizing the south bridge */
@@ -223,7 +262,21 @@ static void pegasos_init(MachineState *machine)
     /* other PC hardware */
     pci_vga_init(pci_bus);
 
-    pegasos2_setup_pci_irq(pm);
+    /* pci interrupt routing */
+    switch (pm->type) {
+    case PEGASOS1:
+        qdev_connect_gpio_out_named(pm->sb, "intr", 0,
+                                    qdev_get_gpio_in(DEVICE(pm->cpu),
+                                                     PPC6xx_INPUT_INT));
+        for (int i = 0; i < PCI_NUM_PINS; i++) {
+            qdev_connect_gpio_out(pm->nb, i,
+                                  qdev_get_gpio_in_named(pm->sb, "pirq", i));
+        }
+        break;
+    case PEGASOS2:
+        pegasos2_setup_pci_irq(pm);
+        break;
+    }
 
     if (machine->kernel_filename) {
         sz = load_elf(machine->kernel_filename, NULL, NULL, NULL,
@@ -376,7 +429,7 @@ static void pegasos2_chipset_reset(PegasosMachineState *pm)
                               PCI_INTERRUPT_LINE, 2, 0x309);
 }
 
-static void pegasos2_machine_reset(MachineState *machine, ResetType type)
+static void pegasos_machine_reset(MachineState *machine, ResetType type)
 {
     PegasosMachineState *pm = PEGASOS_MACHINE(machine);
     void *fdt;
@@ -387,6 +440,9 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type)
     qemu_devices_reset(type);
     if (!pm->vof) {
         return; /* Firmware should set up machine so nothing to do */
+    } else if (pm->type == PEGASOS1) {
+        error_report("VOF is not supported by this machine");
+        exit(1);
     }
 
     /* Otherwise, set up devices that board firmware would normally do */
@@ -558,12 +614,12 @@ static target_ulong pegasos2_rtas(PowerPCCPU *cpu, PegasosMachineState *pm,
     }
 }
 
-static bool pegasos2_cpu_in_nested(PowerPCCPU *cpu)
+static bool pegasos_cpu_in_nested(PowerPCCPU *cpu)
 {
     return false;
 }
 
-static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
+static void pegasos_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
 {
     PegasosMachineState *pm = PEGASOS_MACHINE(vhyp);
     CPUPPCState *env = &cpu->env;
@@ -574,7 +630,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu)
     if (FIELD_EX64(env->msr, MSR, PR)) {
         qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=1\n");
         env->gpr[3] = H_PRIVILEGE;
-    } else if (env->gpr[3] == KVMPPC_H_RTAS) {
+    } else if (env->gpr[3] == KVMPPC_H_RTAS && pm->type == PEGASOS2) {
         env->gpr[3] = pegasos2_rtas(cpu, pm, env->gpr[4]);
     } else if (env->gpr[3] == KVMPPC_H_VOF_CLIENT) {
         int ret = vof_client_call(MACHINE(pm), pm->vof, MACHINE(pm)->fdt,
@@ -596,62 +652,84 @@ static target_ulong vhyp_encode_hpt_for_kvm_pr(PPCVirtualHypervisor *vhyp)
     return POWERPC_CPU(current_cpu)->env.spr[SPR_SDR1];
 }
 
-static bool pegasos2_setprop(MachineState *ms, const char *path,
-                             const char *propname, void *val, int vallen)
+static bool pegasos_setprop(MachineState *ms, const char *path,
+                            const char *propname, void *val, int vallen)
 {
     return true;
 }
 
-static void pegasos2_init(Object *obj)
-{
-    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
-
-    pm->bus_freq_hz = 133333333;
-}
-
-static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
+static void pegasos_machine_init(MachineClass *mc)
 {
-    MachineClass *mc = MACHINE_CLASS(oc);
-    PPCVirtualHypervisorClass *vhc = PPC_VIRTUAL_HYPERVISOR_CLASS(oc);
-    VofMachineIfClass *vmc = VOF_MACHINE_CLASS(oc);
+    PPCVirtualHypervisorClass *vhc = PPC_VIRTUAL_HYPERVISOR_CLASS(mc);
+    VofMachineIfClass *vmc = VOF_MACHINE_CLASS(mc);
 
-    mc->desc = "Genesi/bPlan Pegasos II";
     mc->init = pegasos_init;
-    mc->reset = pegasos2_machine_reset;
+    mc->reset = pegasos_machine_reset;
     mc->block_default_type = IF_IDE;
     mc->default_boot_order = "cd";
     mc->default_display = "std";
-    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7457_v1.2");
-    mc->default_ram_id = "pegasos2.ram";
+    mc->default_ram_id = "ram";
     mc->default_ram_size = 512 * MiB;
     machine_add_audiodev_property(mc);
 
-    vhc->cpu_in_nested = pegasos2_cpu_in_nested;
-    vhc->hypercall = pegasos2_hypercall;
+    vhc->cpu_in_nested = pegasos_cpu_in_nested;
+    vhc->hypercall = pegasos_hypercall;
     vhc->cpu_exec_enter = vhyp_nop;
     vhc->cpu_exec_exit = vhyp_nop;
     vhc->encode_hpt_for_kvm_pr = vhyp_encode_hpt_for_kvm_pr;
 
-    vmc->setprop = pegasos2_setprop;
+    vmc->setprop = pegasos_setprop;
+}
+
+static void pegasos1_init(Object *obj)
+{
+    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
+
+    pm->type = PEGASOS1;
+    pm->bus_freq_hz = 33000000;
+}
+
+static void pegasos1_machine_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "Genesi/bPlan Pegasos I";
+    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("750cxe_v3.1b");
+}
+
+static void pegasos2_init(Object *obj)
+{
+    PegasosMachineState *pm = PEGASOS_MACHINE(obj);
+
+    pm->type = PEGASOS2;
+    pm->bus_freq_hz = 133333333;
+}
+
+static void pegasos2_machine_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "Genesi/bPlan Pegasos II";
+    mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7457_v1.2");
 }
 
+DEFINE_MACHINE_EXTENDED("pegasos", MACHINE, PegasosMachineState,
+                        pegasos_machine_init, true,
+                        { TYPE_PPC_VIRTUAL_HYPERVISOR },
+                        { TYPE_VOF_MACHINE_IF }, { })
+
 static const TypeInfo pegasos_machine_types[] = {
     {
-        .name          = TYPE_PEGASOS_MACHINE,
-        .parent        = TYPE_MACHINE,
-        .instance_size = sizeof(PegasosMachineState),
-        .abstract      = true,
+        .name          = MACHINE_TYPE_NAME("pegasos1"),
+        .parent        = TYPE_PEGASOS_MACHINE,
+        .class_init    = pegasos1_machine_class_init,
+        .instance_init = pegasos1_init,
     },
     {
         .name          = MACHINE_TYPE_NAME("pegasos2"),
         .parent        = TYPE_PEGASOS_MACHINE,
         .class_init    = pegasos2_machine_class_init,
         .instance_init = pegasos2_init,
-        .interfaces = (const InterfaceInfo[]) {
-              { TYPE_PPC_VIRTUAL_HYPERVISOR },
-              { TYPE_VOF_MACHINE_IF },
-              { }
-        },
     },
 };
 
Signature · 1 line
2.41.3
#28 lore raw

PATCH v3 13/13 hw/ppc/pegasos2: Add VOF support for pegasos1

In reply to BALATON Zoltan

When running without firmware ROM using Virtual Open Firmware we need to do some hardware initialisation and provide the device tree as the machine firmware would normally do.

---
 MAINTAINERS              |   1 +
 hw/ppc/pegasos2.c        | 140 +++++++++++++++++++++++++++++++++------
 pc-bios/dtb/meson.build  |   1 +
 pc-bios/dtb/pegasos1.dtb | Bin 0 -> 857 bytes
 pc-bios/dtb/pegasos1.dts | 125 ++++++++++++++++++++++++++++++++++
 5 files changed, 246 insertions(+), 21 deletions(-)
 create mode 100644 pc-bios/dtb/pegasos1.dtb
 create mode 100644 pc-bios/dtb/pegasos1.dts
MAINTAINERS +1 -0
index 667acd933c..490eb7e0f7 100644
@@ -1651,6 +1651,7 @@ F: hw/ppc/pegasos2.c
 F: hw/pci-host/mv64361.c
 F: hw/pci-host/mv643xx.h
 F: include/hw/pci-host/mv64361.h
+F: pc-bios/dtb/pegasos[12].dt[sb]
 
 amigaone
 M: BALATON Zoltan <[email protected]>
hw/ppc/pegasos2.c +119 -21

203 lines not on this page · raw message

pc-bios/dtb/meson.build +1 -0
index f14648f3a4..81bdd7580e 100644
@@ -1,6 +1,7 @@
 dtbs = [
   'bamboo.dtb',
   'canyonlands.dtb',
+  'pegasos1.dtb',
   'pegasos2.dtb',
   'petalogix-ml605.dtb',
   'petalogix-s3adsp1800.dtb',
pc-bios/dtb/pegasos1.dtb new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..3b863b25288a59bcede9459ff42afad713dde741
GIT binary patch
pc-bios/dtb/pegasos1.dts new file +125 -0

125 lines not on this page · raw message

Signature · 1 line
2.41.3
#29 lore raw
In reply to BALATON Zoltan

Hi BALATON,

I tested this series with the provided patches and observed the following:

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
-cdrom debian-8.11.0-powerpc-netinst.iso \
-device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                  -kernel vmlinuz-chrp.initrd -append "---" \
                  -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Documentation referred: qemu/docs/system/ppc/amigang.rst

Regards,
Yogesh Vyas

Quoted 69 lines · BALATON Zoltan

This series changes how the fdt for VOF is generated in pegasos2 by moving the static parts to a dtb and only generate the changing parts such as memory size and PCI devices programmatically. This simplifies the code and allows simply adding emulation of Pegasos I which has a different north bridge and slightly different memory map but otherwise very similar and can be emulated by reusing parts from the amigaone machine. The machine was tested with a Pegasos I ROM image and MorphOS.

The first VOF patch (submitted separetely before, the reviewed v3 is included here) fixes handling the name property in VOF that cannot be represented in a dts as that always takes the path as the name and cannot accept an explicit name property but we need the name property to appear when guest queries properties which previously was worked around by adding it to every node.

The series also adds an extended DEFINE_MACHINE macro that is later used for more easily define the abstract machine type and hide most of the QOM boiler plate.

Regards,
BALATON Zoltan

Link to previous version:
https://patchew.org/QEMU/[email protected]/

v3:
- rebase on master

v2:
- rebase on master
- added some R-b tags from Philippe
- move first patch later (was first to allow merging separately)
- clarify blurb above

BALATON Zoltan (13):
ppc/vof: Make nextprop behave more like Open Firmware hw/ppc/pegasos2: Remove explicit name properties from device tree hw/ppc/pegasos2: Change device tree generation hw/ppc/pegasos2: Remove fdt pointer from machine state hw/ppc/pegasos2: Rename mv field in machine state hw/ppc/pegasos2: Add south bridge pointer in the machine state hw/ppc/pegasos2: Move PCI IRQ routing setup to a function hw/ppc/pegasos2: Move hardware specific parts out of machine reset hw/ppc/pegasos2: Introduce abstract superclass hw/ppc/pegasos2: Add bus frequency to machine state hw/boards: Extend DEFINE_MACHINE macro to cover more use cases hw/ppc/pegasos2: Add Pegasos I emulation hw/ppc/pegasos2: Add VOF support for pegasos1

 MAINTAINERS              |   1 +
 hw/ppc/pegasos2.c        | 770 +++++++++++++++++++--------------------
 hw/ppc/vof.c             |  50 ++-
 include/hw/boards.h      |  16 +-
 pc-bios/dtb/meson.build  |   2 +
 pc-bios/dtb/pegasos1.dtb | Bin 0 -> 857 bytes
 pc-bios/dtb/pegasos1.dts | 125 +++++++
 pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes
 pc-bios/dtb/pegasos2.dts | 167 +++++++++
 9 files changed, 718 insertions(+), 413 deletions(-)
 create mode 100644 pc-bios/dtb/pegasos1.dtb
 create mode 100644 pc-bios/dtb/pegasos1.dts
 create mode 100644 pc-bios/dtb/pegasos2.dtb
 create mode 100644 pc-bios/dtb/pegasos2.dts

--
2.41.3

#30 lore raw
Quoted 10 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
-cdrom debian-8.11.0-powerpc-netinst.iso \
-device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

Quoted 8 lines
qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Regards,
BALATON Zoltan

#31 lore raw
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
-cdrom debian-8.11.0-powerpc-netinst.iso \
-device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped
yogi@fedora:~/work/images$ file debian-8.11.0-powerpc-netinst.iso
debian-8.11.0-powerpc-netinst.iso: ISO 9660 CD-ROM filesystem data (DOS/MBR
boot sector) 'Debian 8.11.0 ppc 1'

Qemu distro version:

yogi@fedora:~/work/images$ qemu-system-ppc --version
QEMU emulator version 9.2.4 (qemu-9.2.4-2.fc42)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
yogi@fedora:~/work/images$ qemu-system-ppc64 --version
QEMU emulator version 9.2.4 (qemu-9.2.4-2.fc42)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers

When using upstream Qemu (both ppc and pp64) with VOF it just gets stuck with no console output. Am I missing something?

I also tried applying the patches from
https://lore.kernel.org/qemu-devel/[email protected]/T/#t
but still the same issue.

Regards,
Yogesh

Quoted 3 lines

Regards,
BALATON Zoltan

#32 lore raw
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
-cdrom debian-8.11.0-powerpc-netinst.iso \
-device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

9301172 Jun 19 2018 /install/powerpc/vmlinuz-chrp.initrd
10534888 Jun 19 2018 /install/powerpc64/vmlinuz-chrp.initrd

File command says:

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Regards,
BALATON Zoltan

#33 lore raw
Quoted 36 lines · BALATON Zoltan
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
                 -cdrom debian-8.11.0-powerpc-netinst.iso \
                 -device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 8 lines
Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

  9301172 Jun 19  2018 /install/powerpc/vmlinuz-chrp.initrd 10534888 Jun 19  2018 /install/powerpc64/vmlinuz-chrp.initrd

I am also using the same file:

yogi@fedora:~/work/images$ ls -lrt vmlinuz-chrp.initrd
-r--r--r--. 1 yogi yogi 9301172 Oct 18 23:50 vmlinuz-chrp.initrd
Quoted 7 lines

File command says:

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Yes, I had mentioned it in my first mail that ROM option works as expected. It is only an issue when using VOF with upstream Qemu.

Could you please share your Qemu command line if it's different from the one mentioned in the documentation.

Regards,

Yogesh Vyas

Quoted 3 lines

Regards,
BALATON Zoltan

#34 lore raw
Quoted 55 lines · Yogesh Vyas
Quoted 36 lines · BALATON Zoltan
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
                 -cdrom debian-8.11.0-powerpc-netinst.iso \
                 -device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 8 lines
Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

  9301172 Jun 19  2018 /install/powerpc/vmlinuz-chrp.initrd 10534888 Jun 19  2018 /install/powerpc64/vmlinuz-chrp.initrd

I am also using the same file:

yogi@fedora:~/work/images$ ls -lrt vmlinuz-chrp.initrd
-r--r--r--. 1 yogi yogi 9301172 Oct 18 23:50 vmlinuz-chrp.initrd
Quoted 3 lines

File command says:

Quoted 8 lines
Quoted 4 lines

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Yes, I had mentioned it in my first mail that ROM option works as expected. It is only an issue when using VOF with upstream Qemu.

Could you please share your Qemu command line if it's different from the one mentioned in the documentation.

I've tested with the same command as in the docs:

qemu-system-ppc64 -M pegasos2 -serial stdio -kernel vmlinuz-chrp.initrd -append "---" -cdrom debian-8.11.0-powerpc-netinst.iso

and it boots for me like before. I don't know what could you check to find out why it does not work for you. Maybe you can try adding -d guest_errors and see if that prints any errors or try on different machine or distro to make sure it's not something local to your machine. Or check if you have local patches compared to master and that the vmlinuz-chrp.initrd is the same as on CD and not somehow corrupted. I really have no idea what could it be.

Regards,
BALATON Zoltan

#35 lore raw
In reply to Yogesh Vyas
Quoted 54 lines · Yogesh Vyas
Quoted 36 lines · BALATON Zoltan
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
                 -cdrom debian-8.11.0-powerpc-netinst.iso \
                 -device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 8 lines
Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

  9301172 Jun 19  2018 /install/powerpc/vmlinuz-chrp.initrd 10534888 Jun 19  2018 /install/powerpc64/vmlinuz-chrp.initrd

I am also using the same file:

yogi@fedora:~/work/images$ ls -lrt vmlinuz-chrp.initrd
-r--r--r--. 1 yogi yogi 9301172 Oct 18 23:50 vmlinuz-chrp.initrd
Quoted 1 line
Quoted 8 lines
Quoted 6 lines

File command says:

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Yes, I had mentioned it in my first mail that ROM option works as expected. It is only an issue when using VOF with upstream Qemu.

Or if you suspect it's a VOF issue you can try -trace enable="vof*"

Regards,
BALATON Zoltan

#36 lore raw
Quoted 58 lines · BALATON Zoltan
Quoted 56 lines · Yogesh Vyas
Quoted 36 lines · BALATON Zoltan
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
                 -cdrom debian-8.11.0-powerpc-netinst.iso \
                 -device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 8 lines
Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

  9301172 Jun 19  2018 /install/powerpc/vmlinuz-chrp.initrd 10534888 Jun 19  2018 /install/powerpc64/vmlinuz-chrp.initrd

I am also using the same file:

yogi@fedora:~/work/images$ ls -lrt vmlinuz-chrp.initrd
-r--r--r--. 1 yogi yogi 9301172 Oct 18 23:50 vmlinuz-chrp.initrd
Quoted 3 lines

File command says:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Yes, I had mentioned it in my first mail that ROM option works as expected. It is only an issue when using VOF with upstream Qemu.

Or if you suspect it's a VOF issue you can try -trace enable="vof*"

Hi Balaton,

As suggested, I tried both options in upstream:

yogi@fedora:~/work/git/fork/qemu/build$ ./qemu-system-ppc -machine pegasos2 -serial stdio -kernel ~/work/images/vmlinuz-chrp.initrd -append "---" -cdrom ~/work/images/debian-8.11.0-powerpc-netinst.iso -d guest_errors -trace enable="vof*"

I could see the below trace and the error message:
 vof_getproplen ph=0x13 "subsystem-vendor-id" => len=4
vof_getprop ph=0x13 "subsystem-vendor-id" => len=4 [00001100] vof_getproplen ph=0x13 "reg" => len=20
vof_getprop ph=0x13 "reg" => len=20 [00000000 00000000 00000000 00000000 00000000] vof_write ih=0x2 [22] "Device tree strings 0x"
vof_write ih=0x2 [8] "01b0d000"
vof_write ih=0x2 [6] " -> 0x"
vof_write ih=0x2 [8] "01b0d405"
vof_write ih=0x2 [2] "
"
vof_write ih=0x2 [22] "Device tree struct  0x"
vof_write ih=0x2 [8] "01b0e000"
vof_write ih=0x2 [6] " -> 0x"
vof_write ih=0x2 [8] "01b0f000"
vof_write ih=0x2 [2] "
"
vof_getprop ph=0x3 "stdin" => len=4 [00000001]
vof_write ih=0x2 [18] "Calling quiesce..."
vof_write ih=0x2 [2] "
"
vof_claimed 0x0..0xd80 size=0xd80
vof_claimed 0x8000..0x10000 size=0x8000
vof_claimed 0x400000..0xcd8dfc size=0x8d8dfc
vof_claimed 0xd00000..0x15a1ec0 size=0x8a1ec0
vof_claimed 0x15a2000..0x1b0b90d size=0x56990d
vof_claimed 0x1b0c000..0x1c0c000 size=0x100000
vof_claimed 0x1ffff000..0x1ffff014 size=0x14
vof_write ih=0x2 [24] "returning from prom_init"
vof_write ih=0x2 [2] "
"
Trying to read invalid spr 1012 (0x3f4) at c0013f48

Regards,

Yogesh Vyas

Quoted 2 lines

Regards,
BALATON Zoltan

#37 lore raw
Quoted 97 lines · Yogesh Vyas
Quoted 56 lines · BALATON Zoltan
Quoted 55 lines · Yogesh Vyas
Quoted 36 lines · BALATON Zoltan
Quoted 28 lines · Yogesh Vyas
Quoted 18 lines · BALATON Zoltan
Quoted 17 lines · Yogesh Vyas

When I run QEMU with the ROM option, the machine boots successfully with the below command:

qemu-system-ppc64 -machine pegasos2 -bios pegasos2.rom \
                 -cdrom debian-8.11.0-powerpc-netinst.iso \
                 -device VGA,romfile="" -serial stdio

However, when I try to boot the machine without the ROM using VOF, the machine does not come up and no logs appear on stdout:

qemu-system-ppc64 -machine pegasos2 -serial stdio \
                 -kernel vmlinuz-chrp.initrd -append "---" \
                 -cdrom debian-8.11.0-powerpc-netinst.iso

Please let me know if I am missing any parameters or setup required for booting via VOF on Pegasos2.

Quoted 9 lines
Quoted 1 line

Documentation referred: qemu/docs/system/ppc/amigang.rst

Maybe you did not use the right vmlinuz-chrp.initrd. Pegasos2 is a 32 bit machine so you need /install/powerpc/vmlinuz-chrp.initrd for it (see in the /install/pegasos script that is used with firmware). Even if you call it from qemu-system-ppc64 which includes both 32 bit and 64 bit machines but does not make 32 bit machines 64 bit so you still need the 32 bit OS.

Quoted 4 lines

Hi Balaton,
I am using 32bit images only and looks like VOF boot works with the distro provided Qemu (both ppc and pp64), however doesn't work with upstream Qemu for VOF.

That's odd, it works for me with QEMU master so I can't reproduce this.

Quoted 8 lines
Quoted 3 lines
yogi@fedora:~/work/images$ file vmlinuz-chrp.initrd
vmlinuz-chrp.initrd: ELF 32-bit MSB executable, PowerPC or cisco 4500,
version 1 (SYSV), statically linked, not stripped

The file command says 32-bit for both /install/powerpc/vmlinuz-chrp.initrd and /install/powerpc64/vmlinuz-chrp.initrd but only the first one should work. Can you double check you have the right vmlinuz-chrp.initrd file? But if you say the same file works with 9.2.4 I have no idea why. I see these files on the CD

  9301172 Jun 19  2018 /install/powerpc/vmlinuz-chrp.initrd 10534888 Jun 19  2018 /install/powerpc64/vmlinuz-chrp.initrd

I am also using the same file:

yogi@fedora:~/work/images$ ls -lrt vmlinuz-chrp.initrd
-r--r--r--. 1 yogi yogi 9301172 Oct 18 23:50 vmlinuz-chrp.initrd
Quoted 3 lines

File command says:

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

vmlinuz-chrp.initrd:   ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped vmlinuz-chrp.initrd64: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped

but only the first from the powerpc directory is supposed to work and it does boot for me with QEMU master. You can also check following the other way described in qemu/docs/system/ppc/amigang.rst using -bios pegasos2.rom which loads the correct image from the CD. Does that work?

Yes, I had mentioned it in my first mail that ROM option works as expected. It is only an issue when using VOF with upstream Qemu.

Or if you suspect it's a VOF issue you can try -trace enable="vof*"

Hi Balaton,

As suggested, I tried both options in upstream:

yogi@fedora:~/work/git/fork/qemu/build$ ./qemu-system-ppc -machine pegasos2 
-serial stdio -kernel ~/work/images/vmlinuz-chrp.initrd -append "---" -cdrom 
~/work/images/debian-8.11.0-powerpc-netinst.iso -d guest_errors -trace enable="vof*"

I could see the below trace and the error message:
 vof_getproplen ph=0x13 "subsystem-vendor-id" => len=4
vof_getprop ph=0x13 "subsystem-vendor-id" => len=4 [00001100] vof_getproplen ph=0x13 "reg" => len=20
vof_getprop ph=0x13 "reg" => len=20 [00000000 00000000 00000000 00000000 00000000] vof_write ih=0x2 [22] "Device tree strings 0x"
vof_write ih=0x2 [8] "01b0d000"
vof_write ih=0x2 [6] " -> 0x"
vof_write ih=0x2 [8] "01b0d405"
vof_write ih=0x2 [2] "
"
vof_write ih=0x2 [22] "Device tree struct  0x"
vof_write ih=0x2 [8] "01b0e000"
vof_write ih=0x2 [6] " -> 0x"
vof_write ih=0x2 [8] "01b0f000"
vof_write ih=0x2 [2] "
"
vof_getprop ph=0x3 "stdin" => len=4 [00000001]
vof_write ih=0x2 [18] "Calling quiesce..."
vof_write ih=0x2 [2] "
"
vof_claimed 0x0..0xd80 size=0xd80
vof_claimed 0x8000..0x10000 size=0x8000
vof_claimed 0x400000..0xcd8dfc size=0x8d8dfc

Quoted 8 lines

vof_claimed 0xd00000..0x15a1ec0 size=0x8a1ec0 vof_claimed 0x15a2000..0x1b0b90d size=0x56990d vof_claimed 0x1b0c000..0x1c0c000 size=0x100000 vof_claimed 0x1ffff000..0x1ffff014 size=0x14 vof_write ih=0x2 [24] "returning from prom_init" vof_write ih=0x2 [2] "
"
Trying to read invalid spr 1012 (0x3f4) at c0013f48

Then VOF works too and the Linux kernel loader starts but it stops somewhere when the actual kernel starts. I get:

vof_write ih=0x1 [18] "Calling quiesce..." vof_write ih=0x1 [2] "
"
vof_claimed 0x0..0xd80 size=0xd80
vof_claimed 0x8000..0x10000 size=0x8000 vof_claimed 0x400000..0xcd8dfc size=0x8d8dfc vof_claimed 0xd00000..0x15a1ec0 size=0x8a1ec0 vof_claimed 0x15a2000..0x1b0b90d size=0x56990d vof_claimed 0x1b0c000..0x1c0c000 size=0x100000 vof_claimed 0x1ffff000..0x1ffff014 size=0x14 vof_write ih=0x1 [24] "returning from prom_init" vof_write ih=0x1 [2] "
"
Trying to read invalid spr 1012 (0x3f4) at 00000000c0013f48

[    0.000000] Using CHRP machine description
[    0.000000] Total memory = 512MB; using 1024kB for hash table (at cff00000)
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-6-powerpc ([email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.56-1+deb8u1 (2018-05-08)
[    0.000000] Found initrd at 0xc15a2000:0xc1b0b90d
[    0.000000] chrp type = 6 [Genesi Pegasos]

Are you using this same vmlinuz-chrp.initrd?

$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

If so then probably there's something with your QEMU installation.

Regards,
BALATON Zoltan

#38 lore raw
Quoted 10 lines · BALATON Zoltan

Trying to read invalid spr 1012 (0x3f4) at 00000000c0013f48
[    0.000000] Using CHRP machine description
[    0.000000] Total memory = 512MB; using 1024kB for hash table (at cff00000)
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-6-powerpc (debian- [email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.56-1+deb8u1 (2018-05-08) [    0.000000] Found initrd at 0xc15a2000:0xc1b0b90d
[    0.000000] chrp type = 6 [Genesi Pegasos]

Quoted 4 lines

Are you using this same vmlinuz-chrp.initrd?

$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

Yes, md5sum is same as you mentioned:

yogi@fedora:~/work/images$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

Could you please share your Qemu configure command line?
I can try one more time if that's different than mine.
I used below configure command line:
'../configure' '--target-list=ppc64-softmmu,ppc-softmmu' '--enable-virtfs'

Regards,
Yogesh Vyas

Quoted 2 lines

If so then probably there's something with your QEMU installation.

#39 lore raw
Quoted 16 lines · Yogesh Vyas
Quoted 10 lines · BALATON Zoltan

Trying to read invalid spr 1012 (0x3f4) at 00000000c0013f48
[    0.000000] Using CHRP machine description
[    0.000000] Total memory = 512MB; using 1024kB for hash table (at cff00000)
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-6-powerpc (debian- [email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.56-1+deb8u1 (2018-05-08) [    0.000000] Found initrd at 0xc15a2000:0xc1b0b90d
[    0.000000] chrp type = 6 [Genesi Pegasos]

Quoted 4 lines

Are you using this same vmlinuz-chrp.initrd?

$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd
Quoted 8 lines

Yes, md5sum is same as you mentioned:

yogi@fedora:~/work/images$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

Could you please share your Qemu configure command line?
I can try one more time if that's different than mine.
I used below configure command line:
'../configure' '--target-list=ppc64-softmmu,ppc-softmmu' '--enable-virtfs'

I don't see how configure options could have anyhing to do with that but I've tested that this works on my machine:

configure --disable-download --disable-tools --target-list=ppc64-softmmu
qemu-system-ppc64 -M pegasos2 -serial stdio -kernel vmlinuz-chrp.initrd -append "---" -cdrom debian-8.11.0-powerpc-netinst.iso

The configure options are just to only compile what's needed but it should work anyway with your or any options too as long as qemu-system-ppc or qemu-system-ppc64 is compiled. Can you test on a different machine?

Regards,
BALATON Zoltan

#40 lore raw
Quoted 26 lines · BALATON Zoltan
Quoted 16 lines · Yogesh Vyas
Quoted 10 lines · BALATON Zoltan

Trying to read invalid spr 1012 (0x3f4) at 00000000c0013f48
[    0.000000] Using CHRP machine description
[    0.000000] Total memory = 512MB; using 1024kB for hash table (at cff00000)
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-6-powerpc (debian- [email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.56-1+deb8u1 (2018-05-08) [    0.000000] Found initrd at 0xc15a2000:0xc1b0b90d
[    0.000000] chrp type = 6 [Genesi Pegasos]

Quoted 4 lines

Are you using this same vmlinuz-chrp.initrd?

$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd
Quoted 8 lines

Yes, md5sum is same as you mentioned:

yogi@fedora:~/work/images$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

Could you please share your Qemu configure command line?
I can try one more time if that's different than mine.
I used below configure command line:
'../configure' '--target-list=ppc64-softmmu,ppc-softmmu' '--enable-virtfs'

Quoted 7 lines

I don't see how configure options could have anyhing to do with that but I've tested that this works on my machine:

configure --disable-download --disable-tools --target-list=ppc64-softmmu qemu-system-ppc64 -M pegasos2 -serial stdio -kernel vmlinuz-chrp.initrd -append "---" -cdrom debian-8.11.0-powerpc-netinst.iso

The configure options are just to only compile what's needed but it should work anyway with your or any options too as long as qemu-system-ppc or qemu-system-ppc64 is compiled. Can you test on a different machine?

Someone else reported a possible regression maybe related to this patch too but I could not reproduce that either. Can you check what configure says about FDT and if you're using some external FDT library? I've tested with the internal fdt included with QEMU which works and also with libfdt 1.6.1 from my distro that also had no problems. I have no better idea what else could cause it than maybe some issue with some external libfdt version.

Regards,
BALATON Zoltan

#41 lore raw
Quoted 29 lines · BALATON Zoltan
Quoted 28 lines · BALATON Zoltan
Quoted 16 lines · Yogesh Vyas
Quoted 10 lines · BALATON Zoltan

Trying to read invalid spr 1012 (0x3f4) at 00000000c0013f48
[    0.000000] Using CHRP machine description
[    0.000000] Total memory = 512MB; using 1024kB for hash table (at cff00000)
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
[    0.000000] Linux version 3.16.0-6-powerpc (debian- [email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 Debian 3.16.56-1+deb8u1 (2018-05-08) [    0.000000] Found initrd at 0xc15a2000:0xc1b0b90d
[    0.000000] chrp type = 6 [Genesi Pegasos]

Quoted 4 lines

Are you using this same vmlinuz-chrp.initrd?

$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd
Quoted 8 lines

Yes, md5sum is same as you mentioned:

yogi@fedora:~/work/images$ md5sum vmlinuz-chrp.initrd
a440d76c1d2ccfa86bdff6dba017cf39  vmlinuz-chrp.initrd

Could you please share your Qemu configure command line?
I can try one more time if that's different than mine.
I used below configure command line:
'../configure' '--target-list=ppc64-softmmu,ppc-softmmu' '--enable-virtfs'

I don't see how configure options could have anyhing to do with that but I've tested that this works on my machine:

Quoted 7 lines
Quoted 5 lines

configure --disable-download --disable-tools --target-list=ppc64-softmmu qemu-system-ppc64 -M pegasos2 -serial stdio -kernel vmlinuz-chrp.initrd -append "---" -cdrom debian-8.11.0-powerpc-netinst.iso

The configure options are just to only compile what's needed but it should work anyway with your or any options too as long as qemu-system-ppc or qemu-system-ppc64 is compiled. Can you test on a different machine?

Someone else reported a possible regression maybe related to this patch too

Debugging with the other person reporting similar issue I think I've found the problem and this patch should fix it:
https://patchew.org/QEMU/[email protected]/
Can you test please?

Regards,
BALATON Zoltan