All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: mark.rutland@arm.com, catalin.marinas@arm.com, will@kernel.org,
	Ard Biesheuvel <ardb@kernel.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>
Subject: [PATCH 3/6] arm64: head: clarify `populate_entries`
Date: Wed, 18 May 2022 08:47:22 +0530	[thread overview]
Message-ID: <20220518031725.3128044-4-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20220518031725.3128044-1-anshuman.khandual@arm.com>

From: Mark Rutland <mark.rutland@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@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Anshuman Khandual <anshuman.khandual@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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2022-05-18  3:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  3:17 [PATCH 0/6] arm64/head: Cleanups for __create_page_tables() Anshuman Khandual
2022-05-18  3:17 ` [PATCH 1/6] arm64: don't override idmap t0sz Anshuman Khandual
2022-05-18  6:41   ` Ard Biesheuvel
2022-05-18  3:17 ` [PATCH 2/6] arm64: head: remove __PHYS_OFFSET Anshuman Khandual
2022-05-18  6:45   ` Ard Biesheuvel
2022-05-18  3:17 ` Anshuman Khandual [this message]
2022-05-18  3:17 ` [PATCH 4/6] arm64: head: clarify `compute_indices` Anshuman Khandual
2022-05-18  6:47   ` Ard Biesheuvel
2022-05-18  3:17 ` [PATCH 5/6] arm64: head: clarify `map_memory` Anshuman Khandual
2022-05-18  3:17 ` [PATCH 6/6] arm64: head: clarify commentary for __create_page_tables Anshuman Khandual
2022-05-18  6:52 ` [PATCH 0/6] arm64/head: Cleanups for __create_page_tables() Ard Biesheuvel
2022-05-18  9:35   ` Anshuman Khandual
2022-06-27 10:17     ` Will Deacon
2022-06-28  4:47       ` Anshuman Khandual

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220518031725.3128044-4-anshuman.khandual@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.