Skip to content

Commit b263f85

Browse files
committed
loader,smp: Enable caches on all cores before using cache coherency
Ensure that caches are activated on all cores before accessing cached shared data. Caches are enabled within arch_mmu_enable(), so sharablility attributes are consistenly configured. Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
1 parent c83d507 commit b263f85

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

loader/src/aarch64/cpus.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <stdint.h>
99

1010
#include "smc.h"
11+
#include "../arch.h"
1112
#include "../cpus.h"
1213
#include "../cutil.h"
1314
#include "../loader.h"
@@ -110,6 +111,14 @@ void arm_secondary_cpu_entry(int logical_cpu, uint64_t mpidr_el1)
110111

111112
plat_save_hw_id(logical_cpu, mpidr_el1);
112113

114+
int r = arch_mmu_enable(logical_cpu);
115+
if (r != 0) {
116+
LDR_PRINT("ERROR", logical_cpu, "failed to enable MMU: ");
117+
puthex32(r);
118+
puts("\n");
119+
goto fail;
120+
}
121+
113122
start_kernel(logical_cpu);
114123

115124
fail:

loader/src/loader.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,6 @@ static int print_lock = 0;
100100

101101
void start_kernel(int logical_cpu)
102102
{
103-
LDR_PRINT("INFO", logical_cpu, "enabling MMU\n");
104-
int r = arch_mmu_enable(logical_cpu);
105-
if (r != 0) {
106-
LDR_PRINT("ERROR", logical_cpu, "failed to enable MMU: ");
107-
puthex32(r);
108-
puts("\n");
109-
for (;;) {}
110-
}
111-
112103
LDR_PRINT("INFO", logical_cpu, "jumping to kernel\n");
113104

114105
#ifdef CONFIG_PRINTING
@@ -175,6 +166,13 @@ int main(void)
175166
puthex32(plat_get_active_cpus());
176167
puts("\n");
177168

169+
r = arch_mmu_enable(0);
170+
if (r != 0) {
171+
LDR_PRINT("ERROR", 0, "failed to enable MMU: ");
172+
puthex32(r);
173+
fail();
174+
}
175+
178176
for (int cpu = 1; cpu < plat_get_active_cpus(); cpu++) {
179177
r = plat_start_cpu(cpu);
180178
if (r != 0) {

0 commit comments

Comments
 (0)