summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2017-02-03 13:39:50 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2017-02-03 13:39:50 +0000
commitfa8cdbc6c1601897f1725207d89aefda4a905f0e (patch)
treed08594f4da7fda8d1aa79e64917482f8f7b41bc8
parentb9ba973c1774bce6808662bef1fdf3edfe0ef952 (diff)
Implement a helper that creates an L0 pagetable entry pointing to
a L1 pagetable. Needed for machines that need 4 level pagetables on bootup. From FreeBSD
-rw-r--r--sys/arch/arm64/arm64/locore.S39
1 files changed, 38 insertions, 1 deletions
diff --git a/sys/arch/arm64/arm64/locore.S b/sys/arch/arm64/arm64/locore.S
index c96ec895b8a..f59854dbd82 100644
--- a/sys/arch/arm64/arm64/locore.S
+++ b/sys/arch/arm64/arm64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.9 2017/02/03 10:46:19 patrick Exp $ */
+/* $OpenBSD: locore.S,v 1.10 2017/02/03 13:39:49 patrick Exp $ */
/*-
* Copyright (c) 2012-2014 Andrew Turner
* All rights reserved.
@@ -426,6 +426,43 @@ create_pagetables:
ret
/*
+ * Builds an L0 -> L1 table descriptor
+ *
+ * This is a link for a 512GiB block of memory with up to 1GiB regions mapped
+ * within it by build_l1_block_pagetable.
+ *
+ * x6 = L0 table
+ * x8 = Virtual Address
+ * x9 = L1 PA (trashed)
+ * x10 = Entry count
+ * x11, x12 and x13 are trashed
+ */
+link_l0_pagetable:
+ /*
+ * Link an L0 -> L1 table entry.
+ */
+ /* Find the table index */
+ lsr x11, x8, #L0_SHIFT
+ and x11, x11, #Ln_ADDR_MASK
+
+ /* Build the L0 block entry */
+ mov x12, #L0_TABLE
+
+ /* Only use the output address bits */
+ lsr x9, x9, #PAGE_SHIFT
+1: orr x13, x12, x9, lsl #PAGE_SHIFT
+
+ /* Store the entry */
+ str x13, [x6, x11, lsl #3]
+
+ sub x10, x10, #1
+ add x11, x11, #1
+ add x9, x9, #1
+ cbnz x10, 1b
+
+ ret
+
+/*
* Builds an L1 -> L2 table descriptor
*
* This is a link for a 1GiB block of memory with up to 2MiB regions mapped