Re: [PATCH v6 2/3] x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation

From: Thomas Gleixner
Date: Wed Sep 12 2018 - 15:15:06 EST


On Wed, 12 Sep 2018, Jiri Kosina wrote:
> case X86_BUG_SPECTRE_V2:
> - return sprintf(buf, "%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
> + mutex_lock(&spec_ctrl_mutex);
> + ret = sprintf(buf, "%s%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
> boot_cpu_has(X86_FEATURE_USE_IBPB) ? ", IBPB" : "",
> boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",
> + (x86_spec_ctrl_base & SPEC_CTRL_STIBP) ? ", STIBP" : "",
> spectre_v2_module_string());
> + mutex_unlock(&spec_ctrl_mutex);

The mutex for this printing is overkill. It's a read after all and if there
is a concurrent SMT control fiddling going on then you have a chance of
getting the wrong information as well. I'll zap it.

Thanks,

tglx