From 4963d177f90d0ce4a63c0dcdb86acc9fd4919fca Mon Sep 17 00:00:00 2001 From: Tim Chen Date: Thu, 21 Dec 2017 20:24:24 -0500 Subject: [PATCH] x86/idle: Disable IBRS when offlining cpu and re-enable on wakeup Clear IBRS when cpu is offlined and set it when bringing it back online. Orabug: 27344012 CVE: CVE-2017-5715 Signed-off-by: Tim Chen Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: John Haxby Signed-off-by: Kirtikar Kashyap --- arch/x86/kernel/smpboot.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 757546dffb0b..9495f5efdf87 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -76,6 +76,7 @@ #include #include #include +#include /* Number of siblings per CPU package */ int smp_num_siblings = 1; @@ -1504,9 +1505,15 @@ void native_play_dead(void) play_dead_common(); tboot_shutdown(TB_SHUTDOWN_WFS); + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) + native_wrmsrl(MSR_IA32_SPEC_CTRL, 0); + mwait_play_dead(); /* Only returns on failure */ if (cpuidle_play_dead()) hlt_play_dead(); + + if (boot_cpu_has(X86_FEATURE_SPEC_CTRL)) + native_wrmsrl(MSR_IA32_SPEC_CTRL, FEATURE_ENABLE_IBRS); } #else /* ... !CONFIG_HOTPLUG_CPU */ -- 2.50.1