Re: [RFC PATCH 03/56] cpu: Reset global mitigations

Josh Poimboeuf
2025-10-16T21:34:24Z

On Mon, Oct 13, 2025 at 09:33:51AM -0500, David Kaplan wrote:
> +#ifdef CONFIG_DYNAMIC_MITIGATIONS
> +void __weak arch_cpu_reset_mitigations(void)
> +{
> +}
> +
> +void cpu_reset_mitigations(void)
> +{
> + smt_mitigations = SMT_MITIGATIONS_AUTO;
> + cpu_mitigations = CPU_MITIGATIONS_AUTO;
> + attack_vectors[CPU_MITIGATE_USER_KERNEL] = true;
> + attack_vectors[CPU_MITIGATE_USER_USER] = true;
> + attack_vectors[CPU_MITIGATE_GUEST_HOST] = IS_ENABLED(CONFIG_KVM);
> + attack_vectors[CPU_MITIGATE_GUEST_GUEST] = IS_ENABLED(CONFIG_KVM);
> + arch_cpu_reset_mitigations();
> +}
> +#endif

Considering this will have no effect on other arches (or even on x86 at
this point in the series), should CONFIG_DYNAMIC_MITIGATIONS depend on
an arch-specific CONFIG_HAVE_DYNAMIC_MITIGATIONS?

Then the weak function can be removed (and weak functions should be
avoided anyway, IMO).

--
Josh