Skip to content

Commit 4e0bacd

Browse files
Zhang Jianhuawilldeacon
authored andcommitted
arm64: fix build warning for ARM64_MEMSTART_SHIFT
When building with W=1, the following warning occurs. arch/arm64/include/asm/kernel-pgtable.h:129:41: error: "PUD_SHIFT" is not defined, evaluates to 0 [-Werror=undef] 129 | #define ARM64_MEMSTART_SHIFT PUD_SHIFT | ^~~~~~~~~ arch/arm64/include/asm/kernel-pgtable.h:142:5: note: in expansion of macro ‘ARM64_MEMSTART_SHIFT’ 142 | #if ARM64_MEMSTART_SHIFT < SECTION_SIZE_BITS | ^~~~~~~~~~~~~~~~~~~~ The generic PUD_SHIFT was defined in include/asm-generic/pgtable-nopud.h, however the #ifndef __ASSEMBLY__ guard in this header file makes it unavailable for assembly files. While someone .S file include the <asm/kernel-pgtable.h>, the build warning would occur. Now move the macro ARM64_MEMSTART_SHIFT and ARM64_MEMSTART_ALIGN to arch/arm64/mm/init.c where it is used only, to avoid this issue. Signed-off-by: Zhang Jianhua <chris.zjh@huawei.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/20230804075615.3334756-1-chris.zjh@huawei.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 42501f6 commit 4e0bacd

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

arch/arm64/include/asm/kernel-pgtable.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -118,31 +118,4 @@
118118
#define SWAPPER_RX_MMUFLAGS (SWAPPER_RW_MMUFLAGS | PTE_RDONLY)
119119
#endif
120120

121-
/*
122-
* To make optimal use of block mappings when laying out the linear
123-
* mapping, round down the base of physical memory to a size that can
124-
* be mapped efficiently, i.e., either PUD_SIZE (4k granule) or PMD_SIZE
125-
* (64k granule), or a multiple that can be mapped using contiguous bits
126-
* in the page tables: 32 * PMD_SIZE (16k granule)
127-
*/
128-
#if defined(CONFIG_ARM64_4K_PAGES)
129-
#define ARM64_MEMSTART_SHIFT PUD_SHIFT
130-
#elif defined(CONFIG_ARM64_16K_PAGES)
131-
#define ARM64_MEMSTART_SHIFT CONT_PMD_SHIFT
132-
#else
133-
#define ARM64_MEMSTART_SHIFT PMD_SHIFT
134-
#endif
135-
136-
/*
137-
* sparsemem vmemmap imposes an additional requirement on the alignment of
138-
* memstart_addr, due to the fact that the base of the vmemmap region
139-
* has a direct correspondence, and needs to appear sufficiently aligned
140-
* in the virtual address space.
141-
*/
142-
#if ARM64_MEMSTART_SHIFT < SECTION_SIZE_BITS
143-
#define ARM64_MEMSTART_ALIGN (1UL << SECTION_SIZE_BITS)
144-
#else
145-
#define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_SHIFT)
146-
#endif
147-
148121
#endif /* __ASM_KERNEL_PGTABLE_H */

arch/arm64/mm/init.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,33 @@ phys_addr_t __ro_after_init arm64_dma_phys_limit;
7373

7474
#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)
7575

76+
/*
77+
* To make optimal use of block mappings when laying out the linear
78+
* mapping, round down the base of physical memory to a size that can
79+
* be mapped efficiently, i.e., either PUD_SIZE (4k granule) or PMD_SIZE
80+
* (64k granule), or a multiple that can be mapped using contiguous bits
81+
* in the page tables: 32 * PMD_SIZE (16k granule)
82+
*/
83+
#if defined(CONFIG_ARM64_4K_PAGES)
84+
#define ARM64_MEMSTART_SHIFT PUD_SHIFT
85+
#elif defined(CONFIG_ARM64_16K_PAGES)
86+
#define ARM64_MEMSTART_SHIFT CONT_PMD_SHIFT
87+
#else
88+
#define ARM64_MEMSTART_SHIFT PMD_SHIFT
89+
#endif
90+
91+
/*
92+
* sparsemem vmemmap imposes an additional requirement on the alignment of
93+
* memstart_addr, due to the fact that the base of the vmemmap region
94+
* has a direct correspondence, and needs to appear sufficiently aligned
95+
* in the virtual address space.
96+
*/
97+
#if ARM64_MEMSTART_SHIFT < SECTION_SIZE_BITS
98+
#define ARM64_MEMSTART_ALIGN (1UL << SECTION_SIZE_BITS)
99+
#else
100+
#define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_SHIFT)
101+
#endif
102+
76103
static int __init reserve_crashkernel_low(unsigned long long low_size)
77104
{
78105
unsigned long long low_base;

0 commit comments

Comments
 (0)