Page MenuHomeFreeBSD

D27765.diff
No OneTemporary

D27765.diff

Index: sys/arm64/arm64/locore.S
===================================================================
--- sys/arm64/arm64/locore.S
+++ sys/arm64/arm64/locore.S
@@ -59,6 +59,15 @@
#endif /* page size */
#endif /* defined(LINUX_BOOT_ABI) */
+#if defined(SOCDEV_PA)
+ .bss
+ .align 3
+ .global socdev_va
+socdev_va:
+ .quad 0
+ .size socdev_va, . - socdev_va
+#endif
+
/*
* We assume:
* MMU on with an identity map, or off
@@ -497,35 +506,58 @@
add x27, x24, #PAGE_SIZE
mov x6, x27 /* The initial page table */
-#if defined(SOCDEV_PA) && defined(SOCDEV_VA)
+
+ /* Create the VA = PA map */
+ mov x7, #(ATTR_S1_nG | ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
+ adrp x16, _start
+ and x16, x16, #(~L2_OFFSET)
+ mov x9, x16 /* PA start */
+ mov x8, x16 /* VA start (== PA start) */
+ mov x10, #1
+ bl build_l2_block_pagetable
+
+#if defined(SOCDEV_PA)
/* Create a table for the UART */
mov x7, #(ATTR_S1_nG | ATTR_S1_IDX(VM_MEMATTR_DEVICE))
- mov x8, #(SOCDEV_VA) /* VA start */
- mov x9, #(SOCDEV_PA) /* PA start */
+ add x16, x16, #(L2_SIZE) /* VA start */
+ mov x8, x16
+
+ /* Store the socdev virtual address */
+ add x17, x8, #(SOCDEV_PA & L2_OFFSET)
+ adrp x9, socdev_va
+ str x17, [x9, :lo12:socdev_va]
+
+ mov x9, #(SOCDEV_PA & ~L2_OFFSET) /* PA start */
mov x10, #1
- bl build_l1_block_pagetable
+ bl build_l2_block_pagetable
#endif
#if defined(LINUX_BOOT_ABI)
/* Map FDT data ? */
cbz x19, 1f
- /* Create the identity mapping for FDT data (2 MiB max) */
+ /* Create the mapping for FDT data (2 MiB max) */
mov x7, #(ATTR_S1_nG | ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
- mov x9, x0
- mov x8, x0 /* VA start (== PA start) */
+ add x16, x16, #(L2_SIZE) /* VA start */
+ mov x8, x16
+ mov x9, x0 /* PA start */
+ /* Update the module pointer to point at the allocated memory */
+ and x0, x0, #(L2_OFFSET) /* Keep the lower bits */
+ add x0, x0, x8 /* Add the aligned virtual address */
+
mov x10, #1
- bl build_l1_block_pagetable
+ bl build_l2_block_pagetable
1:
#endif
- /* Create the VA = PA map */
- mov x7, #(ATTR_S1_nG | ATTR_S1_IDX(VM_MEMATTR_WRITE_BACK))
- mov x9, x28
- mov x8, x9 /* VA start (== PA start) */
- mov x10, #1
- bl build_l1_block_pagetable
+ /* Move to the l1 table */
+ add x27, x27, #PAGE_SIZE
+
+ /* Link the l1 -> l2 table */
+ mov x9, x6
+ mov x6, x27
+ bl link_l1_pagetable
/* Move to the l0 table */
add x27, x27, #PAGE_SIZE
@@ -544,13 +576,10 @@
/*
* 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
+ * x10 = Entry count (trashed)
* x11, x12 and x13 are trashed
*/
LENTRY(link_l0_pagetable)
@@ -582,9 +611,6 @@
/*
* Builds an L1 -> L2 table descriptor
*
- * This is a link for a 1GiB block of memory with up to 2MiB regions mapped
- * within it by build_l2_block_pagetable.
- *
* x6 = L1 table
* x8 = Virtual Address
* x9 = L2 PA (trashed)
@@ -611,51 +637,13 @@
ret
LEND(link_l1_pagetable)
-/*
- * Builds count 1 GiB page table entry
- * x6 = L1 table
- * x7 = Variable lower block attributes
- * x8 = VA start
- * x9 = PA start (trashed)
- * x10 = Entry count
- * x11, x12 and x13 are trashed
- */
-LENTRY(build_l1_block_pagetable)
- /*
- * Build the L1 table entry.
- */
- /* Find the table index */
- lsr x11, x8, #L1_SHIFT
- and x11, x11, #Ln_ADDR_MASK
-
- /* Build the L1 block entry */
- orr x12, x7, #L1_BLOCK
- orr x12, x12, #(ATTR_DEFAULT)
-
- /* Only use the output address bits */
- lsr x9, x9, #L1_SHIFT
-
- /* Set the physical address for this virtual address */
-1: orr x13, x12, x9, lsl #L1_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
-LEND(build_l1_block_pagetable)
-
/*
* Builds count 2 MiB page table entry
* x6 = L2 table
* x7 = Type (0 = Device, 1 = Normal)
* x8 = VA start
* x9 = PA start (trashed)
- * x10 = Entry count
+ * x10 = Entry count (trashed)
* x11, x12 and x13 are trashed
*/
LENTRY(build_l2_block_pagetable)
@@ -808,6 +796,8 @@
.space PAGE_SIZE
pagetable_l0_ttbr1:
.space PAGE_SIZE
+pagetable_l2_ttbr0_bootstrap:
+ .space PAGE_SIZE
pagetable_l1_ttbr0_bootstrap:
.space PAGE_SIZE
pagetable_l0_ttbr0_boostrap:
Index: sys/arm64/include/machdep.h
===================================================================
--- sys/arm64/include/machdep.h
+++ sys/arm64/include/machdep.h
@@ -60,6 +60,14 @@
int memory_mapping_mode(vm_paddr_t pa);
extern void (*pagezero)(void *);
+#ifdef SOCDEV_PA
+/*
+ * The virtual address SOCDEV_PA is mapped at.
+ * Only valid while the early pagetables are valid.
+ */
+extern uintptr_t socdev_va;
+#endif
+
#endif /* _KERNEL */
#endif /* _MACHINE_MACHDEP_H_ */
Index: sys/conf/options.arm64
===================================================================
--- sys/conf/options.arm64
+++ sys/conf/options.arm64
@@ -3,7 +3,6 @@
ARM64 opt_global.h
INTRNG opt_global.h
SOCDEV_PA opt_global.h
-SOCDEV_VA opt_global.h
THUNDERX_PASS_1_1_ERRATA opt_global.h
VFP opt_global.h
LINUX_BOOT_ABI opt_global.h

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 21, 9:59 PM (9 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27122810
Default Alt Text
D27765.diff (5 KB)

Event Timeline