Skip to contentSkip to conversation

hw/hppa/machine: Restrict the total memory size to 3GB

PATCH In review Philippe Mathieu-Daudé 3 participants 7 messages Jan 9, 2020 – Jan 17, 2020

lore
Share & tools
lore
#0 lore raw

v2 cover hw/hppa/machine: Restrict the total memory size to 3GB

Following the discussion of Igor's patch "hppa: allow max ram size upto 4Gb" [1] I tried to simplify the current code so Igor's series doesn't change the CLI with this machine.

v2: Simplify by limiting to 3GB (Helge review)

[1] https://www.mail-archive.com/[email protected]/msg667903.html
[2] https://www.mail-archive.com/[email protected]/msg669309.html

Philippe Mathieu-Daudé (3):
hw/hppa/machine: Correctly check the firmware is in PDC range hw/hppa/machine: Restrict the total memory size to 3GB hw/hppa/machine: Map the PDC memory region with higher priority

 hw/hppa/machine.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

PATCH v2 1/3 hw/hppa/machine: Correctly check the firmware is in PDC range

The firmware has to reside in the PDC range. If the Elf file expects to load it below FIRMWARE_START, it is incorrect, regardless the RAM size.

---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/hppa/machine.c +1 -1
index 5d0de26140..6775d879f8 100644
@@ -155,7 +155,7 @@ static void machine_hppa_init(MachineState *machine)
     qemu_log_mask(CPU_LOG_PAGE, "Firmware loaded at 0x%08" PRIx64
                   "-0x%08" PRIx64 ", entry at 0x%08" PRIx64 ".\n",
                   firmware_low, firmware_high, firmware_entry);
-    if (firmware_low < ram_size || firmware_high >= FIRMWARE_END) {
+    if (firmware_low < FIRMWARE_START || firmware_high >= FIRMWARE_END) {
         error_report("Firmware overlaps with memory or IO space");
         exit(1);
     }
Signature · 1 line
2.21.1
#2 lore raw

PATCH v2 2/3 hw/hppa/machine: Restrict the total memory size to 3GB

In reply to Philippe Mathieu-Daudé

The hardware expects DIMM slots of 1 or 2 GB, allowing up to 4 GB of memory. We want to accept the same amount of memory the hardware can deal with. DIMMs of 768MB are not available.

However we have to deal with a firmware limitation: currently SeaBIOS only supports 32-bit, and expects the RAM size in a 32-bit register. When using a 4GB configuration, the 32-bit register get truncated and we report a size of 0MB to SeaBIOS, which ends halting the machine:

  $ qemu-system-hppa -m 4g -serial stdio

SeaBIOS: Machine configured with too little memory (0 MB), minimum is 16 MB.

SeaBIOS wants SYSTEM HALT.

The easiest way is to restrict the machine to 3GB of memory.

---
 hw/hppa/machine.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/hppa/machine.c +4 -5
index 6775d879f8..119ae4d3c8 100644
@@ -90,12 +90,11 @@ static void machine_hppa_init(MachineState *machine)
         g_free(name);
     }
 
-    /* Limit main memory. */
-    if (ram_size > FIRMWARE_START) {
-        machine->ram_size = ram_size = FIRMWARE_START;
-    }
-
     /* Main memory region. */
+    if (machine->ram_size > 3 * GiB) {
+        error_report("RAM size is currently restricted to 3GB");
+        exit(EXIT_FAILURE);
+    }
     ram_region = g_new(MemoryRegion, 1);
     memory_region_allocate_system_memory(ram_region, OBJECT(machine),
                                          "ram", ram_size);
Signature · 1 line
2.21.1
#3 lore raw

PATCH v2 3/3 hw/hppa/machine: Map the PDC memory region with higher priority

In reply to Philippe Mathieu-Daudé

The region in range [0xf0000000 - 0xf1000000] is the PDC area (Processor Dependent Code), where the firmware is loaded. This region has higher priority than the main memory.

When the machine has more than 3840MB of RAM, there is an overlap. Since the PDC is closer to the CPU in the bus hierarchy, it gets accessed first, and the CPU does not have access to the RAM in this range.

To model the same behavior and keep a simple memory layout, reduce the priority of the RAM region. The PDC region ends overlapping the RAM.

---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/hppa/machine.c +1 -1
index 119ae4d3c8..810e6718d9 100644
@@ -98,7 +98,7 @@ static void machine_hppa_init(MachineState *machine)
     ram_region = g_new(MemoryRegion, 1);
     memory_region_allocate_system_memory(ram_region, OBJECT(machine),
                                          "ram", ram_size);
-    memory_region_add_subregion(addr_space, 0, ram_region);
+    memory_region_add_subregion_overlap(addr_space, 0, ram_region, -1);
 
     /* Init Dino (PCI host bus chip).  */
     pci_bus = dino_init(addr_space, &rtc_irq, &serial_irq);
Signature · 1 line
2.21.1
#6 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 10 lines · Philippe Mathieu-Daudé

Following the discussion of Igor's patch "hppa: allow max ram size upto 4Gb" [1] I tried to simplify the current code so Igor's series doesn't change the CLI with this machine.

v2: Simplify by limiting to 3GB (Helge review)

[1] https://www.mail-archive.com/[email protected]/msg667903.html
[2] https://www.mail-archive.com/[email protected]/msg669309.html

Quoted 8 lines

Philippe Mathieu-Daudé (3):
hw/hppa/machine: Correctly check the firmware is in PDC range hw/hppa/machine: Restrict the total memory size to 3GB hw/hppa/machine: Map the PDC memory region with higher priority

 hw/hppa/machine.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

Queued.

r~