From 503eea451903142d08dc664d536738871953557d Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 5 Feb 2021 13:53:36 +0100 Subject: arm: cp15: update DACR value to activate access control Update the initial value of Domain Access Control Register (DACR) and set by default the access permission to client (DACR_Dn_CLIENT = 1U) for each of the 16 domains and no more to all-supervisor (DACR_Dn_MANAGER = 3U). This patch allows to activate the domain checking in MMU against the permission bits in the translation tables and avoids prefetching issue on ARMv7 [1]. Today it was already done for OMAP2 architecture ./arch/arm/mach-omap2/omap-cache.c::arm_init_domains introduced by commit de63ac278cba ("ARM: mmu: Set domain permissions to client access") which fixes lot of speculative prefetch aborts seen on OMAP5 secure devices. [1] https://developer.arm.com/documentation/ddi0406/b/System-Level-Architecture/Virtual-Memory-System-Architecture--VMSA-/Memory-access-control/The-Execute-Never--XN--attribute-and-instruction-prefetching Signed-off-by: Patrick Delaunay Reported-by: Ard Biesheuvel Signed-off-by: Patrick Delaunay --- arch/arm/lib/cache-cp15.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'arch/arm/lib/cache-cp15.c') diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c index 24050e5bdd3..4854c39a354 100644 --- a/arch/arm/lib/cache-cp15.c +++ b/arch/arm/lib/cache-cp15.c @@ -203,9 +203,12 @@ static inline void mmu_setup(void) asm volatile("mcr p15, 0, %0, c2, c0, 0" : : "r" (gd->arch.tlb_addr) : "memory"); #endif - /* Set the access control to all-supervisor */ + /* + * initial value of Domain Access Control Register (DACR) + * Set the access control to client (1U) for each of the 16 domains + */ asm volatile("mcr p15, 0, %0, c3, c0, 0" - : : "r" (~0)); + : : "r" (0x55555555)); arm_init_domains(); -- cgit v1.2.3 From 8ca0f51c5978920f3522df80f235219d2aa182b4 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 5 Feb 2021 13:53:38 +0100 Subject: arm: cp15: remove weak function arm_init_domains Remove the unused weak function arm_init_domains used to change the DACR value. Signed-off-by: Patrick Delaunay --- arch/arm/lib/cache-cp15.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'arch/arm/lib/cache-cp15.c') diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c index 4854c39a354..aab1bf43607 100644 --- a/arch/arm/lib/cache-cp15.c +++ b/arch/arm/lib/cache-cp15.c @@ -22,10 +22,6 @@ __weak void arm_init_before_mmu(void) { } -__weak void arm_init_domains(void) -{ -} - static void set_section_phys(int section, phys_addr_t phys, enum dcache_option option) { @@ -210,8 +206,6 @@ static inline void mmu_setup(void) asm volatile("mcr p15, 0, %0, c3, c0, 0" : : "r" (0x55555555)); - arm_init_domains(); - /* and enable the mmu */ reg = get_cr(); /* get control reg. */ set_cr(reg | CR_M); -- cgit v1.2.3