linux-stable/arch/x86/kernel/fpu
YingChi Long 7242fc8c2f x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN
commit 55228db269 upstream.

WG14 N2350 specifies that it is an undefined behavior to have type
definitions within offsetof", see

  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm

This specification is also part of C23.

Therefore, replace the TYPE_ALIGN macro with the _Alignof builtin to
avoid undefined behavior. (_Alignof itself is C11 and the kernel is
built with -gnu11).

ISO C11 _Alignof is subtly different from the GNU C extension
__alignof__. Latter is the preferred alignment and _Alignof the
minimal alignment. For long long on x86 these are 8 and 4
respectively.

The macro TYPE_ALIGN's behavior matches _Alignof rather than
__alignof__.

  [ bp: Massage commit message. ]

Signed-off-by: YingChi Long <me@inclyc.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://lore.kernel.org/r/20220925153151.2467884-1-me@inclyc.cn
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-24 07:18:01 +01:00
..
bugs.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
core.c x86/fpu: Add kernel_fpu_begin_mask() to selectively initialize state 2021-01-27 11:47:49 +01:00
init.c x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN 2023-01-24 07:18:01 +01:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
regset.c x86/fpu: Limit xstate copy size in xstateregs_set() 2021-07-20 16:10:50 +02:00
signal.c x86/fpu: Reset state for all signal restore failures 2021-06-23 14:41:29 +02:00
xstate.c x86/fpu: Make init_fpstate correct with optimized XSAVE 2021-08-26 08:36:11 -04:00