lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAS=knGxd9ZRo37CaKTvjcc28bqNasx+XuqbV3S+XV=HtQ@mail.gmail.com>
Date: Tue, 20 Feb 2024 22:39:37 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Petr Pavlu <petr.pavlu@...e.com>
Cc: nathan@...nel.org, nicolas@...sle.eu, mark.rutland@....com, 
	linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] kbuild: Use -fmin-function-alignment when available

On Fri, Feb 16, 2024 at 12:16 AM Petr Pavlu <petr.pavlu@...e.com> wrote:
>
> GCC recently added option -fmin-function-alignment, which should appear
> in GCC 14. Unlike -falign-functions, this option causes all functions to
> be aligned at the specified value, including the cold ones.
>
> Detect availability of -fmin-function-alignment and use it instead of
> -falign-functions when present. Introduce CC_HAS_SANE_FUNCTION_ALIGNMENT
> and make the workarounds for the broken function alignment conditional
> on this setting.
>
> Signed-off-by: Petr Pavlu <petr.pavlu@...e.com>
> ---

[snip]

> index dfb963d2f862..5a6fed4ad3df 100644
> --- a/kernel/exit.c
> +++ b/kernel/exit.c
> @@ -1920,7 +1920,10 @@ EXPORT_SYMBOL(thread_group_exited);
>   *
>   * See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88345#c11
>   */
> -__weak __function_aligned void abort(void)
> +#ifndef CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT
> +__function_aligned
> +#endif
> +__weak void abort(void)
>  {
>         BUG();





__function_aligned is conditionally defined in
include/linux/compiler_types.h, and then it is
conditionally used in kernel/exit.c

This is unreadable.




You may want to move CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT
to include/linux/compiler_types.h, as this is more
aligned with what you did for __cold.



if !defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) && \
               CONFIG_FUNCTION_ALIGNMENT > 0
#define __function_aligned       __aligned(CONFIG_FUNCTION_ALIGNMENT)
#else
#define __function_aligned
#endif





However, an even more elegant approach is to unify
the two #ifdef blocks because __cold and __function_aligned
are related to each other.



#if defined(CONFIG_CC_HAS_SANE_FUNCTION_ALIGNMENT) || \
                 (CONFIG_FUNCTION_ALIGNMENT == 0)
#define __cold                 __attribute__((__cold__))
#define __function_aligned
#else
#define __cold
#define __function_aligned     __aligned(CONFIG_FUNCTION_ALIGNMENT)
#endif









--
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ