From: Chuck Anderson Date: Mon, 26 Feb 2018 09:40:58 +0000 (-0800) Subject: retpoline: set IBRS and IBPB in use only on the boot CPU call to init_scattered_cpuid... X-Git-Tag: v4.1.12-124.31.3~1104 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=5560f91691771eb9ce4a5f94f78c6e002286e7d5;p=users%2Fjedix%2Flinux-maple.git retpoline: set IBRS and IBPB in use only on the boot CPU call to init_scattered_cpuid_features() Setting IBRS and IBPB in use is a system wide issue, not a per-CPU issue. Set them only on the boot CPU's call to init_scattered_cpuid_features(). Orabug: 27625404 Signed-off-by: Chuck Anderson Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Darren Kenny Conflicts: arch/x86/kernel/cpu/scattered.c (merged with be596ab27 ("x86/speculation: Use IBRS if available before calling into firmware")) --- diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c index 5d0cd6bcc459..3f2183d6027b 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -185,23 +185,21 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c, clear_cpu_cap(c, X86_FEATURE_STIBP); } - mutex_lock(&spec_ctrl_mutex); - - if (cpu_has(c, X86_FEATURE_IBRS)) { - set_ibrs_supported(); - /* - * Don't do this after disable_ibrs_and_friends as we would - * re-enable it (say if spectre_v2=off is used). - */ - if (&boot_cpu_data == c) + if (&boot_cpu_data == c) { + mutex_lock(&spec_ctrl_mutex); + if (cpu_has(c, X86_FEATURE_IBRS)) { + set_ibrs_supported(); + /* + * Don't do this after disable_ibrs_and_friends as we + * would re-enable it (say if spectre_v2=off is used). + */ set_ibrs_firmware(); - sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0; - } - - if (cpu_has(c, X86_FEATURE_IBPB)) { - set_ibpb_supported(); - sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; + sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0; + } + if (cpu_has(c, X86_FEATURE_IBPB)) { + set_ibpb_supported(); + sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; + } + mutex_unlock(&spec_ctrl_mutex); } - - mutex_unlock(&spec_ctrl_mutex); }