Skip to contentSkip to conversation

hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions

PATCH In review Peter Maydell 3 participants 4 messages Jun 5, 2025 – Jun 13, 2025 Arm/versatile express platform

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions

The AN500 application note documents that it configures the Cortex-M7 CPU to have 16 MPU regions. We weren't doing this in our emulation, so the CPU had only the default 8 MPU regions. Set the mpu-ns-regions property to 16 for this board.

This bug doesn't affect any of the other board types we model in this source file, because they all use either the Cortex-M3 or Cortex-M4. Those CPUs do not have an RTL configurable number of MPU regions, and always provide 8 regions if the MPU is built in.

---
 hw/arm/mps2.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/mps2.c +4 -0
index 58efb41e6db..50e1a1c1c80 100644
@@ -224,7 +224,11 @@ static void mps2_common_init(MachineState *machine)
     switch (mmc->fpga_type) {
     case FPGA_AN385:
     case FPGA_AN386:
+        qdev_prop_set_uint32(armv7m, "num-irq", 32);
+        break;
     case FPGA_AN500:
+        /* The AN500 configures its Cortex-M7 with 16 MPU regions */
+        qdev_prop_set_uint32(armv7m, "mpu-ns-dregions", 16);
         qdev_prop_set_uint32(armv7m, "num-irq", 32);
         break;
     case FPGA_AN511:
Signature · 1 line
2.43.0
#1 lore raw
Quoted 23 lines · Peter Maydell

The AN500 application note documents that it configures the Cortex-M7 CPU to have 16 MPU regions. We weren't doing this in our emulation, so the CPU had only the default 8 MPU regions. Set the mpu-ns-regions property to 16 for this board.

This bug doesn't affect any of the other board types we model in this source file, because they all use either the Cortex-M3 or Cortex-M4. Those CPUs do not have an RTL configurable number of MPU regions, and always provide 8 regions if the MPU is built in.

---
 hw/arm/mps2.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/mps2.c +0 -0
index 58efb41e6db..50e1a1c1c80 100644

hw/arm/mps2.c static void mps2_common_init(MachineState *machine) · line 231

Quoted 8 lines
hw/arm/mps2.c +4 -0
@@ -224,7 +224,11 @@ static void mps2_common_init(MachineState *machine)
     switch (mmc->fpga_type) {
     case FPGA_AN385:
     case FPGA_AN386:
+        qdev_prop_set_uint32(armv7m, "num-irq", 32);
+        break;
     case FPGA_AN500:
+        /* The AN500 configures its Cortex-M7 with 16 MPU regions */
+        qdev_prop_set_uint32(armv7m, "mpu-ns-dregions", 16);

Rats, I failed to actually refresh the git commit with a fix for a bug that "make check" caught before I sent it out. This should be "mpu-ns-regions", without the "d".

hw/arm/mps2.c static void mps2_common_init(MachineState *machine) · line 234

Quoted 3 lines
hw/arm/mps2.c +0 -0
         qdev_prop_set_uint32(armv7m, "num-irq", 32);
         break;
     case FPGA_AN511:

-- PMM

#2 lore raw

Fixed!

Le jeu. 5 juin 2025 à 16:22, Peter Maydell <[email protected]> a écrit :

Quoted 44 lines
Quoted 23 lines · Peter Maydell

The AN500 application note documents that it configures the Cortex-M7 CPU to have 16 MPU regions. We weren't doing this in our emulation, so the CPU had only the default 8 MPU regions. Set the mpu-ns-regions property to 16 for this board.

This bug doesn't affect any of the other board types we model in this source file, because they all use either the Cortex-M3 or Cortex-M4. Those CPUs do not have an RTL configurable number of MPU regions, and always provide 8 regions if the MPU is built in.

---
 hw/arm/mps2.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/mps2.c +0 -0
index 58efb41e6db..50e1a1c1c80 100644

hw/arm/mps2.c static void mps2_common_init(MachineState *machine) · line 231

Quoted 8 lines
hw/arm/mps2.c +4 -0
@@ -224,7 +224,11 @@ static void mps2_common_init(MachineState *machine)
     switch (mmc->fpga_type) {
     case FPGA_AN385:
     case FPGA_AN386:
+        qdev_prop_set_uint32(armv7m, "num-irq", 32);
+        break;
     case FPGA_AN500:
+        /* The AN500 configures its Cortex-M7 with 16 MPU regions */
+        qdev_prop_set_uint32(armv7m, "mpu-ns-dregions", 16);

Rats, I failed to actually refresh the git commit with a fix for a bug that "make check" caught before I sent it out. This should be "mpu-ns-regions", without the "d".

hw/arm/mps2.c static void mps2_common_init(MachineState *machine) · line 234

Quoted 3 lines
hw/arm/mps2.c +0 -0
         qdev_prop_set_uint32(armv7m, "num-irq", 32);
         break;
     case FPGA_AN511:

-- PMM

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

The AN500 application note documents that it configures the Cortex-M7 CPU to have 16 MPU regions. We weren't doing this in our emulation, so the CPU had only the default 8 MPU regions. Set the mpu-ns-regions property to 16 for this board.

This bug doesn't affect any of the other board types we model in this source file, because they all use either the Cortex-M3 or Cortex-M4. Those CPUs do not have an RTL configurable number of MPU regions, and always provide 8 regions if the MPU is built in.

With the typo fix:

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro