Commit 88f3aec7 authored by Ingo Molnar's avatar Ingo Molnar

x86: fix spontaneous reboot with allyesconfig bzImage

recently the 64-bit allyesconfig bzImage kernel started spontaneously
rebooting during early bootup.

after a few fun hours spent with early init debugging, it turns out
that we've got this rather annoying limit on the size of the kernel
image:

      #define KERNEL_TEXT_SIZE  (40*1024*1024)

which limit my vmlinux just happened to pass:

       text           data       bss        dec       hex   filename
   29703744        4222751   8646224c   42572719   2899baf   vmlinux

40 MB is 42572719 bytes, so my vmlinux was just 1.5% above this limit :-/

So it happily crashed right in head_64.S, which - as we all know - is
the most debuggable code in the whole architecture ;-)

So increase the limit to allow an up to 128MB kernel image to be mapped.
(should anyone be that crazy or lazy)

We have a full 4K of pagetable (level2_kernel_pgt) allocated for these
mappings already, so there's no RAM overhead and the limit was rather
pointless and arbitrary.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 3b57bc46
...@@ -379,18 +379,24 @@ NEXT_PAGE(level2_ident_pgt) ...@@ -379,18 +379,24 @@ NEXT_PAGE(level2_ident_pgt)
/* Since I easily can, map the first 1G. /* Since I easily can, map the first 1G.
* Don't set NX because code runs from these pages. * Don't set NX because code runs from these pages.
*/ */
PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD) PMDS(0, __PAGE_KERNEL_LARGE_EXEC, PTRS_PER_PMD)
NEXT_PAGE(level2_kernel_pgt) NEXT_PAGE(level2_kernel_pgt)
/* 40MB kernel mapping. The kernel code cannot be bigger than that. /*
When you change this change KERNEL_TEXT_SIZE in page.h too. */ * 128 MB kernel mapping. We spend a full page on this pagetable
/* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */ * anyway.
PMDS(0x0000000000000000, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL, KERNEL_TEXT_SIZE/PMD_SIZE) *
/* Module mapping starts here */ * The kernel code+data+bss must not be bigger than that.
.fill (PTRS_PER_PMD - (KERNEL_TEXT_SIZE/PMD_SIZE)),8,0 *
* (NOTE: at +128MB starts the module area, see MODULES_VADDR.
* If you want to increase this then increase MODULES_VADDR
* too.)
*/
PMDS(0, __PAGE_KERNEL_LARGE_EXEC|_PAGE_GLOBAL,
KERNEL_TEXT_SIZE/PMD_SIZE)
NEXT_PAGE(level2_spare_pgt) NEXT_PAGE(level2_spare_pgt)
.fill 512,8,0 .fill 512, 8, 0
#undef PMDS #undef PMDS
#undef NEXT_PAGE #undef NEXT_PAGE
......
...@@ -172,8 +172,9 @@ set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot) ...@@ -172,8 +172,9 @@ set_pte_phys(unsigned long vaddr, unsigned long phys, pgprot_t prot)
} }
/* /*
* The head.S code sets up the kernel high mapping from: * The head.S code sets up the kernel high mapping:
* __START_KERNEL_map to __START_KERNEL_map + KERNEL_TEXT_SIZE *
* from __START_KERNEL_map to __START_KERNEL_map + size (== _end-_text)
* *
* phys_addr holds the negative offset to the kernel, which is added * phys_addr holds the negative offset to the kernel, which is added
* to the compile time generated pmds. This results in invalid pmds up * to the compile time generated pmds. This results in invalid pmds up
......
...@@ -47,7 +47,11 @@ ...@@ -47,7 +47,11 @@
#define __PHYSICAL_MASK_SHIFT 46 #define __PHYSICAL_MASK_SHIFT 46
#define __VIRTUAL_MASK_SHIFT 48 #define __VIRTUAL_MASK_SHIFT 48
#define KERNEL_TEXT_SIZE (40*1024*1024) /*
* Kernel image size is limited to 128 MB (see level2_kernel_pgt in
* arch/x86/kernel/head_64.S), and it is mapped here:
*/
#define KERNEL_TEXT_SIZE (128*1024*1024)
#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL) #define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment