linux/arch
Arnd Bergmann b90d961cf6 arm64: pgtable: make __pte_to_phys/__phys_to_pte_val inline functions
[ Upstream commit c7c386fbc2 ]

gcc warns about undefined behavior the vmalloc code when building
with CONFIG_ARM64_PA_BITS_52, when the 'idx++' in the argument to
__phys_to_pte_val() is evaluated twice:

mm/vmalloc.c: In function 'vmap_pfn_apply':
mm/vmalloc.c:2800:58: error: operation on 'data->idx' may be undefined [-Werror=sequence-point]
 2800 |         *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
      |                                                 ~~~~~~~~~^~
arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
   25 | #define __pte(x)        ((pte_t) { (x) } )
      |                                     ^
arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val'
   80 |         __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
      |               ^~~~~~~~~~~~~~~~~
mm/vmalloc.c:2800:30: note: in expansion of macro 'pfn_pte'
 2800 |         *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
      |                              ^~~~~~~

I have no idea why this never showed up earlier, but the safest
workaround appears to be changing those macros into inline functions
so the arguments get evaluated only once.

Cc: Matthew Wilcox <willy@infradead.org>
Fixes: 75387b9263 ("arm64: handle 52-bit physical addresses in page table entries")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20211105075414.2553155-1-arnd@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-18 19:17:11 +01:00
..
alpha
arc ARC: fix potential build snafu 2021-10-15 18:06:32 -07:00
arm ARM: dts: stm32: fix AV96 board SAI2 pin muxing on stm32mp15 2021-11-18 19:16:53 +01:00
arm64 arm64: pgtable: make __pte_to_phys/__phys_to_pte_val inline functions 2021-11-18 19:17:11 +01:00
csky csky: Make HAVE_TCM depend on !COMPILE_TEST 2021-10-16 07:20:12 +08:00
h8300
hexagon
ia64 ia64: don't do IA64_CMPXCHG_DEBUG without CONFIG_PRINTK 2021-11-18 19:16:13 +01:00
m68k m68k: set a default value for MEMORY_RESERVE 2021-11-18 19:17:03 +01:00
microblaze
mips mips: cm: Convert to bitfield API to fix out-of-bounds access 2021-11-18 19:16:58 +01:00
nds32 ftrace/nds32: Update the proto for ftrace_trace_function to match ftrace_stub 2021-10-27 13:00:17 -04:00
nios2 nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST 2021-10-27 09:29:07 -05:00
openrisc openrisc: fix SMP tlb flush NULL pointer dereference 2021-11-18 19:17:06 +01:00
parisc parisc/kgdb: add kgdb_roundup() to make kgdb work with idle polling 2021-11-18 19:16:21 +01:00
powerpc powerpc: Don't provide __kernel_map_pages() without ARCH_SUPPORTS_DEBUG_PAGEALLOC 2021-11-18 19:16:57 +01:00
riscv RISC-V Fixes for 5.15 (or -rc8) 2021-10-30 09:28:24 -07:00
s390 KVM: s390: Fix handle_sske page fault handling 2021-11-18 19:16:42 +01:00
sh signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL) 2021-11-18 19:17:03 +01:00
sparc sparc: Add missing "FORCE" target when using if_changed 2021-11-18 19:17:00 +01:00
um
x86 x86/sev: Fix stack type check in vc_switch_off_ist() 2021-11-18 19:16:39 +01:00
xtensa
.gitignore
Kconfig