linux/tools/testing/selftests/powerpc
Amit Machhiwal 6e65886fce selftests/powerpc: Suppress -Wmaybe-uninitialized with GCC 15
GCC 15 reports the below false positive '-Wmaybe-uninitialized' warning
in vphn_unpack_associativity() when building the powerpc selftests.

  # make -C tools/testing/selftests TARGETS="powerpc"
  [...]
    CC       test-vphn
  In file included from test-vphn.c:3:
  In function ‘vphn_unpack_associativity’,
      inlined from ‘test_one’ at test-vphn.c:371:2,
      inlined from ‘test_vphn’ at test-vphn.c:399:9:
  test-vphn.c:10:33: error: ‘be_packed’ may be used uninitialized [-Werror=maybe-uninitialized]
     10 | #define be16_to_cpup(x)         bswap_16(*x)
        |                                 ^~~~~~~~
  vphn.c:42:27: note: in expansion of macro ‘be16_to_cpup’
     42 |                 u16 new = be16_to_cpup(field++);
        |                           ^~~~~~~~~~~~
  In file included from test-vphn.c:19:
  vphn.c: In function ‘test_vphn’:
  vphn.c:27:16: note: ‘be_packed’ declared here
     27 |         __be64 be_packed[VPHN_REGISTER_COUNT];
        |                ^~~~~~~~~
  cc1: all warnings being treated as errors

When vphn_unpack_associativity() is called from hcall_vphn() in kernel
the error is not seen while building vphn.c during kernel compilation.
This is because the top level Makefile includes '-fno-strict-aliasing'
flag always.

The issue here is that GCC 15 emits '-Wmaybe-uninitialized' due to type
punning between __be64[] and __b16* when accessing the buffer via
be16_to_cpup(). The underlying object is fully initialized but GCC 15
fails to track the aliasing due to the strict aliasing violation here.
Please refer [1] and [2]. This results in a false positive warning which
is promoted to an error under '-Werror'. This problem is not seen when
the compilation is performed with GCC 13 and 14. An issue [1] has also
been created on GCC bugzilla.

The selftest compiles fine with '-fno-strict-aliasing'. Since this GCC
flag is used to compile vphn.c in kernel too, the same flag should be
used to build vphn tests when compiling vphn.c in the selftest as well.

Fix this by including '-fno-strict-aliasing' during vphn.c compilation
in the selftest. This keeps the build working while limiting the scope
of the suppression to building vphn tests.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124427
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99768

Fixes: 58dae82843 ("selftests/powerpc: Add test for VPHN")
Reviewed-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20260313165426.43259-1-amachhiw@linux.ibm.com
2026-04-01 09:21:04 +05:30
..
alignment selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
benchmarks selftests/powerpc: Fix argument order to timer_sub() 2025-01-11 10:39:45 +05:30
cache_shape selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
copyloops powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx 2026-03-12 11:03:48 +05:30
dexcr selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
dscr selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
eeh selftests/powerpc: make sub-folders buildable on their own 2024-04-29 23:54:42 +10:00
include powerpc: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-01 13:23:29 +05:30
lib selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
math selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
mce selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
mm selftests/powerpc: Use PKEY_UNRESTRICTED macro 2025-02-17 18:16:36 +00:00
nx-gzip selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
papr_attributes selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
papr_sysparm selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
papr_vpd selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
pmu selftests/powerpc/pmu/: Add check_extended_reg_test to .gitignore 2025-12-22 17:55:07 +05:30
primitives selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
ptrace selftests/powerpc: Use PKEY_UNRESTRICTED macro 2025-02-17 18:16:36 +00:00
scripts selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
security selftests/powerpc: Detect taint change in mitigation patching test 2024-11-07 22:36:31 +11:00
signal selftests/powerpc: Return errors from all tests 2024-11-07 22:36:31 +11:00
stringloops selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
switch_endian selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
syscalls selftests/powerpc: Give all tests 2 minutes timeout 2024-11-07 22:36:30 +11:00
tm selftests/powerpc: Return errors from all tests 2024-11-07 22:36:31 +11:00
vphn selftests/powerpc: Suppress -Wmaybe-uninitialized with GCC 15 2026-04-01 09:21:04 +05:30
flags.mk selftests/powerpc: Fix build with USERCFLAGS set 2024-07-06 22:10:14 +10:00
harness.c selftests/powerpc: add const qualification where possible 2023-08-18 17:03:15 +10:00
Makefile selftests/powerpc: Install tests in sub-directories 2024-04-29 23:54:43 +10:00
utils.c selftests/powerpc/dexcr: Add hashst/hashchk test 2023-06-19 17:36:28 +10:00