Skip to contentSkip to conversation

hw/arm/raspi: Diagnose requests for too much RAM

PATCH In review Peter Maydell 4 participants 7 messages Mar 28, 2019 – Mar 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 hw/arm/raspi: Diagnose requests for too much RAM

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

 hw/arm/raspi.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/arm/raspi.c +7 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int version)
     BusState *bus;
     DeviceState *carddev;
 
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this machine: "
+                     "maximum is 1GB");
+        exit(1);
+    }
+
     object_initialize(&s->soc, sizeof(s->soc),
                       version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
     object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw

Le jeu. 28 mars 2019 16:29, Peter Maydell <[email protected]> a écrit :

Quoted 10 lines

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

Quoted 9 lines
$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine:
maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

Argh I missed this...

Quoted 33 lines
 hw/arm/raspi.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/arm/raspi.c +7 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qapi/error.h"
 #include "qemu-common.h"
 #include "cpu.h"
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int
 version)
     BusState *bus;
     DeviceState *carddev;
 
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this machine: "
+                     "maximum is 1GB");
+        exit(1);
+    }
+
     object_initialize(&s->soc, sizeof(s->soc),
                       version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
     object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),

--
2.20.1

Reviewed-by on v2 1/1
#2 lore raw
In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)
Quoted 8 lines

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

r~

#3 lore raw
In reply to Peter Maydell
Quoted 34 lines · Peter Maydell

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

  hw/arm/raspi.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/arm/raspi.c +1 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "qemu/units.h"
  #include "qapi/error.h"
  #include "qemu-common.h"
  #include "cpu.h"

hw/arm/raspi.c static void raspi_init(MachineState *machine, int version) · line 181

Quoted 6 lines
hw/arm/raspi.c +3 -0
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int version)
      BusState *bus;
      DeviceState *carddev;
 
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this machine: "
+                     "maximum is 1GB");

1GB vs 1GiB... maybe the message should display "GiB" to avoid any confusion?

Also I was wondering what is need for Patchew to start catching errors like in v1.

- Wainer

Quoted 6 lines
hw/arm/raspi.c +3 -0
+        exit(1);
+    }
+
      object_initialize(&s->soc, sizeof(s->soc),
                        version == 3 ? TYPE_BCM2837 : TYPE_BCM2836);
      object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
#4 lore raw
Quoted 40 lines · Wainer dos Santos Moschetta
Quoted 37 lines · Peter Maydell

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

  hw/arm/raspi.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/arm/raspi.c +1 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
   */
 
  #include "qemu/osdep.h"
+#include "qemu/units.h"
  #include "qapi/error.h"
  #include "qemu-common.h"
  #include "cpu.h"
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int version)
      BusState *bus;
      DeviceState *carddev;
 
Quoted 6 lines

hw/arm/raspi.c static void raspi_init(MachineState *machine, int version) · line 181

Quoted 3 lines
hw/arm/raspi.c +3 -0
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this machine: "
+                     "maximum is 1GB");

1GB vs 1GiB... maybe the message should display "GiB" to avoid any confusion?

I don't know why we call our #defined constant GiB -- to me the unit is GB and I think printing anything else in user messages is weird.

thanks
-- PMM

#5 lore raw

Le ven. 29 mars 2019 10:20, Peter Maydell <[email protected]> a écrit :

Quoted 47 lines
Quoted 7 lines · Wainer dos Santos Moschetta
Quoted 4 lines · Peter Maydell

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

Quoted 8 lines
Quoted 8 lines
$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine:

maximum is 1GB

Quoted 16 lines
Quoted 16 lines

---
Changes v1->v2: use '>', not '>='...

  hw/arm/raspi.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/arm/raspi.c +0 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
   */
 
Quoted 6 lines

hw/arm/raspi.c static void raspi_init(MachineState *machine, int

Quoted 6 lines
hw/arm/raspi.c +1 -0
  #include "qemu/osdep.h"
+#include "qemu/units.h"
  #include "qapi/error.h"
  #include "qemu-common.h"
  #include "cpu.h"
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int

version)

Quoted 5 lines

hw/arm/raspi.c static void raspi_init(MachineState *machine, int version)

Quoted 5 lines
hw/arm/raspi.c +2 -0
      BusState *bus;
      DeviceState *carddev;
 
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this

machine: "

Quoted 9 lines
Quoted 4 lines

hw/arm/raspi.c static void raspi_init(MachineState *machine, int version) · line 181

Quoted 1 line
hw/arm/raspi.c +1 -0
+                     "maximum is 1GB");

1GB vs 1GiB... maybe the message should display "GiB" to avoid any confusion?

I don't know why we call our #defined constant GiB -- to me the unit is GB and I think printing anything else in user messages is weird.

There was a discussion with Stefan and few other in 2017 the outcome was to use the explicit IEC standard (and avoid confusion with 1kHz i.e.).

https://en.m.wikipedia.org/wiki/Kibibyte
"The *kibibyte* is a multiple of the unit byte
<https://en.m.wikipedia.org/wiki/Byte> for quantities of digital information
<https://en.m.wikipedia.org/wiki/Information>. The binary prefix
<https://en.m.wikipedia.org/wiki/Binary_prefix> *kibi
<https://en.m.wikipedia.org/wiki/Kibi->* means 210, or 1024; therefore, 1 kibibyte is 1024 bytes. The unit symbol for the kibibyte is *KiB*."

Quoted 3 lines

thanks
-- PMM

#6 lore raw
In reply to Peter Maydell
Quoted 41 lines · Peter Maydell
Quoted 39 lines · Wainer dos Santos Moschetta
Quoted 37 lines · Peter Maydell

The Raspberry Pi boards have a physical memory map which does not allow for more than 1GB of RAM. Currently if the user tries to ask for more then we fail in a confusing way:

$ qemu-system-aarch64 --machine raspi3 -m 8G
Unexpected error in visit_type_uintN() at qapi/qapi-visit-core.c:164:
qemu-system-aarch64: Parameter 'vcram-base' expects uint32_t
Aborted (core dumped)

Catch this earlier and diagnose it with a more friendly message:

$ qemu-system-aarch64 --machine raspi3 -m 8G
qemu-system-aarch64: Requested ram size is too large for this machine: maximum is 1GB

---
Changes v1->v2: use '>', not '>='...

   hw/arm/raspi.c | 7 +++++++
   1 file changed, 7 insertions(+)
hw/arm/raspi.c +1 -0
index 66899c28dc1..fe2bb511b98 100644
@@ -12,6 +12,7 @@
    */
 
   #include "qemu/osdep.h"
+#include "qemu/units.h"
   #include "qapi/error.h"
   #include "qemu-common.h"
   #include "cpu.h"
@@ -175,6 +176,12 @@ static void raspi_init(MachineState *machine, int version)
       BusState *bus;
       DeviceState *carddev;
 
Quoted 8 lines
Quoted 5 lines

hw/arm/raspi.c static void raspi_init(MachineState *machine, int version) · line 181

Quoted 3 lines
hw/arm/raspi.c +3 -0
+    if (machine->ram_size > 1 * GiB) {
+        error_report("Requested ram size is too large for this machine: "
+                     "maximum is 1GB");

1GB vs 1GiB... maybe the message should display "GiB" to avoid any confusion?

I don't know why we call our #defined constant GiB -- to me the unit is GB and I think printing anything else in user messages is weird.

Ok, I find it weird as well. But I slightly remember that discussion before so I thought in raising it here too.

Quoted 4 lines

thanks
-- PMM