Skip to contentSkip to conversation

Enable early bootup of AArch32 MPU systems (pre-requisite patches)

PATCH Superseded Ayan Kumar Halder 4 participants 8 messages Mar 4, 2025 – Mar 5, 2025

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Enable early bootup of AArch32 MPU systems (pre-requisite patches)

Hi,

I have extracted patches 1, 2 from "https://patchew.org/Xen/[email protected]/" as it will introduce the common files on which the following can be based :-
1. "[PATCH 0/9] First chunk for Arm R82 and MPU support"
2. "Enable early bootup of AArch32 MPU systems" (patches 3-5)

Ayan Kumar Halder (2):
xen/arm: mpu: Move some of the definitions to common file xen/arm: mpu: Ensure that the page size is 4KB

 xen/arch/arm/Makefile                      | 1 +
 xen/arch/arm/arm64/mpu/Makefile            | 1 -
 xen/arch/arm/arm64/mpu/head.S              | 2 +-
 xen/arch/arm/include/asm/early_printk.h    | 2 +-
 xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
 xen/arch/arm/mpu/Makefile                  | 1 +
 xen/arch/arm/{arm64 => }/mpu/mm.c          | 0
 7 files changed, 7 insertions(+), 6 deletions(-)
 rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)
 create mode 100644 xen/arch/arm/mpu/Makefile
 rename xen/arch/arm/{arm64 => }/mpu/mm.c (100%)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 xen/arm: mpu: Move some of the definitions to common file

For AArch32, refer to ARM DDI 0568A.c ID110520. MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR). Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64 (HMPUIR).

---
Changes from

v1 - 1. Add the R-b.

 xen/arch/arm/arm64/mpu/head.S              | 2 +-
 xen/arch/arm/include/asm/early_printk.h    | 2 +-
 xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
 rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)
xen/arch/arm/arm64/mpu/head.S +1 -1
index e4f2021f45..7b659aa42b 100644
@@ -3,7 +3,7 @@
  * Start-of-day code for an Armv8-R MPU system.
  */
 
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/early_printk.h>
 
 /* Backgroud region enable/disable */
xen/arch/arm/include/asm/early_printk.h +1 -1
index 219705a8b6..644fd0fcfb 100644
@@ -11,7 +11,7 @@
 #define __ARM_EARLY_PRINTK_H__
 
 #include <xen/page-size.h>
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/fixmap.h>
 
 #ifdef CONFIG_EARLY_PRINTK
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +3 -3
similarity index 87%
rename from xen/arch/arm/include/asm/arm64/mpu.h
rename to xen/arch/arm/include/asm/mpu.h
index f8a029f1a1..40fa6eaaca 100644
@@ -3,8 +3,8 @@
  * mpu.h: Arm Memory Protection Unit definitions.
  */
 
-#ifndef __ARM64_MPU_H__
-#define __ARM64_MPU_H__
+#ifndef __ARM_MPU_H__
+#define __ARM_MPU_H__
 
 #define MPU_REGION_SHIFT  6
 #define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)
@@ -13,7 +13,7 @@
 #define NUM_MPU_REGIONS_SHIFT   8
 #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
 #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
-#endif /* __ARM64_MPU_H__ */
+#endif /* __ARM_MPU_H__ */
 
 /*
  * Local variables:
Signature · 1 line
2.25.1
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] xen/arm: mpu: Move some of the definitions to common file

Quoted 23 lines · Ayan Kumar Halder

For AArch32, refer to ARM DDI 0568A.c ID110520. MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR). Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64 (HMPUIR).

---
Changes from

v1 - 1. Add the R-b.

 xen/arch/arm/arm64/mpu/head.S              | 2 +-
 xen/arch/arm/include/asm/early_printk.h    | 2 +-
 xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)
 rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)
xen/arch/arm/arm64/mpu/head.S +0 -0
index e4f2021f45..7b659aa42b 100644

xen/arch/arm/arm64/mpu/head.S line 7

Quoted 6 lines
xen/arch/arm/arm64/mpu/head.S +1 -1
@@ -3,7 +3,7 @@
  * Start-of-day code for an Armv8-R MPU system.
  */
 
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/early_printk.h>

These should be sorted alphabetically

xen/arch/arm/include/asm/early_printk.h line 15

Quoted 13 lines
xen/arch/arm/arm64/mpu/head.S +0 -0
 /* Backgroud region enable/disable */
xen/arch/arm/include/asm/early_printk.h +1 -1
index 219705a8b6..644fd0fcfb 100644
@@ -11,7 +11,7 @@
 #define __ARM_EARLY_PRINTK_H__
 
 #include <xen/page-size.h>
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
 #include <asm/fixmap.h>

These should be sorted alphabetically

Quoted 21 lines
xen/arch/arm/include/asm/early_printk.h +0 -0
 #ifdef CONFIG_EARLY_PRINTK
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +2 -2
similarity index 87%
rename from xen/arch/arm/include/asm/arm64/mpu.h
rename to xen/arch/arm/include/asm/mpu.h
index f8a029f1a1..40fa6eaaca 100644
@@ -3,8 +3,8 @@
  * mpu.h: Arm Memory Protection Unit definitions.
  */
 
-#ifndef __ARM64_MPU_H__
-#define __ARM64_MPU_H__
+#ifndef __ARM_MPU_H__
+#define __ARM_MPU_H__
 
 #define MPU_REGION_SHIFT  6
 #define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)

xen/arch/arm/include/asm/mpu.h line 16

Quoted 5 lines
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +1 -1
@@ -13,7 +13,7 @@
 #define NUM_MPU_REGIONS_SHIFT   8
 #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
 #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
-#endif /* __ARM64_MPU_H__ */
+#endif /* __ARM_MPU_H__ */

Would you mind adding extra line between last definition and #endif?

With that:

~Michal

#3 lore raw

Re: [PATCH v2 1/2] xen/arm: mpu: Move some of the definitions to common file

Hi Michal

Quoted 42 lines · Michal
Quoted 23 lines · Ayan Kumar Halder

For AArch32, refer to ARM DDI 0568A.c ID110520. MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR). Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64 (HMPUIR).

---
Changes from

v1 - 1. Add the R-b.

  xen/arch/arm/arm64/mpu/head.S              | 2 +-
  xen/arch/arm/include/asm/early_printk.h    | 2 +-
  xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
  3 files changed, 5 insertions(+), 5 deletions(-)

rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)

xen/arch/arm/arm64/mpu/head.S +0 -0
index e4f2021f45..7b659aa42b 100644

xen/arch/arm/arm64/mpu/head.S line 7

Quoted 6 lines
xen/arch/arm/arm64/mpu/head.S +1 -1
@@ -3,7 +3,7 @@
   * Start-of-day code for an Armv8-R MPU system.
   */
 
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
  #include <asm/early_printk.h>

These should be sorted alphabetically

Quoted 9 lines
xen/arch/arm/arm64/mpu/head.S +0 -0
  /* Backgroud region enable/disable */
xen/arch/arm/include/asm/early_printk.h +0 -0
index 219705a8b6..644fd0fcfb 100644
@@ -11,7 +11,7 @@
  #define __ARM_EARLY_PRINTK_H__
 
Quoted 5 lines

xen/arch/arm/include/asm/early_printk.h line 15

Quoted 4 lines
xen/arch/arm/include/asm/early_printk.h +1 -1
  #include <xen/page-size.h>
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
  #include <asm/fixmap.h>

These should be sorted alphabetically

This and ..

Quoted 19 lines
Quoted 19 lines
xen/arch/arm/include/asm/early_printk.h +0 -0
  #ifdef CONFIG_EARLY_PRINTK
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +2 -2
similarity index 87%
rename from xen/arch/arm/include/asm/arm64/mpu.h
rename to xen/arch/arm/include/asm/mpu.h
index f8a029f1a1..40fa6eaaca 100644
@@ -3,8 +3,8 @@
   * mpu.h: Arm Memory Protection Unit definitions.
   */
 
-#ifndef __ARM64_MPU_H__
-#define __ARM64_MPU_H__
+#ifndef __ARM_MPU_H__
+#define __ARM_MPU_H__
 
Quoted 9 lines

xen/arch/arm/include/asm/mpu.h line 16

Quoted 8 lines
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +1 -1
  #define MPU_REGION_SHIFT  6
  #define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)
@@ -13,7 +13,7 @@
  #define NUM_MPU_REGIONS_SHIFT   8
  #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
  #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
-#endif /* __ARM64_MPU_H__ */
+#endif /* __ARM_MPU_H__ */

Would you mind adding extra line between last definition and #endif?

this, can you fix them on commit, please ? Or do you want me to send a v3.

I am fine either way.

Quoted 3 lines

With that:

- Ayan

Quoted 3 lines

~Michal

#4 lore raw

Re: [PATCH v2 1/2] xen/arm: mpu: Move some of the definitions to common file

Quoted 80 lines · Ayan Kumar Halder

Hi Michal

Quoted 42 lines · Michal
Quoted 23 lines · Ayan Kumar Halder

For AArch32, refer to ARM DDI 0568A.c ID110520. MPU_REGION_SHIFT is same between AArch32 and AArch64 (HPRBAR). Also, NUM_MPU_REGIONS_SHIFT is same between AArch32 and AArch64 (HMPUIR).

---
Changes from

v1 - 1. Add the R-b.

  xen/arch/arm/arm64/mpu/head.S              | 2 +-
  xen/arch/arm/include/asm/early_printk.h    | 2 +-
  xen/arch/arm/include/asm/{arm64 => }/mpu.h | 6 +++---
  3 files changed, 5 insertions(+), 5 deletions(-)

rename xen/arch/arm/include/asm/{arm64 => }/mpu.h (87%)

xen/arch/arm/arm64/mpu/head.S +0 -0
index e4f2021f45..7b659aa42b 100644

xen/arch/arm/arm64/mpu/head.S line 7

Quoted 6 lines
xen/arch/arm/arm64/mpu/head.S +1 -1
@@ -3,7 +3,7 @@
   * Start-of-day code for an Armv8-R MPU system.
   */
 
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
  #include <asm/early_printk.h>

These should be sorted alphabetically

Quoted 9 lines
xen/arch/arm/arm64/mpu/head.S +0 -0
  /* Backgroud region enable/disable */
xen/arch/arm/include/asm/early_printk.h +0 -0
index 219705a8b6..644fd0fcfb 100644
@@ -11,7 +11,7 @@
  #define __ARM_EARLY_PRINTK_H__
 
Quoted 5 lines

xen/arch/arm/include/asm/early_printk.h line 15

Quoted 4 lines
xen/arch/arm/include/asm/early_printk.h +1 -1
  #include <xen/page-size.h>
-#include <asm/arm64/mpu.h>
+#include <asm/mpu.h>
  #include <asm/fixmap.h>

These should be sorted alphabetically

This and ..

Quoted 19 lines
Quoted 19 lines
xen/arch/arm/include/asm/early_printk.h +0 -0
  #ifdef CONFIG_EARLY_PRINTK
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +2 -2
similarity index 87%
rename from xen/arch/arm/include/asm/arm64/mpu.h
rename to xen/arch/arm/include/asm/mpu.h
index f8a029f1a1..40fa6eaaca 100644
@@ -3,8 +3,8 @@
   * mpu.h: Arm Memory Protection Unit definitions.
   */
 
-#ifndef __ARM64_MPU_H__
-#define __ARM64_MPU_H__
+#ifndef __ARM_MPU_H__
+#define __ARM_MPU_H__
 
Quoted 9 lines

xen/arch/arm/include/asm/mpu.h line 16

Quoted 8 lines
xen/arch/arm/include/asm/mpu.h renamed from xen/arch/arm/include/asm/arm64/mpu.h +1 -1
  #define MPU_REGION_SHIFT  6
  #define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)
@@ -13,7 +13,7 @@
  #define NUM_MPU_REGIONS_SHIFT   8
  #define NUM_MPU_REGIONS         (_AC(1, UL) << NUM_MPU_REGIONS_SHIFT)
  #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
-#endif /* __ARM64_MPU_H__ */
+#endif /* __ARM_MPU_H__ */

Would you mind adding extra line between last definition and #endif?

Quoted 1 line

this, can you fix them on commit, please ? Or do you want me to send a v3.

If I end up committing this patch (I can do that tomorrow), then I can do these changes on commit.

~Michal

#5 lore raw

PATCH v2 2/2 xen/arm: mpu: Ensure that the page size is 4KB

In reply to Ayan Kumar Halder

Similar to commit (d736b6eb451b, "xen/arm: mpu: Define Xen start address for MPU systems"), one needs to add a build assertion to ensure that the page size is 4KB on arm32 based systems as well.
The existing build assertion is moved under "xen/arch/arm/mpu" as it applies for both arm64 and arm32 based systems.

---
Changes from :-

v1 - 1. Extracted the changes to a common file. (I have dropped Luca's R-b as there were code changes.)

 xen/arch/arm/Makefile             | 1 +
 xen/arch/arm/arm64/mpu/Makefile   | 1 -
 xen/arch/arm/mpu/Makefile         | 1 +
 xen/arch/arm/{arm64 => }/mpu/mm.c | 0
 4 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 xen/arch/arm/mpu/Makefile
 rename xen/arch/arm/{arm64 => }/mpu/mm.c (100%)
xen/arch/arm/Makefile +1 -0
index 43ab5e8f25..fb0948f067 100644
@@ -1,6 +1,7 @@
 obj-$(CONFIG_ARM_32) += arm32/
 obj-$(CONFIG_ARM_64) += arm64/
 obj-$(CONFIG_MMU) += mmu/
+obj-$(CONFIG_MPU) += mpu/
 obj-$(CONFIG_ACPI) += acpi/
 obj-$(CONFIG_HAS_PCI) += pci/
 ifneq ($(CONFIG_NO_PLAT),y)
xen/arch/arm/arm64/mpu/Makefile +0 -1
index a8a750a3d0..3340058c08 100644
@@ -1,2 +1 @@
 obj-y += head.o
-obj-y += mm.o
xen/arch/arm/mpu/Makefile new file +1 -0
new file mode 100644
index 0000000000..b18cec4836
@@ -0,0 +1 @@
+obj-y += mm.o
xen/arch/arm/mpu/mm.c renamed from xen/arch/arm/arm64/mpu/mm.c +0 -0
similarity index 100%
rename from xen/arch/arm/arm64/mpu/mm.c
rename to xen/arch/arm/mpu/mm.c
Signature · 1 line
2.25.1
Acked-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] xen/arm: mpu: Ensure that the page size is 4KB

Quoted 7 lines · Ayan Kumar Halder

Similar to commit (d736b6eb451b, "xen/arm: mpu: Define Xen start address for MPU systems"), one needs to add a build assertion to ensure that the page size is 4KB on arm32 based systems as well.
The existing build assertion is moved under "xen/arch/arm/mpu" as it applies for both arm64 and arm32 based systems.

~Michal

Reviewed-by on v2 2/2
#7 lore raw

Re: [PATCH v2 2/2] xen/arm: mpu: Ensure that the page size is 4KB

In reply to Ayan Kumar Halder

Hi Ayan,

Quoted 10 lines · Ayan Kumar Halder

Similar to commit (d736b6eb451b, "xen/arm: mpu: Define Xen start address for MPU systems"), one needs to add a build assertion to ensure that the page size is 4KB on arm32 based systems as well.
The existing build assertion is moved under "xen/arch/arm/mpu" as it applies for both arm64 and arm32 based systems.

---