Skip to content

Commit 147dd56

Browse files
author
H. Peter Anvin
committed
x86-32: Make sure we can map all of lowmem if we need to
A relocatable kernel can be anywhere in lowmem -- and in the case of a kdump kernel, is likely to be fairly high. Since the early page tables map everything from address zero up we need to make sure we allocate enough brk that we can map all of lowmem if we need to. Reported-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Tested-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <4D0AD3ED.8070607@kernel.org>
1 parent 7f99d94 commit 147dd56

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎arch/x86/boot/compressed/misc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
355355
if (heap > 0x3fffffffffffUL)
356356
error("Destination address too large");
357357
#else
358-
if (heap > ((-__PAGE_OFFSET-(512<<20)-1) & 0x7fffffff))
358+
if (heap > ((-__PAGE_OFFSET-(128<<20)-1) & 0x7fffffff))
359359
error("Destination address too large");
360360
#endif
361361
#ifndef CONFIG_RELOCATABLE

‎arch/x86/kernel/head_32.S‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,18 @@
6060
#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
6161
#endif
6262

63+
/* Number of possible pages in the lowmem region */
64+
LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
65+
6366
/* Enough space to fit pagetables for the low memory linear map */
64-
MAPPING_BEYOND_END = \
65-
PAGE_TABLE_SIZE(((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) << PAGE_SHIFT
67+
MAPPING_BEYOND_END = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT
6668

6769
/*
6870
* Worst-case size of the kernel mapping we need to make:
69-
* the worst-case size of the kernel itself, plus the extra we need
70-
* to map for the linear map.
71+
* a relocatable kernel can live anywhere in lowmem, so we need to be able
72+
* to map all of lowmem.
7173
*/
72-
KERNEL_PAGES = (KERNEL_IMAGE_SIZE + MAPPING_BEYOND_END)>>PAGE_SHIFT
74+
KERNEL_PAGES = LOWMEM_PAGES
7375

7476
INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE_asm
7577
RESERVE_BRK(pagetables, INIT_MAP_SIZE)

0 commit comments

Comments
 (0)