]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
retpoline: move lock/unlock of spec_ctrl_mutex into init_scattered_cpuid_features()
authorChuck Anderson <chuck.anderson@oracle.com>
Mon, 26 Feb 2018 07:58:47 +0000 (23:58 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Sat, 3 Mar 2018 01:57:18 +0000 (17:57 -0800)
init_scattered_cpuid_features() changes spectre mitigation state.
Not all callers obtained spec_ctrl_mutex.  Move the lock/unlock of
spec_ctrl_mutex to init_scattered_cpuid_features() rather than have
the callers obtain it.  That also allows init_scattered_cpuid_features()
to serialize just the spectre state changes instead of the entire
function.

Orabug: 27625404
Signed-off-by: Chuck Anderson <chuck.anderson@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
arch/x86/kernel/cpu/microcode/core.c
arch/x86/kernel/cpu/scattered.c

index 6b7a843db4549b0b9cba709e7974736be8c6bd1c..2f83c508c1ccdbc00f6daa72346585aeeaa95603 100644 (file)
@@ -233,9 +233,7 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
                perf_check_microcode();
 
        /* check spec_ctrl capabilities */
-       mutex_lock(&spec_ctrl_mutex);
        init_scattered_cpuid_features(&boot_cpu_data);
-       mutex_unlock(&spec_ctrl_mutex);
 
        mutex_unlock(&microcode_mutex);
        put_online_cpus();
index b4825d59a9b45db94b91edd60ef30a8daa45c0e1..39e16bb62490a0f5805234d049fcc316bc6ff0c9 100644 (file)
@@ -178,6 +178,8 @@ 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();
                /*
@@ -193,4 +195,6 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
                set_ibpb_supported();
                sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0;
        }
+
+       mutex_unlock(&spec_ctrl_mutex);
 }