The FF-A EFI runtime variable path uses a shared MM communication buffer after ExitBootServices(). Before sending a request to the MM secure partition the buffer range must be flushed, and after the response the same range must be invalidated.
Keep flush_dcache_range() and invalidate_dcache_range() available from EFI runtime code on arm64, together with the underlying assembly range helpers, so the FF-A runtime transport can maintain the shared buffer without using whole-cache operations after ExitBootServices(). Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Harsimran Singh Tungal <[email protected]> --- Changelog: =============== v5: Ilias: - Split the ARMv8 cache range-maintenance runtime annotations out of the EFI variable TEE runtime patch. --- arch/arm/cpu/armv8/cache.S | 8 ++++++++ arch/arm/cpu/armv8/cache_v8.c | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/arch/arm/cpu/armv8/cache.S b/arch/arm/cpu/armv8/cache.S index c9e46859b4f..386b62c2d81 100644 --- a/arch/arm/cpu/armv8/cache.S +++ b/arch/arm/cpu/armv8/cache.S @@ -169,7 +169,11 @@ ENDPROC(__asm_flush_l3_dcache) * x0: start address * x1: end address */ +#ifdef CONFIG_ARM_FFA_RT_MODE +.pushsection .text.efi_runtime.__asm_flush_dcache_range, "ax" +#else .pushsection .text.__asm_flush_dcache_range, "ax" +#endif ENTRY(__asm_flush_dcache_range) mrs x3, ctr_el0 ubfx x3, x3, #16, #4 @@ -195,7 +199,11 @@ ENDPROC(__asm_flush_dcache_range) * x0: start address * x1: end address */ +#ifdef CONFIG_ARM_FFA_RT_MODE +.pushsection .text.efi_runtime.__asm_invalidate_dcache_range, "ax" +#else .pushsection .text.__asm_invalidate_dcache_range, "ax" +#endif ENTRY(__asm_invalidate_dcache_range) mrs x3, ctr_el0 ubfx x3, x3, #16, #4 diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c index e59528e576e..edde8f73a6b 100644 --- a/arch/arm/cpu/armv8/cache_v8.c +++ b/arch/arm/cpu/armv8/cache_v8.c @@ -8,6 +8,12 @@ */ #include <cpu_func.h> +#if IS_ENABLED(CONFIG_ARM_FFA_RT_MODE) +#include <efi_loader.h> +#define CACHE_RUNTIME_ATTR __efi_runtime +#else +#define CACHE_RUNTIME_ATTR +#endif #include <hang.h> #include <log.h> #include <asm/cache.h> @@ -915,7 +921,8 @@ inline void flush_dcache_all(void) /* * Invalidates range in all levels of D-cache/unified cache */ -void invalidate_dcache_range(unsigned long start, unsigned long stop) +void CACHE_RUNTIME_ATTR invalidate_dcache_range(unsigned long start, + unsigned long stop) { __asm_invalidate_dcache_range(start, stop); } @@ -923,20 +930,25 @@ void invalidate_dcache_range(unsigned long start, unsigned long stop) /* * Flush range(clean & invalidate) from all levels of D-cache/unified cache */ -void flush_dcache_range(unsigned long start, unsigned long stop) +void CACHE_RUNTIME_ATTR flush_dcache_range(unsigned long start, + unsigned long stop) { __asm_flush_dcache_range(start, stop); } #else -void invalidate_dcache_range(unsigned long start, unsigned long stop) +void CACHE_RUNTIME_ATTR invalidate_dcache_range(unsigned long start, + unsigned long stop) { } -void flush_dcache_range(unsigned long start, unsigned long stop) +void CACHE_RUNTIME_ATTR flush_dcache_range(unsigned long start, + unsigned long stop) { } #endif /* CONFIG_SYS_DISABLE_DCACHE_OPS */ +#undef CACHE_RUNTIME_ATTR + void dcache_enable(void) { /* The data cache is not active unless the mmu is enabled */ -- 2.34.1
