Skip to content

Commit 58661a3

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Flush the instruction cache during SMP bringup
Instruction cache flush IPIs are sent only to CPUs in cpu_online_mask, so they will not target a CPU until it calls set_cpu_online() earlier in smp_callin(). As a result, if instruction memory is modified between the CPU coming out of reset and that point, then its instruction cache may contain stale data. Therefore, the instruction cache must be flushed after the set_cpu_online() synchronization point. Fixes: 08f051e ("RISC-V: Flush I$ when making a dirty page executable") Reviewed-by: Alexandre Ghiti <[email protected]> Signed-off-by: Samuel Holland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 4cece76 commit 58661a3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

arch/riscv/kernel/smpboot.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <linux/sched/task_stack.h>
2727
#include <linux/sched/mm.h>
2828

29-
#include <asm/cpufeature.h>
29+
#include <asm/cacheflush.h>
3030
#include <asm/cpu_ops.h>
3131
#include <asm/irq.h>
3232
#include <asm/mmu_context.h>
@@ -234,9 +234,10 @@ asmlinkage __visible void smp_callin(void)
234234
riscv_user_isa_enable();
235235

236236
/*
237-
* Remote TLB flushes are ignored while the CPU is offline, so emit
238-
* a local TLB flush right now just in case.
237+
* Remote cache and TLB flushes are ignored while the CPU is offline,
238+
* so flush them both right now just in case.
239239
*/
240+
local_flush_icache_all();
240241
local_flush_tlb_all();
241242
complete(&cpu_running);
242243
/*

0 commit comments

Comments
 (0)