Re: [PATCH v3 12/35] x86/bugs: Restructure retbleed mitigation

Pawan Gupta
2025-01-09T16:40:41Z

On Thu, Jan 09, 2025 at 03:26:58PM +0000, Kaplan, David wrote:
> The intent was never to allow AUTO to persist, it should always be turned
> into a real mitigation. However it looks like I did miss a case there,
> where if the mitigation is AUTO when retbleed_select_mitigation() is
> called, the bug should be mitigated but the vendor isn't AMD/Hygon, it
> wasn't being transformed.
>
> I'll figure out how to fix this to match the existing functionality,
> thanks for pointing this out.

Also, adding a guard to ensure AUTO never persists would be good.

diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index 5bc2782f4ce1..ad63b5678250 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -1383,6 +1383,9 @@ static void __init retbleed_update_mitigation(void)
}
}
out:
+ if (retbleed_mitigation == RETBLEED_MITIGATION_AUTO)
+ retbleed_mitigation = RETBLEED_MITIGATION_NONE;
+
pr_info("%s\n", retbleed_strings[retbleed_mitigation]);
}