Re: [PATCH v2 08/59] x86/build: Ensure proper function alignment

From: Linus Torvalds
Date: Fri Sep 02 2022 - 12:51:47 EST


On Fri, Sep 2, 2022 at 6:55 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> --- a/arch/x86/include/asm/linkage.h
> +++ b/arch/x86/include/asm/linkage.h
> @@ -14,9 +14,10 @@
>
> #ifdef __ASSEMBLY__
>
> -#if defined(CONFIG_X86_64) || defined(CONFIG_X86_ALIGNMENT_16)
> -#define __ALIGN .p2align 4, 0x90
> -#define __ALIGN_STR __stringify(__ALIGN)
> +#if CONFIG_FUNCTION_ALIGNMENT == 16
> +#define __ALIGN .p2align 4, 0x90
> +#define __ALIGN_STR __stringify(__ALIGN)
> +#define FUNCTION_ALIGNMENT 16
> #endif

Ugh.

Why is this conditional on that alignment being 16?

Is it purely because the CONFIG variable was mis-designed, and is the
number of bytes, instead of being the shift? If so, just fix that, and
then do an unconditional

#define __ALIGN .p2align
CONFIG_FUNCTION_ALIGNMENT_SHIFT, 0x90
#define __ALIGN_STR __stringify(__ALIGN)

(leave the asm-generic one conditional, since then the condition makes
sense - it's arch-specific).

Linus