|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] xen/arm: mpu: Enable MPU
commit 5423a08eae391e781a457fa2b819431ab36f85bd
Author: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
AuthorDate: Mon Nov 18 12:12:49 2024 +0000
Commit: Julien Grall <jgrall@xxxxxxxxxx>
CommitDate: Mon Dec 2 18:28:54 2024 +0000
xen/arm: mpu: Enable MPU
After the regions have been created, now we enable the MPU. For this we
disable
the background region so that the new memory map created for the regions
take
effect. Also, we treat all RW regions as non executable and the data cache
is
enabled.
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
xen/arch/arm/arm64/mpu/head.S | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/xen/arch/arm/arm64/mpu/head.S b/xen/arch/arm/arm64/mpu/head.S
index a06589566f..bacf8315f9 100644
--- a/xen/arch/arm/arm64/mpu/head.S
+++ b/xen/arch/arm/arm64/mpu/head.S
@@ -5,6 +5,9 @@
#include <asm/arm64/mpu.h>
+/* Backgroud region enable/disable */
+#define SCTLR_ELx_BR BIT(17, UL)
+
#define REGION_TEXT_PRBAR 0x38 /* SH=11 AP=10 XN=00 */
#define REGION_RO_PRBAR 0x3A /* SH=11 AP=10 XN=10 */
#define REGION_DATA_PRBAR 0x32 /* SH=11 AP=00 XN=10 */
@@ -75,6 +78,29 @@ FUNC_LOCAL(fail_insufficient_regions)
b 1b
END(fail_insufficient_regions)
+/*
+ * Enable EL2 MPU and data cache
+ * If the Background region is enabled, then the MPU uses the default memory
+ * map as the Background region for generating the memory
+ * attributes when MPU is disabled.
+ * Since the default memory map of the Armv8-R AArch64 architecture is
+ * IMPLEMENTATION DEFINED, we intend to turn off the Background region here.
+ *
+ * Clobbers x0
+ *
+ */
+FUNC_LOCAL(enable_mpu)
+ mrs x0, SCTLR_EL2
+ bic x0, x0, #SCTLR_ELx_BR /* Disable Background region */
+ orr x0, x0, #SCTLR_Axx_ELx_M /* Enable MPU */
+ orr x0, x0, #SCTLR_Axx_ELx_C /* Enable D-cache */
+ orr x0, x0, #SCTLR_Axx_ELx_WXN /* Enable WXN */
+ msr SCTLR_EL2, x0
+ isb
+
+ ret
+END(enable_mpu)
+
/*
* Maps the various sections of Xen (described in xen.lds.S) as different MPU
* regions.
@@ -114,6 +140,7 @@ FUNC(enable_boot_cpu_mm)
ldr x2, =__bss_end
prepare_xen_region x0, x1, x2, x3, x4, x5
+ b enable_mpu
ret
END(enable_boot_cpu_mm)
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |