Skip to content

Commit 2f8b5b2

Browse files
nmenontmlind
authored andcommitted
ARM: DRA7/OMAP5: Enable ACTLR[0] (Enable invalidates of BTB) for secondary cores
Call secure services to enable ACTLR[0] (Enable invalidates of BTB with ICIALLU) when branch hardening is enabled for kernel. On GP devices OMAP5/DRA7, there is no possibility to update secure side since "secure world" is ROM and there are no override mechanisms possible. On HS devices, appropriate PPA should do the workarounds as well. However, the configuration is only done for secondary core, since it is expected that firmware/bootloader will have enabled the required configuration for the primary boot core (note: bootloaders typically will NOT enable secondary processors, since it has no need to do so). Signed-off-by: Nishanth Menon <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent 0144eb2 commit 2f8b5b2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

arch/arm/mach-omap2/omap-smp.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,45 @@ void omap5_erratum_workaround_801819(void)
109109
static inline void omap5_erratum_workaround_801819(void) { }
110110
#endif
111111

112+
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
113+
/*
114+
* Configure ACR and enable ACTLR[0] (Enable invalidates of BTB with
115+
* ICIALLU) to activate the workaround for secondary Core.
116+
* NOTE: it is assumed that the primary core's configuration is done
117+
* by the boot loader (kernel will detect a misconfiguration and complain
118+
* if this is not done).
119+
*
120+
* In General Purpose(GP) devices, ACR bit settings can only be done
121+
* by ROM code in "secure world" using the smc call and there is no
122+
* option to update the "firmware" on such devices. This also works for
123+
* High security(HS) devices, as a backup option in case the
124+
* "update" is not done in the "security firmware".
125+
*/
126+
static void omap5_secondary_harden_predictor(void)
127+
{
128+
u32 acr, acr_mask;
129+
130+
asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
131+
132+
/*
133+
* ACTLR[0] (Enable invalidates of BTB with ICIALLU)
134+
*/
135+
acr_mask = BIT(0);
136+
137+
/* Do we already have it done.. if yes, skip expensive smc */
138+
if ((acr & acr_mask) == acr_mask)
139+
return;
140+
141+
acr |= acr_mask;
142+
omap_smc1(OMAP5_DRA7_MON_SET_ACR_INDEX, acr);
143+
144+
pr_debug("%s: ARM ACR setup for CVE_2017_5715 applied on CPU%d\n",
145+
__func__, smp_processor_id());
146+
}
147+
#else
148+
static inline void omap5_secondary_harden_predictor(void) { }
149+
#endif
150+
112151
static void omap4_secondary_init(unsigned int cpu)
113152
{
114153
/*
@@ -131,6 +170,8 @@ static void omap4_secondary_init(unsigned int cpu)
131170
set_cntfreq();
132171
/* Configure ACR to disable streaming WA for 801819 */
133172
omap5_erratum_workaround_801819();
173+
/* Enable ACR to allow for ICUALLU workaround */
174+
omap5_secondary_harden_predictor();
134175
}
135176

136177
/*

0 commit comments

Comments
 (0)