Skip to content

Commit c2ea1d5

Browse files
committed
MIPS: Avoid potential hazard on Context register
set_saved_sp reads Context register. Avoid reading stale value from earlier incomplete write. Issue found and fixed for head.S by Chris Dearman <chris@mips.com>. Signed-off-by: Chris Dearman <chris@mips.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent cd847b7 commit c2ea1d5

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎arch/mips/include/asm/mmu_context.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/smp.h>
1717
#include <linux/slab.h>
1818
#include <asm/cacheflush.h>
19+
#include <asm/hazards.h>
1920
#include <asm/tlbflush.h>
2021
#ifdef CONFIG_MIPS_MT_SMTC
2122
#include <asm/mipsmtregs.h>
@@ -36,11 +37,13 @@ extern unsigned long pgd_current[];
3637
#ifdef CONFIG_32BIT
3738
#define TLBMISS_HANDLER_SETUP() \
3839
write_c0_context((unsigned long) smp_processor_id() << 25); \
40+
back_to_back_c0_hazard(); \
3941
TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
4042
#endif
4143
#ifdef CONFIG_64BIT
4244
#define TLBMISS_HANDLER_SETUP() \
4345
write_c0_context((unsigned long) smp_processor_id() << 26); \
46+
back_to_back_c0_hazard(); \
4447
TLBMISS_HANDLER_SETUP_PGD(swapper_pg_dir)
4548
#endif
4649

‎arch/mips/kernel/head.S‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
191191
/* Set the SP after an empty pt_regs. */
192192
PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE
193193
PTR_ADDU sp, $28
194+
back_to_back_c0_hazard
194195
set_saved_sp sp, t0, t1
195196
PTR_SUBU sp, 4 * SZREG # init stack pointer
196197

0 commit comments

Comments
 (0)