Skip to contentSkip to conversation

hw/sparc/sun4m: Limit max_mem to what the memory controllers decode

PATCH New Imre Kaloz 1 participant 3 messages Nov 4

lore
Share & tools
lore

Imre Kaloz

author
#0 lore raw

v2 cover hw/sparc/sun4m: Limit max_mem to what the memory controllers decode

The SS-10, SS-20 and SPARCserver 600MP accept -m up to 60 GiB, and the LX, SS-4, SPARCclassic, SPARCbook and Voyager 256 MiB, more than their memory controllers decode. Above 4 GiB the sparc32 OpenBIOS reads only the low 32 bits of the fw_cfg RAM size, so -m 5120 boots as -m 1024.

Patch 1 ends the empty slot for missing RAM at iommu_base instead of at max_mem, which does not change the layout today. Patch 2 lowers max_mem on each machine to the memory its controller decodes.

Changes in v2:
- Split the empty slot change out of the limits patch, as requested by Mark Cave-Ayland.
- Kept Philippe Mathieu-Daudé's Reviewed-by on both patches.
- No code change.

v1: https://lore.kernel.org/r/[email protected]

Imre Kaloz (2):
hw/sparc/sun4m: End the empty slot at iommu_base hw/sparc/sun4m: Limit max_mem to what the memory controllers decode

 docs/system/target-sparc.rst |  6 ++++--
 hw/sparc/sun4m.c             | 24 ++++++++++++++----------
 2 files changed, 18 insertions(+), 12 deletions(-)

base-commit: 1c1f512972b25229d4b69ae7a3a7e5d7df30a6a6

Signature · 1 line
2.47.3
author
#1 lore raw

PATCH v2 1/2 hw/sparc/sun4m: End the empty slot at iommu_base

Memory decode on machines without ECC ends at iommu_base, so the empty slot for missing RAM should end there. max_mem equals iommu_base on these machines today, so nothing changes, but a later patch lowers max_mem.

---
 hw/sparc/sun4m.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/sparc/sun4m.c +5 -2
index 550acdff6d..2f4eb19f7f 100644
@@ -840,10 +840,13 @@ static void sun4m_hw_init(MachineState *machine)
     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0);
 
-    /* models without ECC don't trap when missing ram is accessed */
+    /*
+     * models without ECC don't trap when missing ram is accessed,
+     * up to the end of memory decode at iommu_base
+     */
     if (!hwdef->ecc_base) {
         empty_slot_init("ecc", machine->ram_size,
-                        hwdef->max_mem - machine->ram_size);
+                        hwdef->iommu_base - machine->ram_size);
     }
 
     prom_init(hwdef->slavio_base, machine->firmware);
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH v2 2/2 hw/sparc/sun4m: Limit max_mem to what the memory controllers decode

In reply to Imre Kaloz

Limit max_mem on each machine to what its memory controller decodes, instead of the former 60 GiB or 256 MiB, and update the docs. The Voyager default RAM size becomes 80 MiB so -M Voyager without -m still starts.

---
 docs/system/target-sparc.rst |  6 ++++--
 hw/sparc/sun4m.c             | 17 +++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)
docs/system/target-sparc.rst +4 -2
index 4116cac493..de0acc76dc 100644
@@ -52,8 +52,10 @@ QEMU emulates the following sun4m peripherals:
 -  CS4231 sound device (only on SS-5, not working yet)
 
 The number of peripherals is fixed in the architecture. Maximum memory
-size depends on the machine type, for SS-5 it is 256MB and for others
-2047MB.
+size depends on the machine type: 512 MiB for the SS-10 and SS-20,
+256 MiB for the SS-5, 160 MiB for the SS-4, 128 MiB for the LX,
+SPARCclassic and SPARCbook, 80 MiB for the Voyager, and 1 GiB for the
+SPARCserver 600MP.
 
 Since version 0.8.2, QEMU uses OpenBIOS https://www.openbios.org/.
 OpenBIOS is a free (GPL v2) portable firmware implementation. The goal
hw/sparc/sun4m.c +9 -8
index 2f4eb19f7f..c586b1c44e 100644
@@ -1177,7 +1177,7 @@ static void ss10_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x72,
         .machine_id = ss10_id,
         .iommu_version = 0x03000000,
-        .max_mem = 0xf00000000ULL,
+        .max_mem = 0x20000000, /* 512M: EMC has 29 DRAM address bits */
     };
 
     mc->desc = "Sun4m platform, SPARCstation 10";
@@ -1210,7 +1210,7 @@ static void ss600mp_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x71,
         .machine_id = ss600mp_id,
         .iommu_version = 0x01000000,
-        .max_mem = 0xf00000000ULL,
+        .max_mem = 0x40000000, /* 1G: onboard plus expansion boards */
     };
 
     mc->desc = "Sun4m platform, SPARCserver 600MP";
@@ -1261,7 +1261,7 @@ static void ss20_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x72,
         .machine_id = ss20_id,
         .iommu_version = 0x13000000,
-        .max_mem = 0xf00000000ULL,
+        .max_mem = 0x20000000, /* 512M: SMC has 29 DRAM address bits */
     };
 
     mc->desc = "Sun4m platform, SPARCstation 20";
@@ -1294,11 +1294,12 @@ static void voyager_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x80,
         .machine_id = vger_id,
         .iommu_version = 0x05000000,
-        .max_mem = 0x10000000,
+        .max_mem = 0x05000000, /* 80M: 16M onboard plus two 32M cards */
     };
 
     mc->desc = "Sun4m platform, SPARCstation Voyager";
     mc->default_cpu_type = SPARC_CPU_TYPE_NAME("Fujitsu-MB86904");
+    mc->default_ram_size = 80 * MiB;
     smc->hwdef = &voyager_hwdef;
 }
 
@@ -1327,7 +1328,7 @@ static void ss_lx_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x80,
         .machine_id = lx_id,
         .iommu_version = 0x04000000,
-        .max_mem = 0x10000000,
+        .max_mem = 0x08000000, /* 128M: microSPARC-I on-chip controller */
     };
 
     mc->desc = "Sun4m platform, SPARCstation LX";
@@ -1360,7 +1361,7 @@ static void ss4_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x80,
         .machine_id = ss4_id,
         .iommu_version = 0x05000000,
-        .max_mem = 0x10000000,
+        .max_mem = 0x0a000000, /* 160M: 5 SIMM slots */
     };
 
     mc->desc = "Sun4m platform, SPARCstation 4";
@@ -1392,7 +1393,7 @@ static void scls_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x80,
         .machine_id = scls_id,
         .iommu_version = 0x05000000,
-        .max_mem = 0x10000000,
+        .max_mem = 0x08000000, /* 128M: microSPARC-I on-chip controller */
     };
 
     mc->desc = "Sun4m platform, SPARCClassic";
@@ -1424,7 +1425,7 @@ static void sbook_class_init(ObjectClass *oc, const void *data)
         .nvram_machine_id = 0x80,
         .machine_id = sbook_id,
         .iommu_version = 0x05000000,
-        .max_mem = 0x10000000,
+        .max_mem = 0x08000000, /* 128M: microSPARC-I on-chip controller */
     };
 
     mc->desc = "Sun4m platform, SPARCbook";
Signature · 1 line
2.47.3