diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index ed92eb67cb..15b2e4a227 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -23,6 +23,16 @@ config ARCH_DEFCONFIG default "arch/arm/configs/arm32_defconfig" if ARM_32 default "arch/arm/configs/arm64_defconfig" if ARM_64 +config XEN_START_ADDRESS + hex "Xen start address: keep default to use platform defined address" + default 0xFFFFFFFF + depends on MPU + help + Used to set customized address at which which Xen will be linked on MPU + systems. Must be aligned to 4KB. + 0xFFFFFFFF is used as default value to indicate that user has not + customized this address. + menu "Architecture Features" choice diff --git a/xen/arch/arm/arm64/Makefile b/xen/arch/arm/arm64/Makefile index 72161ff22e..6491c5350b 100644 --- a/xen/arch/arm/arm64/Makefile +++ b/xen/arch/arm/arm64/Makefile @@ -1,5 +1,6 @@ obj-y += lib/ obj-$(CONFIG_MMU) += mmu/ +obj-$(CONFIG_MPU) += mpu/ obj-y += cache.o obj-y += cpufeature.o diff --git a/xen/arch/arm/arm64/mpu/Makefile b/xen/arch/arm/arm64/mpu/Makefile new file mode 100644 index 0000000000..b18cec4836 --- /dev/null +++ b/xen/arch/arm/arm64/mpu/Makefile @@ -0,0 +1 @@ +obj-y += mm.o diff --git a/xen/arch/arm/arm64/mpu/mm.c b/xen/arch/arm/arm64/mpu/mm.c new file mode 100644 index 0000000000..0b8748e575 --- /dev/null +++ b/xen/arch/arm/arm64/mpu/mm.c @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +static void __init __maybe_unused build_assertions(void) +{ + /* + * Unlike MMU, MPU does not use pages for translation. However, we continue + * to use PAGE_SIZE to denote 4KB. This is so that the existing memory + * management based on pages, continue to work for now. + */ + BUILD_BUG_ON(PAGE_SIZE != SZ_4K); +} diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h index a2e22b659d..0a51142efd 100644 --- a/xen/arch/arm/include/asm/config.h +++ b/xen/arch/arm/include/asm/config.h @@ -69,8 +69,10 @@ #include #include -#ifdef CONFIG_MMU +#if defined(CONFIG_MMU) #include +#elif defined(CONFIG_MPU) +#include #else # error "Unknown memory management layout" #endif diff --git a/xen/arch/arm/include/asm/mpu/layout.h b/xen/arch/arm/include/asm/mpu/layout.h new file mode 100644 index 0000000000..d6d397f4c2 --- /dev/null +++ b/xen/arch/arm/include/asm/mpu/layout.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ARM_MPU_LAYOUT_H__ +#define __ARM_MPU_LAYOUT_H__ + +#define XEN_START_ADDRESS CONFIG_XEN_START_ADDRESS + +/* + * All MPU platforms need to provide a XEN_START_ADDRESS for linker. This + * address indicates where Xen image will be loaded and run from. This + * address must be aligned to a PAGE_SIZE. + */ +#if (XEN_START_ADDRESS % PAGE_SIZE) != 0 +#error "XEN_START_ADDRESS must be aligned to 4KB" +#endif + +/* + * For MPU, XEN's virtual start address is same as the physical address. + * The reason being MPU treats VA == PA. IOW, it cannot map the physical + * address to a different fixed virtual address. So, the virtual start + * address is determined by the physical address at which Xen is loaded. + */ +#define XEN_VIRT_START _AT(paddr_t, XEN_START_ADDRESS) + +#endif /* __ARM_MPU_LAYOUT_H__ */ +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S index 5b9abc9a2d..d1e579e8a8 100644 --- a/xen/arch/arm/xen.lds.S +++ b/xen/arch/arm/xen.lds.S @@ -213,6 +213,13 @@ SECTIONS * match the context. */ ASSERT(_start == XEN_VIRT_START, "_start != XEN_VIRT_START") +#ifdef CONFIG_MPU +/* + * On MPU based platforms, the starting address is to be provided by user. + * One need to check that it is 4KB aligned. + */ +ASSERT(IS_ALIGNED(_start, 4096), "starting address should be aligned to 4KB") +#endif /* * We require that Xen is loaded at a page boundary, so this ensures that any