[PATCH 3/6] arm64: head: clarify `populate_entries`

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


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

For a few reasons, `populate_entries` can be harder than necessary to
understand. This patch improves the commentary and naming to make it
easier to follow:

* Commentary is update to explicitly describe the span of adjacent pages
  which `populate_entries` operates on, and what entries correspond to
  at each level.

* As `rtbl` is not always a table, is renamed to `phys`, as it always
  represents a physical address.

* `index` and `eindex` are renamed to `istart` and `iend` respectively,
  to match the naming used in `compute_indices` where these values are
  generated.

* As "to or in" can be difficult to read, the commentary for `flags` is
  reworded in terms of "bits to set".

There should be no functional change as a result of this patch.

Cc: Ard Biesheuvel <ardb at kernel.org>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Will Deacon <will at kernel.org>
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 | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index aaad76680495..b5d7dacbbb2c 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -144,28 +144,30 @@ SYM_CODE_END(preserve_boot_args)
 	.endm
 
 /*
- * Macro to populate page table entries, these entries can be pointers to the next level
- * or last level entries pointing to physical memory.
+ * Populate a span of adjacent page tables with entries. For non-leaf levels,
+ * each entry points to a table in a span of adjacent page tables at the next
+ * level. For the leaf level these entries point to a span of physical memory
+ * being mapped.
  *
- *	tbl:	page table address
- *	rtbl:	pointer to page table or physical memory
- *	index:	start index to write
- *	eindex:	end index to write - [index, eindex] written to
- *	flags:	flags for pagetable entry to or in
- *	inc:	increment to rtbl between each entry
+ *	tbl:	physical address of the first table in this span
+ *	phys:	physical address of memory or next-level table span
+ *	istart:	index of the first entry to write
+ *	iend:	index of the last entry to write - [index, eindex] written to
+ *	flags:	bits to set in each page table entry
+ *	inc:	increment to phys between each entry
  *	tmp1:	temporary variable
  *
- * Preserves:	tbl, eindex, flags, inc
- * Corrupts:	index, tmp1
- * Returns:	rtbl
+ * Preserves:	tbl, iend, flags, inc
+ * Corrupts:	istart, tmp1
+ * Returns:	phys
  */
-	.macro populate_entries, tbl, rtbl, index, eindex, flags, inc, tmp1
-.Lpe\@:	phys_to_pte \tmp1, \rtbl
+	.macro populate_entries, tbl, phys, istart, iend, flags, inc, tmp1
+.Lpe\@:	phys_to_pte \tmp1, \phys
 	orr	\tmp1, \tmp1, \flags	// tmp1 = table entry
-	str	\tmp1, [\tbl, \index, lsl #3]
-	add	\rtbl, \rtbl, \inc	// rtbl = pa next level
-	add	\index, \index, #1
-	cmp	\index, \eindex
+	str	\tmp1, [\tbl, \istart, lsl #3]
+	add	\phys, \phys, \inc
+	add	\istart, \istart, #1
+	cmp	\istart, \iend
 	b.ls	.Lpe\@
 	.endm
 
-- 
2.20.1




More information about the linux-arm-kernel mailing list