Re: [RFC][PATCH 12/17] x86/cpu: Rename original retbleed return thunk
From: Peter Zijlstra
Date: Thu Aug 10 2023 - 09:02:43 EST
On Thu, Aug 10, 2023 at 12:06:17PM +0100, Andrew.Cooper3@xxxxxxxxxx wrote:
> On 09/08/2023 3:22 pm, Peter Zijlstra wrote:
> > On Wed, Aug 09, 2023 at 10:20:31AM -0400, Josh Poimboeuf wrote:
> >> On Wed, Aug 09, 2023 at 09:12:30AM +0200, Peter Zijlstra wrote:
> >>> +++ b/tools/objtool/check.c
> >>> @@ -455,7 +455,12 @@ static int decode_instructions(struct ob
> >>> return -1;
> >>> }
> >>>
> >>> - if (func->return_thunk || !strcmp(func->name, "srso_safe_ret") || func->alias != func)
> >>> + /*
> >>> + * Both zen_return_thunk() and srso_safe_ret() are embedded inside
> >>> + * another instruction and objtool doesn't grok that. Skip validating them.
> >>> + */
> >>> + if (!strcmp(func->name, "zen_return_thunk") ||
> >>> + !strcmp(func->name, "srso_safe_ret") || func->alias != func)
> >> Hm, speaking of renaming they should probably be called
> >> retbleed_return_thunk() and srso_return_thunk().
> > Yes, clearly naming is better in daylight. Let me regex that.
>
> btc_*, not retbleed_*.
>
> That way it matches the terminology you'll find in the AMD whitepaper
> about what's going on, and there's already an entirely different issue
> called Retbleed.
So BTC as a whole is the fact that AMD predicts the type of an
instruction and then picks a predictor to predict the target of that
instruction, no?
The retbleed issue is that BTC is used to trick the thing into thinking
the RET is not a return but an indirect branch (type confusion) and then
pick the BTB predictor for a target, which got trained to point at
targer of choice.
The SRSO thing employs the same type confusion to train the RSB/RAP and
have RET, now correctly predicted to be a RET and using said RSB/RAP, to
jump to target of choice.
So in that regards, I don't think BTC is a good name for the thing.