Enable early bootup of AArch64 MPU systems (Part 2)
v3 cover Enable early bootup of AArch64 MPU systems (Part 2)
This patch serie concludes earlyboot support for Arm-v8R AArch64 MPU systems.
Ayan Kumar Halder (1):
xen/mpu: Map early uart when earlyprintk on
Penny Zheng (1):
xen/mmu: enable SMMU subsystem only in MMU
xen/arch/arm/Kconfig | 4 ++-- xen/arch/arm/Kconfig.debug | 7 +++++++ xen/arch/arm/arm64/mpu/head.S | 10 +++++++++ xen/arch/arm/include/asm/early_printk.h | 28 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 xen/mpu: Map early uart when earlyprintk on
CONFIG_EARLY_UART_SIZE is introduced to let user provide physical size of early UART. Unlike MMU where we map a page in the virtual address space, here we need to know the exact physical size to be mapped.
As VA == PA in case of MPU, the memory layout follows exactly the hardware configuration. As a consequence, we set EARLY_UART_VIRTUAL_ADDRESS as physical address.
EARLY_UART_BASE_ADDRESS and EARLY_UART_SIZE should be aligned to the minimum size of MPU region (ie 64 bits) as per the hardware restrictions. Refer ARM DDI 0600A.d ID120821 A1.3 "A minimum protection region size of 64 bytes.".
UART is mapped as nGnRE region (as specified by ATTR=100 , refer G1.3.13, MAIR_EL2, "---0100 Device memory nGnRE"). Also, it is mapped as outer shareable, RW at EL2 only and execution of instructions from the region is not permitted.
---
Changes from :-
v1 - 1. UART base address and size should be aligned to the minimum size of MPU region (and not PAGE_SIZE).
v2 - 1. In early_printk.h, included <asm/arm64/mpu.h> and fixed the macro names.
2. Included <asm/early_printk.h> in head.S.
3. Updated the commit message (to remove reference to R82 TRM) and added Luca's R-b.
xen/arch/arm/Kconfig.debug | 7 +++++++ xen/arch/arm/arm64/mpu/head.S | 10 +++++++++ xen/arch/arm/include/asm/early_printk.h | 28 ++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-)
xen/arch/arm/Kconfig.debug +7 -0
@@ -121,6 +121,13 @@ config EARLY_UART_BASE_ADDRESS hex "Early printk, physical base address of debug UART" range 0x0 0xffffffff if ARM_32 +config EARLY_UART_SIZE + depends on EARLY_PRINTK + depends on MPU + hex "Early printk, physical size of debug UART" + range 0x0 0xffffffff if ARM_32 + default 0x1000 + config EARLY_UART_PL011_BAUD_RATE depends on EARLY_UART_PL011 int "Early printk UART baud rate for pl011"
xen/arch/arm/arm64/mpu/head.S +10 -0
@@ -4,6 +4,7 @@ */ #include <asm/arm64/mpu.h> +#include <asm/early_printk.h> /* Backgroud region enable/disable */ #define SCTLR_ELx_BR BIT(17, UL)
@@ -11,8 +12,10 @@ #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 */ +#define REGION_DEVICE_PRBAR 0x22 /* SH=10 AP=00 XN=10 */ #define REGION_NORMAL_PRLAR 0x0f /* NS=0 ATTR=111 EN=1 */ +#define REGION_DEVICE_PRLAR 0x09 /* NS=0 ATTR=100 EN=1 */ /* * Macro to prepare and set a EL2 MPU memory region.
@@ -140,6 +143,13 @@ FUNC(enable_boot_cpu_mm) ldr x2, =__bss_end prepare_xen_region x0, x1, x2, x3, x4, x5 +#ifdef CONFIG_EARLY_PRINTK + /* Xen early UART section. */ + ldr x1, =CONFIG_EARLY_UART_BASE_ADDRESS + ldr x2, =(CONFIG_EARLY_UART_BASE_ADDRESS + CONFIG_EARLY_UART_SIZE) + prepare_xen_region x0, x1, x2, x3, x4, x5, attr_prbar=REGION_DEVICE_PRBAR, attr_prlar=REGION_DEVICE_PRLAR +#endif + b enable_mpu ret END(enable_boot_cpu_mm)
xen/arch/arm/include/asm/early_printk.h +27 -1
@@ -11,10 +11,33 @@#define __ARM_EARLY_PRINTK_H__#include <xen/page-size.h> +#include <asm/arm64/mpu.h> #include <asm/fixmap.h> #ifdef CONFIG_EARLY_PRINTK +#if defined(CONFIG_MPU ) + +/* +* For MPU systems, there is no VMSA support in EL2, so we use VA == PA +* for EARLY_UART_VIRTUAL_ADDRESS. +*/ +#define EARLY_UART_VIRTUAL_ADDRESS CONFIG_EARLY_UART_BASE_ADDRESS + +/* +* User-defined EARLY_UART_BASE_ADDRESS and EARLY_UART_SIZE must be aligned to +* minimum size of MPU region. +*/ +#if (CONFIG_EARLY_UART_BASE_ADDRESS %MPU_REGION_ALIGN ) !=0 +#error "EARLY_UART_BASE_ADDRESS must be aligned to minimum MPU region size" +#endif + +#if (CONFIG_EARLY_UART_SIZE %MPU_REGION_ALIGN ) !=0 +#error "EARLY_UART_SIZE must be aligned to minimum MPU region size" +#endif + +#elif defined(CONFIG_MMU ) +/* need to add the uart address offset in page to the fixmap address */ #define EARLY_UART_VIRTUAL_ADDRESS \ (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
@@ -22,6 +45,9 @@#define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \ (TEMPORARY_FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK)) -#endif /* !CONFIG_EARLY_PRINTK */ +#else +#error "Unknown Memory management system" +#endif +#endif /* !CONFIG_EARLY_PRINTK */ #endif
Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] xen/mpu: Map early uart when earlyprintk on
Hi Ayan,
Quoted 11 lines · Ayan Kumar Halder
CONFIG_EARLY_UART_SIZEis introduced to let user provide physical size of early UART. Unlike MMU where we map a page in the virtual address space, here we need to know the exact physical size to be mapped.
As VA == PA in case of MPU, the memory layout follows exactly the hardware configuration. As a consequence, we setEARLY_UART_VIRTUAL_ADDRESSas physical address.
EARLY_UART_BASE_ADDRESSandEARLY_UART_SIZEshould be aligned to the minimum size of MPU region (ie 64 bits) as per the hardware restrictions. Refer ARM DDI 0600A.d ID120821 A1.3 "A minimum protection region size of 64 bytes.".
Quoted 6 lines
UART is mapped as nGnRE region (as specified by ATTR=100 , refer G1.3.13,
MAIR_EL2, "---0100 Device memory nGnRE"). Also, it is mapped as outer shareable, RW at EL2 only and execution of instructions from the region is not permitted.Signed-off-by Ayan Kumar Halder <[email protected]>Reviewed-by Luca Fancellu <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH v3 2/2 xen/mmu: enable SMMU subsystem only in MMU
In reply to Ayan Kumar HalderFrom: Penny Zheng <[email protected]>
In Xen, SMMU subsystem is supported for MMU system only. The reason being SMMU driver uses the same page tables as MMU.
Thus, we make it dependent on CONFIG_MMU.
---
Changes from
v1 - 1. HAS_PASSTHROUGH is now enclosed within "config MMU". There was a pending response on
"[PATCH v1 2/2] xen/mmu: enable SMMU subsystem only in MMU" that it might introduce a bunch of #if-defs in arm specific common code. However, there are alternative implementations possible to reduce #if-defs. So, that can be decided at a later point in time and should not block the current patch.
v2 - 1. Added Julien's A-b.
xen/arch/arm/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/Kconfig +2 -2
@@ -15,9 +15,7 @@ config ARM select GENERIC_UART_INIT select HAS_ALTERNATIVE if HAS_VMAP select HAS_DEVICE_TREE - select HAS_PASSTHROUGH select HAS_UBSAN - select IOMMU_FORCE_PT_SHARE config ARCH_DEFCONFIG string
@@ -79,6 +77,8 @@ config MMU bool "MMU" select HAS_PMAP select HAS_VMAP + select HAS_PASSTHROUGH + select IOMMU_FORCE_PT_SHARE help Select it if you plan to run Xen on A-profile Armv7+
Signature · 1 line
2.25.1
Hi Ayan,
Quoted 7 lines · Ayan Kumar Halder
This patch serie concludes earlyboot support for Arm-v8R AArch64 MPU systems.
Ayan Kumar Halder (1):
xen/mpu: Map early uart when earlyprintk onPenny Zheng (1):
xen/mmu: enable SMMU subsystem only in MMU
I have committed this series.
Cheers,
Signature · 1 line
Julien Grall