Re: [RFC PATCH 22/23] x86/hreset: Configure history reset

Peter Zijlstra
2022-09-27T12:04:39Z

On Fri, Sep 09, 2022 at 04:12:04PM -0700, Ricardo Neri wrote:

> +static u32 hardware_history_features __read_mostly;

__ro_after_init ?

> +static __always_inline void setup_hreset(struct cpuinfo_x86 *c)
> +{
> + if (!cpu_feature_enabled(X86_FEATURE_HRESET))
> + return;
> +
> + /*
> + * Use on all CPUs the hardware history features that the boot
> + * CPU supports.
> + */
> + if (c == &boot_cpu_data)
> + hardware_history_features = cpuid_ebx(0x20);
> +
> + if (!hardware_history_features)
> + return;
> +
> + wrmsrl(MSR_IA32_HW_HRESET_ENABLE, hardware_history_features);
> +
> + pr_info_once("x86/cpu: Intel History Reset (HRESET) activated\n");
> +}
> +
> /* These bits should not change their value after CPU init is finished. */
> static const unsigned long cr4_pinned_mask =
> X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |