[PATCH] arm64/kernel: Fix range on invalidating dcache for boot page tables

From: Gavin Shan
Date: Fri Apr 24 2020 - 01:02:53 EST


The MMU is disabled when __create_page_tables() is called. The data
cache corresponding to these two page tables, which are tracked by
@idmap_pg_dir and @init_pg_dir, is invalidated after the page tables
are populated. However, the wrong or inappropriate size have been used
and more data cache are invalidated than it need.

This fixes the issue by invalidating the data cache for these two
page tables separately as they aren't necessarily physically adjacent.

Signed-off-by: Gavin Shan <gshan@xxxxxxxxxx>
---
arch/arm64/kernel/head.S | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 57a91032b4c2..66947873c9e7 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -398,6 +398,10 @@ SYM_FUNC_START_LOCAL(__create_page_tables)
* tables again to remove any speculatively loaded cache lines.
*/
adrp x0, idmap_pg_dir
+ mov x1, #IDMAP_DIR_SIZE
+ dmb sy
+ bl __inval_dcache_area
+ adrp x0, init_pg_dir
adrp x1, init_pg_end
sub x1, x1, x0
dmb sy
--
2.23.0