Skip to content

Commit 36e5cd6

Browse files
Ard Biesheuvelwildea01
authored andcommitted
arm64: account for sparsemem section alignment when choosing vmemmap offset
Commit dfd55ad ("arm64: vmemmap: use virtual projection of linear region") fixed an issue where the struct page array would overflow into the adjacent virtual memory region if system RAM was placed so high up in physical memory that its addresses were not representable in the build time configured virtual address size. However, the fix failed to take into account that the vmemmap region needs to be relatively aligned with respect to the sparsemem section size, so that a sequence of page structs corresponding with a sparsemem section in the linear region appears naturally aligned in the vmemmap region. So round up vmemmap to sparsemem section size. Since this essentially moves the projection of the linear region up in memory, also revert the reduction of the size of the vmemmap region. Cc: <stable@vger.kernel.org> Fixes: dfd55ad ("arm64: vmemmap: use virtual projection of linear region") Tested-by: Mark Langsdorf <mlangsdo@redhat.com> Tested-by: David Daney <david.daney@cavium.com> Tested-by: Robert Richter <rrichter@cavium.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent f6cede5 commit 36e5cd6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* VMALLOC_END: extends to the available space below vmmemmap, PCI I/O space,
4141
* fixed mappings and modules
4242
*/
43-
#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT - 1)) * sizeof(struct page), PUD_SIZE)
43+
#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT)) * sizeof(struct page), PUD_SIZE)
4444

4545
#ifndef CONFIG_KASAN
4646
#define VMALLOC_START (VA_START)
@@ -52,7 +52,8 @@
5252
#define VMALLOC_END (PAGE_OFFSET - PUD_SIZE - VMEMMAP_SIZE - SZ_64K)
5353

5454
#define VMEMMAP_START (VMALLOC_END + SZ_64K)
55-
#define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT))
55+
#define vmemmap ((struct page *)VMEMMAP_START - \
56+
SECTION_ALIGN_DOWN(memstart_addr >> PAGE_SHIFT))
5657

5758
#define FIRST_USER_ADDRESS 0UL
5859

0 commit comments

Comments
 (0)