Re: [PATCH v3 04/35] x86/bugs: Restructure mds mitigation

Josh Poimboeuf
2025-02-10T22:25:10Z

On Wed, Jan 08, 2025 at 02:24:44PM -0600, David Kaplan wrote:
> @@ -229,9 +259,6 @@ static void x86_amd_ssb_disable(void)
> wrmsrl(MSR_AMD64_LS_CFG, msrval);
> }
>
> -#undef pr_fmt
> -#define pr_fmt(fmt) "MDS: " fmt
> -

Why? For consistency with the rest of the file it's best to leave the
correct pr_fmt() in place for mds_*(), taa_*(), rfds_*(), etc.

> static void __init mds_select_mitigation(void)
> {
> - if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
> + if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off())
> mds_mitigation = MDS_MITIGATION_OFF;
> - return;
> - }

For clarity it should still return here, that makes it obvious none of
the subsequent conditions apply.

> +static void __init mds_apply_mitigation(void)
> +{
> + if (mds_mitigation == MDS_MITIGATION_FULL) {
> + setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);

The mitigation still needs to be attempted for the MDS_MITIGATION_VMWERV
case.

--
Josh