mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
arm/mpu: Provide and populate MPU C data structures
Modify Arm32 assembly boot code to reset any unused MPU region, initialise
'max_mpu_regions' with the number of supported MPU regions and set/clear the
bitmap 'xen_mpumap_mask' used to track the enabled regions.
Introduce cache.S to hold arm32 cache related functions.
Use the macro definition for "dcache_line_size" from linux.
Change the order of registers in prepare_xen_region() as 'strd' instruction
is used to store {prbar, prlar} in arm32. Thus, 'prbar' has to be a even
numbered register and 'prlar' is the consecutively ordered register.
Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
This commit is contained in:
1 parent
b84be0ff09
commit
3c63d6b330
5 files changed
+84
-9
No files matched your search
@@ -2,6 +2,7 @@ obj-y += lib/
|
||||
obj-$(CONFIG_MMU) += mmu/
|
||||
obj-$(CONFIG_MPU) += mpu/
|
||||
|
||||
obj-y += cache.o
|
||||
obj-$(CONFIG_EARLY_PRINTK) += debug.o
|
||||
obj-y += domctl.o
|
||||
obj-y += domain.o
|
||||
|
||||
@@ -75,6 +75,12 @@ void __dummy__(void)
|
||||
|
||||
OFFSET(INITINFO_stack, struct init_info, stack);
|
||||
BLANK();
|
||||
|
||||
#ifdef CONFIG_MPU
|
||||
DEFINE(XEN_MPUMAP_MASK_sizeof, sizeof(xen_mpumap_mask));
|
||||
DEFINE(XEN_MPUMAP_sizeof, sizeof(xen_mpumap));
|
||||
BLANK();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/* Cache maintenance */
|
||||
|
||||
#include <asm/arm32/sysregs.h>
|
||||
|
||||
/* dcache_line_size - get the minimum D-cache line size from the CTR register */
|
||||
.macro dcache_line_size, reg, tmp
|
||||
mrc CP32(\tmp, CTR) /* read ctr */
|
||||
lsr \tmp, \tmp, #16
|
||||
and \tmp, \tmp, #0xf /* cache line size encoding */
|
||||
mov \reg, #4 /* bytes per word */
|
||||
mov \reg, \reg, lsl \tmp /* actual cache line size */
|
||||
.endm
|
||||
|
||||
/*
|
||||
* __invalidate_dcache_area(addr, size)
|
||||
*
|
||||
* Ensure that the data held in the cache for the buffer is invalidated.
|
||||
*
|
||||
* - addr - start address of the buffer
|
||||
* - size - size of the buffer
|
||||
*
|
||||
* Clobbers r0 - r3
|
||||
*/
|
||||
FUNC(__invalidate_dcache_area)
|
||||
dcache_line_size r2, r3
|
||||
add r1, r0, r1
|
||||
sub r3, r2, #1
|
||||
bic r0, r0, r3
|
||||
1: mcr CP32(r0, DCIMVAC) /* invalidate D line / unified line */
|
||||
add r0, r0, r2
|
||||
cmp r0, r1
|
||||
blo 1b
|
||||
dsb sy
|
||||
ret
|
||||
END(__invalidate_dcache_area)
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: ASM
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*/
|
||||
@@ -46,43 +46,68 @@ END(enable_mpu)
|
||||
*/
|
||||
FUNC(enable_boot_cpu_mm)
|
||||
/* Get the number of regions specified in MPUIR_EL2 */
|
||||
mrc CP32(r5, MPUIR_EL2)
|
||||
and r5, r5, #NUM_MPU_REGIONS_MASK
|
||||
mrc CP32(r3, MPUIR_EL2)
|
||||
and r3, r3, #NUM_MPU_REGIONS_MASK
|
||||
|
||||
mov_w r0, max_mpu_regions
|
||||
str r3, [r0]
|
||||
mcr CP32(r0, DCIMVAC) /* Invalidate cache for max_mpu_regions addr */
|
||||
|
||||
/* x0: region sel */
|
||||
mov r0, #0
|
||||
/* Xen text section. */
|
||||
mov_w r1, _stext
|
||||
mov_w r2, _etext
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5, attr_prbar=REGION_TEXT_PRBAR
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3, attr_prbar=REGION_TEXT_PRBAR
|
||||
|
||||
/* Xen read-only data section. */
|
||||
mov_w r1, _srodata
|
||||
mov_w r2, _erodata
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5, attr_prbar=REGION_RO_PRBAR
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3, attr_prbar=REGION_RO_PRBAR
|
||||
|
||||
/* Xen read-only after init and data section. (RW data) */
|
||||
mov_w r1, __ro_after_init_start
|
||||
mov_w r2, __init_begin
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3
|
||||
|
||||
/* Xen code section. */
|
||||
mov_w r1, __init_begin
|
||||
mov_w r2, __init_data_begin
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5, attr_prbar=REGION_TEXT_PRBAR
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3, attr_prbar=REGION_TEXT_PRBAR
|
||||
|
||||
/* Xen data and BSS section. */
|
||||
mov_w r1, __init_data_begin
|
||||
mov_w r2, __bss_end
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3
|
||||
|
||||
#ifdef CONFIG_EARLY_PRINTK
|
||||
/* Xen early UART section. */
|
||||
mov_w r1, CONFIG_EARLY_UART_BASE_ADDRESS
|
||||
mov_w r2, (CONFIG_EARLY_UART_BASE_ADDRESS + CONFIG_EARLY_UART_SIZE)
|
||||
prepare_xen_region r0, r1, r2, r3, r4, r5, attr_prbar=REGION_DEVICE_PRBAR, attr_prlar=REGION_DEVICE_PRLAR
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3, attr_prbar=REGION_DEVICE_PRBAR, attr_prlar=REGION_DEVICE_PRLAR
|
||||
#endif
|
||||
|
||||
zero_mpu:
|
||||
/* Reset remaining MPU regions */
|
||||
cmp r0, r3
|
||||
beq out_zero_mpu
|
||||
mov r1, #0
|
||||
mov r2, #1
|
||||
prepare_xen_region r0, r1, r2, r4, r5, r3, attr_prlar=REGION_DISABLED_PRLAR
|
||||
b zero_mpu
|
||||
|
||||
out_zero_mpu:
|
||||
/* Invalidate data cache for MPU data structures */
|
||||
mov r4, lr
|
||||
mov_w r0, xen_mpumap_mask
|
||||
mov r1, #XEN_MPUMAP_MASK_sizeof
|
||||
bl __invalidate_dcache_area
|
||||
|
||||
ldr r0, =xen_mpumap
|
||||
mov r1, #XEN_MPUMAP_sizeof
|
||||
bl __invalidate_dcache_area
|
||||
mov lr, r4
|
||||
|
||||
b enable_mpu
|
||||
END(enable_boot_cpu_mm)
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#define XEN_MPUMAP_ENTRY_SHIFT 0x3 /* 8 byte structure */
|
||||
|
||||
.macro store_pair reg1, reg2, dst
|
||||
.word 0xe7f000f0 /* unimplemented */
|
||||
strd \reg1, \reg2, [\dst]
|
||||
.endm
|
||||
|
||||
#endif
|
||||
|
||||