diff mbox series

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

Message ID 20220518031725.3128044-6-anshuman.khandual@arm.com (mailing list archive)
State New, archived
Headers show
Series arm64/head: Cleanups for __create_page_tables() | expand

Commit Message

Anshuman Khandual May 18, 2022, 3:17 a.m. UTC
From: Mark Rutland <mark.rutland@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@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 arch/arm64/kernel/head.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

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
 
 /*