Re: [RFC][PATCH 05/17] x86/cpu: Cleanup the untrain mess

From: Josh Poimboeuf
Date: Wed Aug 09 2023 - 08:51:40 EST


On Wed, Aug 09, 2023 at 09:12:23AM +0200, Peter Zijlstra wrote:
> Since there can only be one active return_thunk, there only needs be
> one (matching) untrain_ret. It fundamentally doesn't make sense to
> allow multiple untrain_ret at the same time.
>
> Fold all the 3 different untrain methods into a single (temporary)
> helper stub.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> arch/x86/include/asm/nospec-branch.h | 19 +++++--------------
> arch/x86/lib/retpoline.S | 7 +++++++
> 2 files changed, 12 insertions(+), 14 deletions(-)
>
> --- a/arch/x86/include/asm/nospec-branch.h
> +++ b/arch/x86/include/asm/nospec-branch.h
> @@ -272,9 +272,9 @@
> .endm
>
> #ifdef CONFIG_CPU_UNRET_ENTRY
> -#define CALL_ZEN_UNTRAIN_RET "call zen_untrain_ret"
> +#define CALL_UNTRAIN_RET "call entry_untrain_ret"
> #else
> -#define CALL_ZEN_UNTRAIN_RET ""
> +#define CALL_UNTRAIN_RET ""
> #endif
>
> /*
> @@ -293,15 +293,10 @@
> defined(CONFIG_CALL_DEPTH_TRACKING) || defined(CONFIG_CPU_SRSO)
> VALIDATE_UNRET_END
> ALTERNATIVE_3 "", \
> - CALL_ZEN_UNTRAIN_RET, X86_FEATURE_UNRET, \
> + CALL_UNTRAIN_RET, X86_FEATURE_UNRET, \

SRSO doesn't have X86_FEATURE_UNRET set.

--
Josh