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

From: Jiri Kosina
Date: Wed Sep 12 2018 - 15:16:56 EST


On Wed, 12 Sep 2018, Thomas Gleixner 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.

Yeah; I was just happy to be able to stick second use of it there, with
the first one being basically useless as well :)

> I'll zap it.

Absolutely feel free to. Thanks,

--
Jiri Kosina
SUSE Labs