lkml.org 
[lkml]   [2018]   [Sep]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 2/2] x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation
On Mon, 10 Sep 2018, Jiri Kosina wrote:
> +static void update_stibp_msr(void *info)
> +{
> + wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
> +}
> +
> +void arch_smt_update(void)
> +{
> + if (stibp_needed()) {

if (!stib_needed())
return;

spares you an indentation level.

> + u64 mask;

Newline between declarations and code please.

> + mutex_lock(&spec_ctrl_mutex);
> + mask = x86_spec_ctrl_base;
> + if (cpu_smt_control == CPU_SMT_ENABLED)
> + mask |= SPEC_CTRL_STIBP;
> + else
> + mask &= ~SPEC_CTRL_STIBP;
> +
> + if (mask != x86_spec_ctrl_base) {
> + pr_info("Spectre v2 cross-process SMT mitigation: %s STIBP\n",
> + cpu_smt_control == CPU_SMT_ENABLED ?
> + "Enabling" : "Disabling");
> + x86_spec_ctrl_base = mask;
> + on_each_cpu(update_stibp_msr, NULL, 1);
> + }
> + mutex_unlock(&spec_ctrl_mutex);
> + }
> +}
> +

That looks much more palatable. One missing piece is the sysfs mitigation
file for spectre v2. That should reflect STIPB state as well.

Thanks,

tglx

\
 
 \ /
  Last update: 2018-09-10 12:04    [W:0.122 / U:0.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site