Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: choose memstart_addr based on minimum sparsemem section alignment

This redefines ARM64_MEMSTART_ALIGN in terms of the minimal alignment
required by sparsemem vmemmap. This comes down to using 1 GB for all
translation granules if CONFIG_SPARSEMEM_VMEMMAP is enabled.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>

authored by

Ard Biesheuvel and committed by
Will Deacon
06e9bf2f 2958987f

+18 -3
+18 -3
arch/arm64/include/asm/kernel-pgtable.h
··· 19 19 #ifndef __ASM_KERNEL_PGTABLE_H 20 20 #define __ASM_KERNEL_PGTABLE_H 21 21 22 + #include <asm/sparsemem.h> 22 23 23 24 /* 24 25 * The linear mapping and the start of memory are both 2M aligned (per ··· 87 86 * (64k granule), or a multiple that can be mapped using contiguous bits 88 87 * in the page tables: 32 * PMD_SIZE (16k granule) 89 88 */ 90 - #ifdef CONFIG_ARM64_64K_PAGES 91 - #define ARM64_MEMSTART_ALIGN SZ_512M 89 + #if defined(CONFIG_ARM64_4K_PAGES) 90 + #define ARM64_MEMSTART_SHIFT PUD_SHIFT 91 + #elif defined(CONFIG_ARM64_16K_PAGES) 92 + #define ARM64_MEMSTART_SHIFT (PMD_SHIFT + 5) 92 93 #else 93 - #define ARM64_MEMSTART_ALIGN SZ_1G 94 + #define ARM64_MEMSTART_SHIFT PMD_SHIFT 95 + #endif 96 + 97 + /* 98 + * sparsemem vmemmap imposes an additional requirement on the alignment of 99 + * memstart_addr, due to the fact that the base of the vmemmap region 100 + * has a direct correspondence, and needs to appear sufficiently aligned 101 + * in the virtual address space. 102 + */ 103 + #if defined(CONFIG_SPARSEMEM_VMEMMAP) && ARM64_MEMSTART_SHIFT < SECTION_SIZE_BITS 104 + #define ARM64_MEMSTART_ALIGN (1UL << SECTION_SIZE_BITS) 105 + #else 106 + #define ARM64_MEMSTART_ALIGN (1UL << ARM64_MEMSTART_SHIFT) 94 107 #endif 95 108 96 109 #endif /* __ASM_KERNEL_PGTABLE_H */