Skip to contentSkip to conversation

hw/arm/cubieboard: correct CPU type and add machine argument checks

PATCH Applied Niek Linnenbank 3 participants 15 messages Feb 27, 2020 – Mar 2, 2020

lore
Share & tools
lore
#0 lore raw

cover hw/arm/cubieboard: correct CPU type and add machine argument checks

These patches change the Cubieboard machine definition to use the correct CPU type, which is ARM Cortex-A8 instead of ARM Cortex-A9.

Additionally, add some sanity checks for the machine input arguments in the initialization function.

Niek Linnenbank (4):
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine
definition
hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8 hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB hw/arm/cubieboard: report error when using unsupported -bios argument

 hw/arm/cubieboard.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition

The Cubieboard is a singleboard computer with an Allwinner A10 System-on-Chip [1]. As documented in the Allwinner A10 User Manual V1.5 [2], the SoC has an ARM Cortex-A8 processor. Currently the Cubieboard machine definition specifies the ARM Cortex-A9 in its description and as the default CPU.

This patch corrects the Cubieboard machine definition to use the ARM Cortex-A8.

[1] http://docs.cubieboard.org/products/start#cubieboard1
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

---
 hw/arm/cubieboard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/cubieboard.c +2 -2
index 089f9a30c1..0195925c73 100644
@@ -68,8 +68,8 @@ static void cubieboard_init(MachineState *machine)
 
 static void cubieboard_machine_init(MachineClass *mc)
 {
-    mc->desc = "cubietech cubieboard (Cortex-A9)";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+    mc->desc = "cubietech cubieboard (Cortex-A8)";
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
     mc->init = cubieboard_init;
     mc->block_default_type = IF_IDE;
     mc->units_per_default_bus = 1;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH v1 1/4] hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition

Quoted 21 lines · Niek Linnenbank

The Cubieboard is a singleboard computer with an Allwinner A10 System-on-Chip [1]. As documented in the Allwinner A10 User Manual V1.5 [2], the SoC has an ARM Cortex-A8 processor. Currently the Cubieboard machine definition specifies the ARM Cortex-A9 in its description and as the default CPU.

This patch corrects the Cubieboard machine definition to use the ARM Cortex-A8.

[1] http://docs.cubieboard.org/products/start#cubieboard1
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

---
 hw/arm/cubieboard.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/cubieboard.c +0 -0
index 089f9a30c1..0195925c73 100644

hw/arm/cubieboard.c static void cubieboard_init(MachineState *machine) · line 75

Quoted 10 lines
hw/arm/cubieboard.c +2 -2
@@ -68,8 +68,8 @@ static void cubieboard_init(MachineState *machine)
 
 static void cubieboard_machine_init(MachineClass *mc)
 {
-    mc->desc = "cubietech cubieboard (Cortex-A9)";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+    mc->desc = "cubietech cubieboard (Cortex-A8)";
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
     mc->init = cubieboard_init;
     mc->block_default_type = IF_IDE;
     mc->units_per_default_bus = 1;

This is worth fixing, but I'm pretty sure it doesn't have any user-visible effects, because the CPU is created by hw/arm/allwinner-a10.c:aw_a10_init(), which always uses cortex-a8 regardless of what the user specified on the command line or what the mc->default_cpu_type is.

Fixes 8a863c8120994981a099

if you tweak the commit message to mention that it wasn't a user-visible bug (but I'll do that myself if there isn't anything else in the series that means it needs a respin).

thanks
-- PMM

#3 lore raw

Re: [PATCH v1 1/4] hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine definition

Quoted 23 lines · Peter Maydell
Quoted 22 lines · Niek Linnenbank

The Cubieboard is a singleboard computer with an Allwinner A10 System-on-Chip [1]. As documented in the Allwinner A10 User Manual V1.5 [2], the SoC has an ARM Cortex-A8 processor. Currently the Cubieboard machine definition specifies the ARM Cortex-A9 in its description and as the default CPU.

This patch corrects the Cubieboard machine definition to use the ARM Cortex-A8.

[1] http://docs.cubieboard.org/products/start#cubieboard1
[2] https://linux-sunxi.org/File:Allwinner_A10_User_manual_V1.5.pdf

---
  hw/arm/cubieboard.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/cubieboard.c +0 -0
index 089f9a30c1..0195925c73 100644
@@ -68,8 +68,8 @@ static void cubieboard_init(MachineState *machine)
 
Quoted 15 lines

hw/arm/cubieboard.c static void cubieboard_init(MachineState *machine) · line 75

Quoted 9 lines
hw/arm/cubieboard.c +2 -2
  static void cubieboard_machine_init(MachineClass *mc)
  {
-    mc->desc = "cubietech cubieboard (Cortex-A9)";
-    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9");
+    mc->desc = "cubietech cubieboard (Cortex-A8)";
+    mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
      mc->init = cubieboard_init;
      mc->block_default_type = IF_IDE;
      mc->units_per_default_bus = 1;

This is worth fixing, but I'm pretty sure it doesn't have any user-visible effects, because the CPU is created by hw/arm/allwinner-a10.c:aw_a10_init(), which always uses cortex-a8 regardless of what the user specified on the command line or what the mc->default_cpu_type is.

It is worth fixing if we continue the MachineClass code cleanup Igor wants (moving the ram size / cpu type checks in the machine common code).

Quoted 11 lines
Fixes 8a863c8120994981a099

if you tweak the commit message to mention that it wasn't a user-visible bug (but I'll do that myself if there isn't anything else in the series that means it needs a respin).

thanks
-- PMM

#4 lore raw

PATCH 2/4 hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8

In reply to Niek Linnenbank

The Cubieboard has an ARM Cortex-A8. Prevent changing the CPU to a different type which could break user programs.

---
 hw/arm/cubieboard.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
hw/arm/cubieboard.c +9 -1
index 0195925c73..010375f0a8 100644
@@ -30,9 +30,17 @@ static struct arm_boot_info cubieboard_binfo = {
 
 static void cubieboard_init(MachineState *machine)
 {
-    AwA10State *a10 = AW_A10(object_new(TYPE_AW_A10));
+    AwA10State *a10;
     Error *err = NULL;
 
+    /* Only allow Cortex-A8 for this board */
+    if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) {
+        error_report("This board can only be used with cortex-a8 CPU");
+        exit(1);
+    }
+
+    a10 = AW_A10(object_new(TYPE_AW_A10));
+
     object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't set phy address: ");
Signature · 1 line
2.17.1
Reviewed-by on v1 2/4
#5 lore raw

Re: [PATCH v1 2/4] hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8

Quoted 22 lines · Niek Linnenbank

The Cubieboard has an ARM Cortex-A8. Prevent changing the CPU to a different type which could break user programs.

---
 hw/arm/cubieboard.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
hw/arm/cubieboard.c +2 -1
index 0195925c73..010375f0a8 100644
@@ -30,9 +30,17 @@ static struct arm_boot_info cubieboard_binfo = {
 
 static void cubieboard_init(MachineState *machine)
 {
-    AwA10State *a10 = AW_A10(object_new(TYPE_AW_A10));
+    AwA10State *a10;
     Error *err = NULL;
 
+    /* Only allow Cortex-A8 for this board */

hw/arm/cubieboard.c static struct arm_boot_info cubieboard_binfo = { · line 46

Quoted 10 lines
hw/arm/cubieboard.c +7 -0
+    if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) {
+        error_report("This board can only be used with cortex-a8 CPU");
+        exit(1);
+    }
+
+    a10 = AW_A10(object_new(TYPE_AW_A10));
+
     object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't set phy address: ");

except that we're not preventing the user changing the CPU type, we're just giving a helpful error message instead of ignoring the bogus -cpu option.

thanks
-- PMM

#6 lore raw

PATCH 3/4 hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB

In reply to Niek Linnenbank

The Cubieboard contains either 512MiB or 1GiB of onboard RAM [1]. Prevent changing RAM to a different size which could break user programs.

[1] http://linux-sunxi.org/Cubieboard

---
 hw/arm/cubieboard.c | 8 ++++++++
 1 file changed, 8 insertions(+)
hw/arm/cubieboard.c +8 -0
index 010375f0a8..6c55d9056f 100644
@@ -33,6 +33,13 @@ static void cubieboard_init(MachineState *machine)
     AwA10State *a10;
     Error *err = NULL;
 
+    /* This board has fixed size RAM (512MiB or 1GiB) */
+    if (machine->ram_size != 512 * MiB &&
+        machine->ram_size != 1 * GiB) {
+        error_report("This machine can only be used with 512MiB or 1GiB RAM");
+        exit(1);
+    }
+
     /* Only allow Cortex-A8 for this board */
     if (strcmp(machine->cpu_type, ARM_CPU_TYPE_NAME("cortex-a8")) != 0) {
         error_report("This board can only be used with cortex-a8 CPU");
@@ -78,6 +85,7 @@ static void cubieboard_machine_init(MachineClass *mc)
 {
     mc->desc = "cubietech cubieboard (Cortex-A8)";
     mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a8");
+    mc->default_ram_size = 1 * GiB;
     mc->init = cubieboard_init;
     mc->block_default_type = IF_IDE;
     mc->units_per_default_bus = 1;
Signature · 1 line
2.17.1
#8 lore raw

PATCH 4/4 hw/arm/cubieboard: report error when using unsupported -bios argument

In reply to Niek Linnenbank

The Cubieboard machine does not support the -bios argument. Report an error when -bios is used and exit immediately.

---
 hw/arm/cubieboard.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/arm/cubieboard.c +7 -0
index 6c55d9056f..871b1beef4 100644
@@ -19,6 +19,7 @@
 #include "exec/address-spaces.h"
 #include "qapi/error.h"
 #include "cpu.h"
+#include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
 #include "hw/boards.h"
 #include "hw/arm/allwinner-a10.h"
@@ -33,6 +34,12 @@ static void cubieboard_init(MachineState *machine)
     AwA10State *a10;
     Error *err = NULL;
 
+    /* BIOS is not supported by this board */
+    if (bios_name) {
+        error_report("BIOS not supported for this machine");
+        exit(1);
+    }
+
     /* This board has fixed size RAM (512MiB or 1GiB) */
     if (machine->ram_size != 512 * MiB &&
         machine->ram_size != 1 * GiB) {
Signature · 1 line
2.17.1
Reviewed-by on v1 4/4
#9 lore raw

Re: [PATCH v1 4/4] hw/arm/cubieboard: report error when using unsupported -bios argument

Quoted 22 lines · Niek Linnenbank

The Cubieboard machine does not support the -bios argument. Report an error when -bios is used and exit immediately.

---
 hw/arm/cubieboard.c | 7 +++++++
 1 file changed, 7 insertions(+)
hw/arm/cubieboard.c +1 -0
index 6c55d9056f..871b1beef4 100644
@@ -19,6 +19,7 @@
 #include "exec/address-spaces.h"
 #include "qapi/error.h"
 #include "cpu.h"
+#include "sysemu/sysemu.h"
 #include "hw/sysbus.h"
 #include "hw/boards.h"
 #include "hw/arm/allwinner-a10.h"

hw/arm/cubieboard.c static void cubieboard_init(MachineState *machine) · line 41

Quoted 8 lines
hw/arm/cubieboard.c +5 -0
@@ -33,6 +34,12 @@ static void cubieboard_init(MachineState *machine)
     AwA10State *a10;
     Error *err = NULL;
 
+    /* BIOS is not supported by this board */
+    if (bios_name) {
+        error_report("BIOS not supported for this machine");
+        exit(1);
+    }

We don't usually bother to check this, but I guess there's no reason not to.

thanks
-- PMM

#10 lore raw

Re: [PATCH v1 4/4] hw/arm/cubieboard: report error when using unsupported -bios argument

Quoted 26 lines · Peter Maydell
Quoted 25 lines · Niek Linnenbank

The Cubieboard machine does not support the -bios argument. Report an error when -bios is used and exit immediately.

---
  hw/arm/cubieboard.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/arm/cubieboard.c +1 -0
index 6c55d9056f..871b1beef4 100644
@@ -19,6 +19,7 @@
  #include "exec/address-spaces.h"
  #include "qapi/error.h"
  #include "cpu.h"
+#include "sysemu/sysemu.h"
  #include "hw/sysbus.h"
  #include "hw/boards.h"
  #include "hw/arm/allwinner-a10.h"
@@ -33,6 +34,12 @@ static void cubieboard_init(MachineState *machine)
      AwA10State *a10;
      Error *err = NULL;
 
Quoted 8 lines

hw/arm/cubieboard.c static void cubieboard_init(MachineState *machine) · line 41

Quoted 5 lines
hw/arm/cubieboard.c +5 -0
+    /* BIOS is not supported by this board */
+    if (bios_name) {
+        error_report("BIOS not supported for this machine");
+        exit(1);
+    }

We don't usually bother to check this, but I guess there's no reason not to.

I agree this is confusing to expect the machine boot from a flash when using -bios and having to debug until figuring out the reason.

This -bios is a generic machine option, maybe we could move this check to the common machine code.

Quoted 6 lines

thanks
-- PMM

#11 lore raw

Re: [PATCH v1 4/4] hw/arm/cubieboard: report error when using unsupported -bios argument

Hi Philippe,

Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 1 line · Peter Maydell

On Thu, 27 Feb 2020 at 22:02, Niek Linnenbank <[email protected]>

Quoted 25 lines · wrote:
Quoted 25 lines

The Cubieboard machine does not support the -bios argument. Report an error when -bios is used and exit immediately.

---
  hw/arm/cubieboard.c | 7 +++++++
  1 file changed, 7 insertions(+)
hw/arm/cubieboard.c +1 -0
index 6c55d9056f..871b1beef4 100644
@@ -19,6 +19,7 @@
  #include "exec/address-spaces.h"
  #include "qapi/error.h"
  #include "cpu.h"
+#include "sysemu/sysemu.h"
  #include "hw/sysbus.h"
  #include "hw/boards.h"
  #include "hw/arm/allwinner-a10.h"
@@ -33,6 +34,12 @@ static void cubieboard_init(MachineState *machine)
      AwA10State *a10;
      Error *err = NULL;
 
Quoted 8 lines

hw/arm/cubieboard.c static void cubieboard_init(MachineState *machine) · line 41

Quoted 5 lines
hw/arm/cubieboard.c +5 -0
+    /* BIOS is not supported by this board */
+    if (bios_name) {
+        error_report("BIOS not supported for this machine");
+        exit(1);
+    }

We don't usually bother to check this, but I guess there's no reason not to.

Quoted 6 lines

I agree this is confusing to expect the machine boot from a flash when using -bios and having to debug until figuring out the reason.

This -bios is a generic machine option, maybe we could move this check to the common machine code.

Agreed, that sounds logical indeed.

When we have a common machine code/class I presume that boards which do support the -bios
option could simply set somekind of flag/field to enable the -bios functionality. And for boards
which do not support it, the common machine code would then by default give an error and exit.

Regards,
Niek

Quoted 8 lines
Quoted 6 lines

thanks
-- PMM

Signature · 1 line
Niek Linnenbank
#12 lore raw
In reply to Niek Linnenbank
Quoted 7 lines · Niek Linnenbank

These patches change the Cubieboard machine definition to use the correct CPU type, which is ARM Cortex-A8 instead of ARM Cortex-A9.

Additionally, add some sanity checks for the machine input arguments in the initialization function.

Quoted 6 lines

Niek Linnenbank (4):
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine
definition
hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8 hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB hw/arm/cubieboard: report error when using unsupported -bios argument

Applied to target-arm.next, thanks. (I tweaked a couple of commit messages as mentioned in replies to those patches.)

-- PMM

#13 lore raw

Hi Peter, Philippe,

Quoted 17 lines · Peter Maydell
Quoted 7 lines · Niek Linnenbank

These patches change the Cubieboard machine definition to use the correct CPU type, which is ARM Cortex-A8 instead of ARM Cortex-A9.

Additionally, add some sanity checks for the machine input arguments in the initialization function.

Quoted 6 lines

Niek Linnenbank (4):
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine
definition
hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8 hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB hw/arm/cubieboard: report error when using unsupported -bios argument

Quoted 3 lines

Applied to target-arm.next, thanks. (I tweaked a couple of commit messages as mentioned in replies to those patches.)

Great, and thanks for your quick and detailed responses Peter.

And to be clear, these improvements came from the excellent reviews done by Philippe on the Allwinner H3 patch series
which I submitted earlier. Since that series is quite big and will take more time to complete, I thought it would be nice
to take a few of those improvements and meanwhile apply them to the other similar boards as well.

Regards,
Niek

Quoted 3 lines

-- PMM

Signature · 1 line
Niek Linnenbank
Reviewed-by on the v1 series
#14 lore raw
In reply to Niek Linnenbank
Quoted 13 lines · Niek Linnenbank

These patches change the Cubieboard machine definition to use the correct CPU type, which is ARM Cortex-A8 instead of ARM Cortex-A9.

Additionally, add some sanity checks for the machine input arguments in the initialization function.

Niek Linnenbank (4):
hw/arm/cubieboard: use ARM Cortex-A8 as the default CPU in machine
definition
hw/arm/cubieboard: restrict allowed CPU type to ARM Cortex-A8 hw/arm/cubieboard: restrict allowed RAM size to 512MiB and 1GiB hw/arm/cubieboard: report error when using unsupported -bios argument

Quoted 3 lines
  hw/arm/cubieboard.c | 29 ++++++++++++++++++++++++++---
  1 file changed, 26 insertions(+), 3 deletions(-)

Series: