Fix speculative access to firewalled regions on AM62 SoCs
Subsystems (2)
v3 cover Fix speculative access to firewalled regions on AM62 SoCs
Hi all,
This patch series fixes firewall exceptions observed on AM62 family of devices due to speculative accesses made by the A53 core to secure DDR regions.
For testing, I had used an AM62p with the following diff to enable logging from TIFS:
--- a/board/ti/am62px/board-cfg.yaml
+++ b/board/ti/am62px/board-cfg.yaml
@@ -33,5 +33,5 @@ board-cfg:
subhdr:
magic: 0x020C
size: 8
- trace_dst_enables: 0x00
- trace_src_enables: 0x00
+ trace_dst_enables: 0xd
+ trace_src_enables: 0x3fWithout this patch an exception[1] similar to the following is observed at A53 SPL stage:
FWL Bit 0x1
Exception addr 0x45B08000
FWL Exception 0x1000100
0x60000
0x80002880
0x0
0x141201
0x40
---
Changes in v3:
- Pick R-by tag form Ilias
- Remove the mmu_enable call added in [1/2] in patch [2/2]
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Added Reported-by from Suhaas
- Modify ARMv8's mmu_setup instead of overriding it only for mach-k3
- Add mmu_enable to give boards more control over MMU configruation
- Link to v1: https://patch.msgid.link/[email protected]
---
Anshul Dalal (2):
arm: armv8: mmu: move mmu enablement out of mmu_setup
mach-k3: enable mmu after reserved memory is unmapped
arch/arm/cpu/armv8/cache_v8.c | 5 ++++- arch/arm/include/asm/armv8/mmu.h | 5 +++++ arch/arm/mach-k3/common.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
---
base-commit: 13c1e13cc7fb1fa07867f835ccf25913594c71ec
change-id: 20260512-am62_firewall_exception_fix-20a335cca769
Best regards,
Signature · 1 line
Anshul Dalal <[email protected]>
PATCH v3 1/2 arm: armv8: mmu: move mmu enablement out of mmu_setup
Currently mmu_setup for ARMv8 performs two functions, first it sets up the page tables based the memory map provided by the board and then it enables the MMU.
However for some platforms runtime fixes to the generated page tables are required before the MMU can be enabled, such as K3 family of SoCs.
Therefore this patch moves the enablement of the MMU out of mmu_setup and to a standalone mmu_enable function to give more granular control to the platforms.
Note that no functional changes are intended from this patch.
--- arch/arm/cpu/armv8/cache_v8.c | 5 ++++- arch/arm/include/asm/armv8/mmu.h | 5 +++++ arch/arm/mach-k3/common.c | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/cache_v8.c +4 -1
@@ -810,8 +810,10 @@ __weak void mmu_setup(void) el =current_el ();set_ttbr_tcr_mair (el, gd->arch.tlb_addr,get_tcr (NULL ,NULL ),MEMORY_ATTRIBUTES ); +} -/* enable the mmu */ +void mmu_enable (void ) +{set_sctlr (get_sctlr () |CR_M ); }
@@ -881,6 +883,7 @@ void dcache_enable(void)if (!mmu_status ()) {__asm_invalidate_tlb_all ();mmu_setup (); +mmu_enable (); }/* Set up page tables only once (it is done also by mmu_setup()) */
arch/arm/include/asm/armv8/mmu.h +5 -0
@@ -222,6 +222,11 @@ u64 get_tcr(u64 *pips, u64 *pva_bits);* mmu_setup() - Sets up the mmu page tables as per mem_map */ void mmu_setup (void ); + +/** +* mmu_enable() - Enable the MMU by setting 'M' bit in SCTLR register +*/ +void mmu_enable (void );#endif #endif /* _ASM_ARMV8_MMU_H_ */
arch/arm/mach-k3/common.c +1 -0
@@ -279,6 +279,7 @@ void enable_caches(void) __func__, fdt_strerror(ret));mmu_setup (); +mmu_enable ();if (CONFIG_K3_ATF_LOAD_ADDR >=CFG_SYS_SDRAM_BASE ) { ret =mmu_unmap_reserved_mem ("tfa" , true);
Signature · 1 line
2.53.0
PATCH v3 2/2 mach-k3: enable mmu after reserved memory is unmapped
In reply to Anshul DalalCurrently the sequence to enable caches for the A53/A72 core on K3 devices looks as follows:
1. Map entire DDR banks
2. Setup page tables (done by mmu_setup)
3. Enable MMU
4. Unmap reserved-memory regions
5. Enable caches
However there is a brief period of execution between #3 and #4 where the core can issue speculative accesses to the entire DDR space (including the reserved-memory regions) despite the caches being disabled.
A firewall exception is triggered whenever such speculative access is made to secure DDR region of TFA or OP-TEE. This patch fixes the issue by re-ordering the sequence as follows:
1. Map entire DDR banks
2. Setup page tables
3. Unmap reserved-memory regions
4. Enable MMU
5. Enable caches
--- arch/arm/mach-k3/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-k3/common.c +1 -1
@@ -279,7 +279,6 @@ void enable_caches(void) __func__, fdt_strerror(ret));mmu_setup (); -mmu_enable ();if (CONFIG_K3_ATF_LOAD_ADDR >=CFG_SYS_SDRAM_BASE ) { ret =mmu_unmap_reserved_mem ("tfa" , true);
@@ -295,6 +294,7 @@ void enable_caches(void) __func__, ret); } +mmu_enable ();icache_enable ();dcache_enable (); }
Signature · 1 line
2.53.0
Re: [PATCH master v3 2/2] mach-k3: enable mmu after reserved memory is unmapped
Quoted 24 lines · Anshul Dalal
Currently the sequence to enable caches for the A53/A72 core on K3 devices looks as follows:
1. Map entire DDR banks
2. Setup page tables (done bymmu_setup)
3. Enable MMU
4. Unmap reserved-memory regions
5. Enable cachesHowever there is a brief period of execution between #3 and #4 where the core can issue speculative accesses to the entire DDR space (including the reserved-memory regions) despite the caches being disabled.
A firewall exception is triggered whenever such speculative access is made to secure DDR region of TFA or OP-TEE. This patch fixes the issue by re-ordering the sequence as follows:
1. Map entire DDR banks
2. Setup page tables
3. Unmap reserved-memory regions
4. Enable MMU
5. Enable caches
Quoted 4 lines
Fixes f1c694b8fdde ("mach-k3: map all banks using mem_map_from_dram_banks")Reported-by Suhaas Joshi <[email protected]>Signed-off-by Anshul Dalal <[email protected]>---
Quoted 27 lines
arch/arm/mach-k3/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-k3/common.c +1
-2@@ -279,7 +279,6 @@ void enable_caches(void) __func__, fdt_strerror(ret));mmu_setup (); -mmu_enable ();if (CONFIG_K3_ATF_LOAD_ADDR >=CFG_SYS_SDRAM_BASE ) { ret =mmu_unmap_reserved_mem ("tfa" , true);@@ -295,6 +294,7 @@ void enable_caches(void) __func__, ret); } +mmu_enable ();icache_enable ();dcache_enable (); } --2.53.0
Quoted 8 lines · Anshul Dalal
This patch series fixes firewall exceptions observed on AM62 family of devices due to speculative accesses made by the A53 core to secure DDR regions.
For testing, I had used an AM62p with the following diff to enable logging from TIFS:
[...]
Applied to u-boot/master, thanks!
[1/2] arm: armv8: mmu: move mmu enablement out of mmu_setup
commit: b53128d5283d63d749525895b2a38b558d843ced
[2/2] mach-k3: enable mmu after reserved memory is unmapped
commit: 37e6b640ef6177b79021190e3dfab13b465bebe4Signature · 1 line
Tom