Re: [PATCH 2/2] x86/bugs: Don't WARN() when overwriting retbleed_return_thunk with srso_return_thunk

From: Borislav Petkov
Date: Fri May 16 2025 - 03:49:04 EST


On Thu, May 15, 2025 at 04:34:33PM -0700, Suraj Jitindar Singh wrote:
> - WARN(x86_return_thunk != __x86_return_thunk,
> + WARN((x86_return_thunk != __x86_return_thunk) &&
> + (thunk != srso_return_thunk ||
> + x86_return_thunk != retbleed_return_thunk),
> "x86/bugs: return thunk changed from %ps to %ps\n",
> x86_return_thunk, thunk);

This is still adding that nasty conditional which I'd like to avoid.

And I just had this other idea: we're switching to select/update/apply logic
with the mitigations and I'm sure we can use that new ability to select the
proper mitigation when other mitigations are influencing the decision, to
select the proper return thunk.

I'm thinking for retbleed and SRSO we could set it only once, perhaps in
srso_select_mitigation() as it runs last.

I don't want to introduce an amd_return_thunk... :-)

But David might have a better idea...

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette