Skip to content

Commit 45ed285

Browse files
pmundtPaul Mundt
authored andcommitted
sh: speculative execution support for SH7780.
SH7780 has a speculative execution mode where it can speculatively perform an instruction fetch for subroutine returns, this allows it to be enabled. There are some various pitfalls associated with this mode, so it's left as depending on CONFIG_EXPERIMENTAL and not enabled by default. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent fc31b80 commit 45ed285

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎arch/sh/Kconfig‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,16 @@ config SH_STORE_QUEUES
366366
Selecting this option will enable an in-kernel API for manipulating
367367
the store queues integrated in the SH-4 processors.
368368

369+
config SPECULATIVE_EXECUTION
370+
bool "Speculative subroutine return"
371+
depends on CPU_SUBTYPE_SH7780 && EXPERIMENTAL
372+
help
373+
This enables support for a speculative instruction fetch for
374+
subroutine return. There are various pitfalls associated with
375+
this, as outlined in the SH7780 hardware manual.
376+
377+
If unsure, say N.
378+
369379
config CPU_HAS_INTEVT
370380
bool
371381

‎arch/sh/kernel/cpu/init.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ __setup("no" __stringify(x), x##_setup);
4141
onchip_setup(fpu);
4242
onchip_setup(dsp);
4343

44+
#ifdef CONFIG_SPECULATIVE_EXECUTION
45+
#define CPUOPM 0xff2f0000
46+
#define CPUOPM_RABD (1 << 5)
47+
48+
static void __init speculative_execution_init(void)
49+
{
50+
/* Clear RABD */
51+
ctrl_outl(ctrl_inl(CPUOPM) & ~CPUOPM_RABD, CPUOPM);
52+
53+
/* Flush the update */
54+
(void)ctrl_inl(CPUOPM);
55+
ctrl_barrier();
56+
}
57+
#else
58+
#define speculative_execution_init() do { } while (0)
59+
#endif
60+
4461
/*
4562
* Generic first-level cache init
4663
*/
@@ -261,4 +278,6 @@ asmlinkage void __init sh_cpu_init(void)
261278
*/
262279
ubc_wakeup();
263280
#endif
281+
282+
speculative_execution_init();
264283
}

0 commit comments

Comments
 (0)