linux-stable/arch/x86/mm
Siddh Raman Pant 73fb00ab42 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:15:26 +02:00
..
amdtopology.c
cpu_entry_area.c x86: Add entry trampolines to kcore 2018-08-14 19:13:26 -03:00
debug_pagetables.c x86/efi: Replace efi_pgd with efi_mm.pgd 2018-03-12 11:05:05 +01:00
dump_pagetables.c x86/mm: Do not warn about PCI BIOS W+X mappings 2019-11-24 08:20:57 +01:00
extable.c x86/extable: Mark exception handler functions visible 2018-01-14 20:04:16 +01:00
fault.c x86/mm: split vmalloc_sync_all() 2020-03-25 08:06:13 +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:25:50 +01:00
init.c x86/mm: Stop printing BRK addresses 2020-06-22 09:05:18 +02:00
init_32.c mm/memory_hotplug: shrink zones when offlining memory 2020-01-29 16:43:27 +01:00
init_64.c x86/mm: Fix kern_addr_valid() to cope with existing but not present entries 2021-09-22 11:48:10 +02:00
iomap_32.c x86/mm: Do not auto-massage page protections 2018-04-12 09:04:22 +02:00
ioremap.c x86: Make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol 2021-12-22 09:19:01 +01:00
kasan_init_64.c x86/kasan: Fix boot with 5-level paging and KASAN 2019-06-19 08:18:06 +02:00
kaslr.c x86/mm/KASLR: Compute the size of the vmemmap section properly 2019-06-19 08:18:07 +02:00
kmmio.c x86/mm/kmmio: Make the tracer robust against L1TF 2018-08-08 22:28:34 +02:00
Makefile x86/mm/sme: Disable stack protection for mem_encrypt_identity.c 2018-02-28 15:24:12 +01:00
mem_encrypt.c x86/mem_encrypt: Correct physical address calculation in __set_clr_pte_enc() 2021-03-30 14:37:03 +02:00
mem_encrypt_boot.S x86/mm/sme, objtool: Annotate indirect call in sme_encrypt_execute() 2018-02-21 09:05:04 +01:00
mem_encrypt_identity.c x86/sme: Use #define USE_EARLY_PGTABLE_L5 in mem_encrypt_identity.c 2021-11-26 11:35:58 +01:00
mm_internal.h
mmap.c x86/mm: Don't exceed the valid physical address space 2019-05-04 09:20:21 +02:00
mmio-mod.c x86/mmiotrace: Use cpumask_available() for cpumask_var_t variables 2020-06-07 13:17:56 +02:00
mpx.c
numa.c x86/numa: Use cpumask_available instead of hardcoded NULL check 2022-08-25 11:15:26 +02:00
numa_32.c x86/mm/32: Remove unused node_memmap_size_bytes() & CONFIG_NEED_NODE_MEMMAP_SIZE logic 2018-03-27 08:45:02 +02:00
numa_64.c
numa_emulation.c x86, fakenuma: Fix invalid starting node ID 2020-09-09 19:04:27 +02:00
numa_internal.h
pageattr-test.c
pageattr.c x86/mm: Fix NX bit clearing issue in kernel_map_pages_in_pgd 2020-02-24 08:34:49 +01:00
pat.c x86: Fix return value of __setup handlers 2022-06-14 16:59:21 +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:10:23 +01:00
pgtable_32.c x86/mm: Rename flush_tlb_single() and flush_tlb_one() to __flush_tlb_one_[user|kernel]() 2018-02-15 01:15:52 +01:00
physaddr.c
physaddr.h
pkeys.c x86/pkeys: Override pkey when moving away from PROT_EXEC 2018-05-14 11:14:45 +02:00
pti.c x86/mm/pti: Handle unaligned address gracefully in pti_clone_pagetable() 2019-10-05 13:09:52 +02:00
setup_nx.c
srat.c
testmmiotrace.c
tlb.c x86/membarrier: Get rid of a dubious optimization 2020-12-30 11:25:40 +01:00