[PATCH 5/6] arm64: head: clarify `map_memory`

Anshuman Khandual anshuman.khandual at arm.com
Tue May 17 20:17:24 PDT 2022


From: Mark Rutland <mark.rutland at arm.com>

In the `map_memory` macro we repurpose the `count` temporary register to
hold the physical address `phys` aligned downwards to
SWAPPER_BLOCK_SIZE. Due to the subtle usage of `count` elsewhere, this
is a little confusing, and is also unnecessary as we can safely corrupt
`phys`, which is not used after `map_memory` completes.

This patch makes `map_memory` manipulate `phys` in-place, and updates
the documentation to mention that it corrupts `phys`.

Signed-off-by: Mark Rutland <mark.rutland at arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual at arm.com>
---
 arch/arm64/kernel/head.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 01739f5ec3de..107275e06212 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -225,7 +225,7 @@ SYM_CODE_END(preserve_boot_args)
  *
  * Temporaries:	istart, iend, tmp, count, sv - these need to be different registers
  * Preserves:	vstart, flags
- * Corrupts:	tbl, rtbl, vend, istart, iend, tmp, count, sv
+ * Corrupts:	tbl, rtbl, vend, phys, istart, iend, tmp, count, sv
  */
 	.macro map_memory, tbl, rtbl, vstart, vend, flags, phys, pgds, istart, iend, tmp, count, sv
 	sub \vend, \vend, #1
@@ -251,8 +251,8 @@ SYM_CODE_END(preserve_boot_args)
 #endif
 
 	compute_indices \vstart, \vend, #SWAPPER_BLOCK_SHIFT, #PTRS_PER_PTE, \istart, \iend, \count, \tmp
-	bic \count, \phys, #SWAPPER_BLOCK_SIZE - 1
-	populate_entries \tbl, \count, \istart, \iend, \flags, #SWAPPER_BLOCK_SIZE, \tmp
+	bic \phys, \phys, #SWAPPER_BLOCK_SIZE - 1
+	populate_entries \tbl, \phys, \istart, \iend, \flags, #SWAPPER_BLOCK_SIZE, \tmp
 	.endm
 
 /*
-- 
2.20.1




More information about the linux-arm-kernel mailing list