Skip to content

Commit 4583a6b

Browse files
konradwilkjfvogel
authored andcommitted
x86/spectre_v2: Disable IBRS if spectre_v2=off
We found some interesting behaviors when booting on IBRS enabled hardware where 'spectre_v2=off' did not disable IBRS completely. That is during the bootup we received some interrupts which meant that we set the MSR 0x48 to 1.. and then when we got to the code that handles 'spectre_v2=off' we would just call 'set_ibrs_disabled' which would clear the in_use parameter. But that would not clear the wedged MSR 048 being set to 1. Which means we would continue on with both retpoline and IBRS on! The fix is rather simple - clear the MSR as well. Note that if 'noibrs' was used - then we would have disabled the IBRS _before_ we got the interrupt, as 'noibrs' is an early parameter. OraBug: 27525754 Reported-by: Yao-Min Chen <[email protected]> Reviewed-by: Mike Kravetz <[email protected]> Reviewed-by: Khalid Aziz <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent c859a42 commit 4583a6b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/x86/kernel/cpu/bugs_64.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifdef CONFIG_SYSFS
99
#include <linux/device.h>
1010
#endif
11+
#include <linux/cpu.h>
1112
#include <asm/alternative.h>
1213
#include <asm/nospec-branch.h>
1314
#include <asm/cmdline.h>
@@ -295,6 +296,15 @@ static enum spectre_v2_mitigation __init ibrs_select(void)
295296
static void __init disable_ibrs_and_friends(bool disable_ibpb)
296297
{
297298
set_ibrs_disabled();
299+
if (use_ibrs & SPEC_CTRL_IBRS_SUPPORTED) {
300+
unsigned int cpu;
301+
302+
get_online_cpus();
303+
for_each_online_cpu(cpu)
304+
wrmsrl_on_cpu(cpu, MSR_IA32_SPEC_CTRL, SPEC_CTRL_FEATURE_DISABLE_IBRS);
305+
306+
put_online_cpus();
307+
}
298308
/* We need to use IBPB with retpoline if it is available. */
299309
if (disable_ibpb)
300310
set_ibpb_disabled();

0 commit comments

Comments
 (0)