All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB
@ 2020-01-09  0:05 Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 1/3] hw/hppa/machine: Correctly check the firmware is in PDC range Philippe Mathieu-Daudé
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-09  0:05 UTC (permalink / raw)
  To: Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel
  Cc: Philippe Mathieu-Daudé, Richard Henderson

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/qemu-devel@nongnu.org/msg667903.html
[2] https://www.mail-archive.com/qemu-devel@nongnu.org/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(-)

-- 
2.21.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] hw/hppa/machine: Correctly check the firmware is in PDC range
  2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
@ 2020-01-09  0:05 ` Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 2/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-09  0:05 UTC (permalink / raw)
  To: Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel
  Cc: Philippe Mathieu-Daudé, Richard Henderson

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.

Acked-by: Helge Deller <deller@gmx.de>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 5d0de26140..6775d879f8 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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);
     }
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] hw/hppa/machine: Restrict the total memory size to 3GB
  2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 1/3] hw/hppa/machine: Correctly check the firmware is in PDC range Philippe Mathieu-Daudé
@ 2020-01-09  0:05 ` Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 3/3] hw/hppa/machine: Map the PDC memory region with higher priority Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-09  0:05 UTC (permalink / raw)
  To: Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel
  Cc: Philippe Mathieu-Daudé, Richard Henderson

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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/hppa/machine.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 6775d879f8..119ae4d3c8 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] hw/hppa/machine: Map the PDC memory region with higher priority
  2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 1/3] hw/hppa/machine: Correctly check the firmware is in PDC range Philippe Mathieu-Daudé
  2020-01-09  0:05 ` [PATCH v2 2/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
@ 2020-01-09  0:05 ` Philippe Mathieu-Daudé
  2020-01-09  2:20 ` [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Richard Henderson
  2020-01-17  1:03 ` Richard Henderson
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-09  0:05 UTC (permalink / raw)
  To: Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel
  Cc: Philippe Mathieu-Daudé, Richard Henderson

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.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/hppa/machine.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index 119ae4d3c8..810e6718d9 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -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);
-- 
2.21.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB
  2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2020-01-09  0:05 ` [PATCH v2 3/3] hw/hppa/machine: Map the PDC memory region with higher priority Philippe Mathieu-Daudé
@ 2020-01-09  2:20 ` Richard Henderson
  2020-01-09  6:48   ` Helge Deller
  2020-01-17  1:03 ` Richard Henderson
  4 siblings, 1 reply; 7+ messages in thread
From: Richard Henderson @ 2020-01-09  2:20 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel
  Cc: Richard Henderson

On 1/9/20 11:05 AM, Philippe Mathieu-Daudé wrote:
> 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

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB
  2020-01-09  2:20 ` [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Richard Henderson
@ 2020-01-09  6:48   ` Helge Deller
  0 siblings, 0 replies; 7+ messages in thread
From: Helge Deller @ 2020-01-09  6:48 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Igor Mammedov, Sven Schnelle, qemu-devel
  Cc: Richard Henderson, Richard Henderson

On 09.01.20 03:20, Richard Henderson wrote:
> On 1/9/20 11:05 AM, Philippe Mathieu-Daudé wrote:
>> 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
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

Acked-by: Helge Deller <deller@gmx.de>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB
  2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2020-01-09  2:20 ` [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Richard Henderson
@ 2020-01-17  1:03 ` Richard Henderson
  4 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2020-01-17  1:03 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé,
	Igor Mammedov, Helge Deller, Sven Schnelle, qemu-devel

On 1/8/20 2:05 PM, Philippe Mathieu-Daudé wrote:
> 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/qemu-devel@nongnu.org/msg667903.html
> [2] https://www.mail-archive.com/qemu-devel@nongnu.org/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(-)
> 

Queued.


r~


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-17  1:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  0:05 [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
2020-01-09  0:05 ` [PATCH v2 1/3] hw/hppa/machine: Correctly check the firmware is in PDC range Philippe Mathieu-Daudé
2020-01-09  0:05 ` [PATCH v2 2/3] hw/hppa/machine: Restrict the total memory size to 3GB Philippe Mathieu-Daudé
2020-01-09  0:05 ` [PATCH v2 3/3] hw/hppa/machine: Map the PDC memory region with higher priority Philippe Mathieu-Daudé
2020-01-09  2:20 ` [PATCH v2 0/3] hw/hppa/machine: Restrict the total memory size to 3GB Richard Henderson
2020-01-09  6:48   ` Helge Deller
2020-01-17  1:03 ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.