linux-stable/arch/x86/mm
Siddh Raman Pant 46513b4a80 x86/numa: Use cpumask_available instead of hardcoded NULL check
[ Upstream commit 625395c4a0 ]

GCC-12 started triggering a new warning:

  arch/x86/mm/numa.c: In function ‘cpumask_of_node’:
  arch/x86/mm/numa.c:916:39: warning: the comparison will always evaluate as ‘false’ for the address of ‘node_to_cpumask_map’ will never be NULL [-Waddress]
    916 |         if (node_to_cpumask_map[node] == NULL) {
        |                                       ^~

node_to_cpumask_map is of type cpumask_var_t[].

When CONFIG_CPUMASK_OFFSTACK is set, cpumask_var_t is typedef'd to a
pointer for dynamic allocation, else to an array of one element. The
"wicked game" can be checked on line 700 of include/linux/cpumask.h.

The original code in debug_cpumask_set_cpu() and cpumask_of_node() were
probably written by the original authors with CONFIG_CPUMASK_OFFSTACK=y
(i.e. dynamic allocation) in mind, checking if the cpumask was available
via a direct NULL check.

When CONFIG_CPUMASK_OFFSTACK is not set, GCC gives the above warning
while compiling the kernel.

Fix that by using cpumask_available(), which does the NULL check when
CONFIG_CPUMASK_OFFSTACK is set, otherwise returns true. Use it wherever
such checks are made.

Conditional definitions of cpumask_available() can be found along with
the definition of cpumask_var_t. Check the cpumask.h reference mentioned
above.

Fixes: c032ef60d1 ("cpumask: convert node_to_cpumask_map[] to cpumask_var_t")
Fixes: de2d9445f1 ("x86: Unify node_to_cpumask_map handling between 32 and 64bit")
Signed-off-by: Siddh Raman Pant <code@siddh.me>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20220731160913.632092-1-code@siddh.me
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-08-25 11:18:08 +02:00
..
amdtopology.c
cpu_entry_area.c
debug_pagetables.c
dump_pagetables.c
extable.c locking/refcount: Consolidate implementations of refcount_t 2022-07-29 17:14:17 +02:00
fault.c x86/mm: split vmalloc_sync_all() 2020-03-25 08:25:58 +01:00
highmem_32.c
hugetlbpage.c
ident_map.c x86/mm/ident_map: Check for errors from ident_pud_init() 2020-12-30 11:51:02 +01:00
init.c x86/mm: Stop printing BRK addresses 2020-06-22 09:31:08 +02:00
init_32.c
init_64.c x86/mm: Fix kern_addr_valid() to cope with existing but not present entries 2021-09-22 12:26:40 +02:00
iomap_32.c
ioremap.c x86/ioremap: Fix CONFIG_EFI=n build 2020-04-01 11:01:59 +02:00
kasan_init_64.c
kaslr.c
kmmio.c
Makefile
mem_encrypt.c x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc() 2021-03-30 14:35:29 +02:00
mem_encrypt_boot.S
mem_encrypt_identity.c x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c 2021-11-17 09:48:19 +01:00
mm_internal.h
mmap.c
mmio-mod.c x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables 2020-06-07 13:18:51 +02:00
mpx.c
numa.c x86/numa: Use cpumask_available instead of hardcoded NULL check 2022-08-25 11:18:08 +02:00
numa_32.c
numa_64.c
numa_emulation.c x86, fakenuma: Fix invalid starting node ID 2020-09-09 19:12:28 +02:00
numa_internal.h
pageattr-test.c
pageattr.c x86/mm/pat: Don't flush cache if hardware enforces cache coherency across encryption domnains 2022-03-16 13:21:48 +01:00
pat.c x86: Fix return value of __setup handlers 2022-06-14 18:11:35 +02:00
pat_internal.h
pat_rbtree.c
pf_in.c
pf_in.h
pgtable.c x86/mm: Fix leak of pmd ptlock 2021-01-12 20:16:22 +01:00
pgtable_32.c
physaddr.c
physaddr.h
pkeys.c
pti.c
setup_nx.c
srat.c
testmmiotrace.c
tlb.c x86/membarrier: Get rid of a dubious optimization 2020-12-16 10:56:59 +01:00