mirrored from git://xenbits.xen.org/xen.git
-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xen/arm: mpu: Define Xen start address for MPU systems
On Armv8-A, Xen has a fixed virtual start address (link address too) for all Armv8-A platforms. In an MMU based system, Xen can map its loaded address to this virtual start address. So, on Armv8-A platforms, the Xen start address does not need to be configurable. But on Armv8-R platforms, there is no MMU to map loaded address to a fixed virtual address and different platforms will have very different address space layout. So Xen cannot use a fixed physical address on MPU based system and need to have it configurable. So, we introduce a Kconfig option for users to set the start address. The start address needs to be aligned to 4KB. We have a check for this alignment. MPU allows us to define regions which are 64 bits aligned. This restriction comes from the bitfields of PRBAR, PRLAR (the lower 6 bits are 0 extended to provide the base and limit address of a region). This means that the start address of Xen needs to be at least 64 bits aligned (as it will correspond to the start address of memory protection region). As for now Xen on MPU tries to use the same memory alignment restrictions as it has been for MMU. We have added a build assertion to ensure that the page size is 4KB. Unlike MMU where the starting virtual address is 2MB, Xen on MPU needs the start address to be 4KB (ie page size) aligned. In case if the user forgets to set the start address, then 0xffffffff is used as default. This is to trigger the error (on alignment check) and thereby prompt user to set the start address. Also updated config.h so that it includes mpu/layout.h when CONFIG_MPU is defined. Signed-off-by: Wei Chen <[email protected]> Signed-off-by: Jiamei.Xie <[email protected]> Signed-off-by: Ayan Kumar Halder <[email protected]> Reviewed-by: Julien Grall <[email protected]> Reviewed-by: Luca Fancellu <[email protected]>
- Loading branch information
Showing
7 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
obj-y += lib/ | ||
obj-$(CONFIG_MMU) += mmu/ | ||
obj-$(CONFIG_MPU) += mpu/ | ||
|
||
obj-y += cache.o | ||
obj-y += cpufeature.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj-y += mm.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#include <xen/lib.h> | ||
#include <xen/init.h> | ||
#include <xen/sizes.h> | ||
|
||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters