From e873e580ef72a2bd95f5e5455ec878bccb622773 Mon Sep 17 00:00:00 2001 From: Michalis Pappas Date: Wed, 17 Feb 2021 11:52:04 +0100 Subject: [PATCH] plat/common: Add invalidate_dcache_range for arm64 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Introduces an additional cache maintenance function that invalidates cache without cleaning. This is useful when reading memory updated from a different core, after turning on the caches. Signed-off-by: Michalis Pappas Reviewed-by: Răzvan Vîrtan Tested-by: Unikraft CI GitHub-Pull-Request: #171 --- plat/common/arm/cache64.S | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/plat/common/arm/cache64.S b/plat/common/arm/cache64.S index 46bab4af0..ce62d584c 100644 --- a/plat/common/arm/cache64.S +++ b/plat/common/arm/cache64.S @@ -73,3 +73,34 @@ ENTRY(clean_and_invalidate_dcache_range) ret END(clean_and_invalidate_dcache_range) + +ENTRY(invalidate_dcache_range) + /* Get information about the caches from CTR_EL0 */ + mrs x4, ctr_el0 + mov x2, #CTR_BYTES_PER_WORD + + /* Get minimum D cache line size */ + ubfx x3, x4, #CTR_DMINLINE_SHIFT, #CTR_DMINLINE_WIDTH + lsl x3, x2, x3 + + /* Align the start address to line size */ + sub x4, x3, #1 + and x2, x0, x4 + add x1, x1, x2 + bic x0, x0, x4 +1: + /* clean D cache by D cache line size */ + dc ivac, x0 + dsb nsh + + /* Move to next line and reduce the size */ + add x0, x0, x3 + subs x1, x1, x3 + + /* Check if all range has been invalidated */ + b.hi 1b + + isb + + ret +END(invalidate_dcache_range) -- 2.39.5