Re: [PATCH v3 10/10] x86/ibt: Optimize fineibt-bhi arity 1 case

Kees Cook
2025-02-19T18:21:39Z

On Wed, Feb 19, 2025 at 05:21:17PM +0100, Peter Zijlstra wrote:
> Saves a CALL to an out-of-line thunk for the common case of 1
> argument.
>
> Suggested-by: Scott Constable <scott.d.constable@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> arch/x86/include/asm/ibt.h | 4 ++
> arch/x86/kernel/alternative.c | 61 +++++++++++++++++++++++++++++++++++-------
> 2 files changed, 56 insertions(+), 9 deletions(-)
>
> --- a/arch/x86/include/asm/ibt.h
> +++ b/arch/x86/include/asm/ibt.h
> @@ -70,6 +70,10 @@ static inline bool __is_endbr(u32 val)
> if (val == gen_endbr_poison())
> return true;
>
> + /* See cfi_fineibt_bhi_preamble() */
> + if (IS_ENABLED(CONFIG_FINEIBT_BHI) && val == 0x001f0ff5)
> + return true;

Does this magic value need some better documentation?

Reviewed-by: Kees Cook <kees@kernel.org>

--
Kees Cook