[PATCH v3 11/19] arm64: text replication: boot secondary CPUs with appropriate TTBR1
Hao Jia
jiahao.os at bytedance.com
Wed Jan 17 00:53:49 PST 2024
From: "Russell King (Oracle)" <rmk+kernel at armlinux.org.uk>
Arrange for secondary CPUs to boot with TTBR1 pointing at the
appropriate per-node copy of the kernel page tables for the CPUs NUMA
node.
Signed-off-by: Russell King (Oracle) <rmk+kernel at armlinux.org.uk>
---
arch/arm64/include/asm/smp.h | 1 +
arch/arm64/kernel/asm-offsets.c | 1 +
arch/arm64/kernel/head.S | 3 ++-
arch/arm64/kernel/smp.c | 3 +++
4 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
index efb13112b408..a095616999a9 100644
--- a/arch/arm64/include/asm/smp.h
+++ b/arch/arm64/include/asm/smp.h
@@ -79,6 +79,7 @@ asmlinkage void secondary_start_kernel(void);
struct secondary_data {
struct task_struct *task;
long status;
+ phys_addr_t ttbr1;
};
extern struct secondary_data secondary_data;
diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c
index 5ff1942b04fc..ce9d265bc099 100644
--- a/arch/arm64/kernel/asm-offsets.c
+++ b/arch/arm64/kernel/asm-offsets.c
@@ -121,6 +121,7 @@ int main(void)
DEFINE(IRQ_CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending));
BLANK();
DEFINE(CPU_BOOT_TASK, offsetof(struct secondary_data, task));
+ DEFINE(CPU_BOOT_TTBR1, offsetof(struct secondary_data, ttbr1));
BLANK();
DEFINE(FTR_OVR_VAL_OFFSET, offsetof(struct arm64_ftr_override, val));
DEFINE(FTR_OVR_MASK_OFFSET, offsetof(struct arm64_ftr_override, mask));
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index cab7f91949d8..c21746685cdd 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -648,7 +648,8 @@ SYM_FUNC_START_LOCAL(secondary_startup)
ldr_l x0, vabits_actual
#endif
bl __cpu_setup // initialise processor
- adrp x1, swapper_pg_dir
+ adr_l x1, secondary_data
+ ldr x1, [x1, #CPU_BOOT_TTBR1]
adrp x2, idmap_pg_dir
bl __enable_mmu
ldr x8, =__secondary_switched
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index 4ced34f62dab..80a8e55e79b2 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -127,6 +127,9 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle)
* page tables.
*/
secondary_data.task = idle;
+ secondary_data.ttbr1 = __swapper_pg_dir_node_phys(cpu_to_node(cpu));
+ dcache_clean_poc((uintptr_t)&secondary_data,
+ (uintptr_t)&secondary_data + sizeof(secondary_data));
update_cpu_boot_status(CPU_MMU_OFF);
/* Now bring the CPU into our world */
--
2.20.1
More information about the linux-arm-kernel
mailing list