From dadc48ed101fff191511930a3fc5179143d2254b Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Thu, 29 Aug 2024 02:13:24 +0800 Subject: [PATCH] smp: Write _vectors_start into boot CPU rvbar where possible On A7-A11 we have a ROM exploit and we can keep CPU0 RVBAR unlocked. Signed-off-by: Nick Chan --- src/smp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/smp.c b/src/smp.c index 5a622a19..74ed2ecc 100644 --- a/src/smp.c +++ b/src/smp.c @@ -319,9 +319,6 @@ void smp_start_secondaries(void) } for (int i = 0; i < MAX_CPUS; i++) { - - if (i == boot_cpu_idx) - continue; int cpu_node = cpu_nodes[i]; if (!cpu_node) @@ -342,6 +339,18 @@ void smp_start_secondaries(void) memcpy(cpu_impl_reg, ®s[index], 16); } + if (i == boot_cpu_idx) { + // Check if already locked + if (read64(cpu_impl_reg[0]) & 1) + continue; + + // Unlocked, write _vectors_start into boot CPU's rvbar + write64(cpu_impl_reg[0], (u64)_vectors_start); + sysop("dmb sy"); + + continue; + } + u8 core = FIELD_GET(CPU_REG_CORE, reg); u8 cluster = FIELD_GET(CPU_REG_CLUSTER, reg); u8 die = FIELD_GET(CPU_REG_DIE, reg);