Re: [RFC][PATCH 2/2] x86: Clean up default rethunk warning

From: Borislav Petkov
Date: Mon Nov 04 2024 - 07:01:42 EST


On Mon, Oct 07, 2024 at 10:32:12AM +0200, Peter Zijlstra wrote:
> - .section .text..__x86.indirect_thunk
> +#define WARN_ONCE \

This should be in the asm section of arch/x86/include/asm/bug.h so that other
asm code can use it. It will come in handy...

> + 1: ALTERNATIVE "", "ud2", X86_FEATURE_ALWAYS ; \

... but uff, you can't because of this ALTERNATIVE. This is a conditional
WARN_ONCE. Yuck.

I guess ALT_WARN_ONCE or so...

> + ASM_BUGTABLE_FLAGS(1b, 0, 0, BUGFLAG_WARNING | BUGFLAG_ONCE) ; \
> + REACHABLE
>
> + .section .text..__x86.indirect_thunk
>
> .macro POLINE reg
> ANNOTATE_INTRA_FUNCTION_CALL
> @@ -382,16 +387,15 @@ SYM_FUNC_END(call_depth_return_thunk)
> SYM_CODE_START(__x86_return_thunk)
> UNWIND_HINT_FUNC
> ANNOTATE_NOENDBR
> -#if defined(CONFIG_MITIGATION_UNRET_ENTRY) || \
> - defined(CONFIG_MITIGATION_SRSO) || \
> - defined(CONFIG_MITIGATION_CALL_DEPTH_TRACKING)
> - ALTERNATIVE __stringify(ANNOTATE_UNRET_SAFE; ret), \
> - "jmp warn_thunk_thunk", X86_FEATURE_ALWAYS
> -#else
> +
> +#ifdef CONFIG_X86_64
> + WARN_ONCE
> +#endif

And you can add an empty 32-bit WARN_ONCE macro so that we don't have this
ifdeffery here where ifdeffery gives the last drop of making this file totally
unreadable...

--
Regards/Gruss,
Boris.

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