git: a1e516a731e3 - main - arm64: Move curthread setup earlier
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 19 Mar 2024 22:17:22 UTC
The branch main has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=a1e516a731e3d45e10dab65bb8ccb0484f316d55
commit a1e516a731e3d45e10dab65bb8ccb0484f316d55
Author: Isaac Cilia Attard <iciliaat@gmail.com>
AuthorDate: 2024-03-13 18:06:19 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-03-19 22:16:48 +0000
arm64: Move curthread setup earlier
In 469cfa3c30ee cperciva added TSLOG profiling to link_elf_ireloc. This
requires curthread to be read when the kernel linker is invoked, but it
hadn't yet been initialized. On amd64 this was harmless since [gs:0] was
readable; but on arm64 this broke since [x18] was not readable.
Move the curthread (and associated PCPU) setup earlier on arm64 in order
to allow TSLOG to work there.
Fixes: 469cfa3c30ee ("tslog: Annotate some early boot functions")
Differential Revision: https://reviews.freebsd.org/D44317
---
sys/arm64/arm64/machdep.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c
index 50b2cd15df3f..d566a8e2298c 100644
--- a/sys/arm64/arm64/machdep.c
+++ b/sys/arm64/arm64/machdep.c
@@ -920,6 +920,22 @@ initarm(struct arm64_bootparams *abp)
update_special_regs(0);
+ /* Set the pcpu data, this is needed by pmap_bootstrap */
+ pcpup = &pcpu0;
+ pcpu_init(pcpup, 0, sizeof(struct pcpu));
+
+ /*
+ * Set the pcpu pointer with a backup in tpidr_el1 to be
+ * loaded when entering the kernel from userland.
+ */
+ __asm __volatile(
+ "mov x18, %0 \n"
+ "msr tpidr_el1, %0" :: "r"(pcpup));
+
+ /* locore.S sets sp_el0 to &thread0 so no need to set it here. */
+ PCPU_SET(curthread, &thread0);
+ PCPU_SET(midr, get_midr());
+
link_elf_ireloc(kmdp);
#ifdef FDT
try_load_dtb(kmdp);
@@ -952,22 +968,6 @@ initarm(struct arm64_bootparams *abp)
physmem_exclude_region(efifb->fb_addr, efifb->fb_size,
EXFLAG_NOALLOC);
- /* Set the pcpu data, this is needed by pmap_bootstrap */
- pcpup = &pcpu0;
- pcpu_init(pcpup, 0, sizeof(struct pcpu));
-
- /*
- * Set the pcpu pointer with a backup in tpidr_el1 to be
- * loaded when entering the kernel from userland.
- */
- __asm __volatile(
- "mov x18, %0 \n"
- "msr tpidr_el1, %0" :: "r"(pcpup));
-
- /* locore.S sets sp_el0 to &thread0 so no need to set it here. */
- PCPU_SET(curthread, &thread0);
- PCPU_SET(midr, get_midr());
-
/* Do basic tuning, hz etc */
init_param1();