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

Reply via email to