git: 719908c81300 - main - arm64: Merge common page table creation code

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Fri, 10 May 2024 09:30:12 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=719908c8130012234898c3602eb0c0db9af0a620

commit 719908c8130012234898c3602eb0c0db9af0a620
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-04-25 13:06:23 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-05-10 09:29:24 +0000

    arm64: Merge common page table creation code
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D45061
---
 sys/arm64/arm64/locore.S | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index 94a50b735bc6..67bdece402c2 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -520,17 +520,27 @@ common:
 	 * when the page size is larger than 4k, L2 blocks are too large to
 	 * map the kernel with such an alignment.
 	 */
+#define	PTE_SHIFT	L3_SHIFT
+#define	BUILD_PTE_FUNC	build_l3_page_pagetable
+#else
+#define	PTE_SHIFT	L2_SHIFT
+#define	BUILD_PTE_FUNC	build_l2_block_pagetable
+#endif
 
-	/* Get the number of l3 pages to allocate, rounded down */
-	lsr	x10, x8, #(L3_SHIFT)
+	/* Get the number of blocks/pages to allocate, rounded down */
+	lsr	x10, x8, #(PTE_SHIFT)
 
-	/* Create the kernel space L2 table */
+	/* Create the kernel space PTE table */
 	mov	x6, x26
 	mov	x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
 	mov	x8, #(KERNBASE)
 	mov	x9, x28
-	bl	build_l3_page_pagetable
+	bl	BUILD_PTE_FUNC
+
+#undef PTE_SHIFT
+#undef BUILD_PTE_FUNC
 
+#if PAGE_SIZE != PAGE_SIZE_4K
 	/* Move to the l2 table */
 	ldr	x9, =(PAGE_SIZE * L3_PAGE_COUNT)
 	add	x26, x26, x9
@@ -539,16 +549,6 @@ common:
 	mov	x9, x6
 	mov	x6, x26
 	bl	link_l2_pagetable
-#else
-	/* Get the number of l2 pages to allocate, rounded down */
-	lsr	x10, x8, #(L2_SHIFT)
-
-	/* Create the kernel space L2 table */
-	mov	x6, x26
-	mov	x7, #(ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
-	mov	x8, #(KERNBASE)
-	mov	x9, x28
-	bl	build_l2_block_pagetable
 #endif
 
 	/* Move to the l1 table */