x86_32 cleanup: KERNEL_IMAGE_SIZE
cover x86_32 cleanup: KERNEL_IMAGE_SIZE
I noticed that KERNEL_IMAGE_SIZE is no longer used by x86_32 code (head_32.S no longer uses it for the initial kernel mapping).
We can thus remove the assert from the vmlinux.lds.S file, and remove it completely for x86_32 code.
Since head_32.S doesn't use it anymore, I can't find a reason why we should impose such a limit on the kernel image size (although a 512+MB kernel image isn't what one would call a realistic scenario :P)
I think that a limit on the size of the image is imposed anyway by decompress_kernel()(if I understood correctly).
I also updated the comments in head_32.S which still had references to KERNEL_IMAGE_SIZE.
PATCH 1/2 Remove KERNEL_IMAGE_SIZE for x86_32 code(no longer used)
KERNEL_IMAGE_SIZE is no longer used by head_32.S for the kernel mapping, and thus it is no longer needed.
Remove its definition from page_32_types.h, and the assert from the vmlinux.lds.S for the 32bit executable.
--- arch/x86/include/asm/page_32_types.h | 5 ----- arch/x86/kernel/vmlinux.lds.S | 13 ++++--------- 2 files changed, 4 insertions(+), 14 deletions(-)
arch/x86/include/asm/page_32_types.h +0 -5
@@ -35,11 +35,6 @@#define __VIRTUAL_MASK_SHIFT 32#endif /* CONFIG_X86_PAE */ -/* -* Kernel image size is limited to 512 MB (see in arch/x86/kernel/head_32.S) -*/ -#define KERNEL_IMAGE_SIZE (512 * 1024 * 1024) -#ifndef __ASSEMBLY__/*
arch/x86/kernel/vmlinux.lds.S +4 -9
@@ -362,13 +362,7 @@ SECTIONS } -#ifdef CONFIG_X86_32 -/* - * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: - */ -. = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), - "kernel image bigger than KERNEL_IMAGE_SIZE"); -#else +#ifdef CONFIG_X86_64 /* * Per-cpu symbols which need to be offset from __per_cpu_load * for the boot processor.
@@ -378,7 +372,8 @@ INIT_PER_CPU(gdt_page); INIT_PER_CPU(irq_stack_union); /* - * Build-time check on the image size: + * Build-time check on the image size. + * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility. */ . = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), "kernel image bigger than KERNEL_IMAGE_SIZE");
@@ -388,7 +383,7 @@ INIT_PER_CPU(irq_stack_union); "irq_stack_union is not at start of per-cpu area"); #endif -#endif /* CONFIG_X86_32 */ +#endif /* CONFIG_X86_64 */ #ifdef CONFIG_KEXEC #include <asm/kexec.h>
Signature · 1 line
1.7.4.1
PATCH 2/2 head_32.S: Update the comments for the initial kernel mapping(KERNEL_IMAGE_SIZE no longer used)
In reply to Stratos PsomadakisUpdate the comments regarding the initial kernel mapping in head_32.S and cleanup the code(KERNEL_IMAGE_SIZE no longer used).
--- arch/x86/kernel/head_32.S | 44 +++++++++++++++++--------------------------- 1 files changed, 17 insertions(+), 27 deletions(-)
arch/x86/kernel/head_32.S +17 -27
@@ -39,42 +39,32 @@ #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id /* - * This is how much memory in addition to the memory covered up to - * and including _end we need mapped initially. - * We need: - * (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) - * (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) - * - * Modulo rounding, each megabyte assigned here requires a kilobyte of - * memory, which is currently unreclaimed. - * - * This should be a multiple of a page. - * - * KERNEL_IMAGE_SIZE should be greater than pa(_end) - * and small than max_low_pfn, otherwise will waste some page table entries + * Worst-case size of the kernel mapping we need to make: + * a relocatable kernel can live anywhere in lowmem, so we need to be able + * to map all of lowmem. */ -#if PTRS_PER_PMD > 1 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) -#else -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD) -#endif - /* Number of possible pages in the lowmem region */ LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT) - -/* Enough space to fit pagetables for the low memory linear map */ -MAPPING_BEYOND_END = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT /* - * Worst-case size of the kernel mapping we need to make: - * a relocatable kernel can live anywhere in lowmem, so we need to be able - * to map all of lowmem. + * This is the size of the pagetable(in pages) we need for the kernel mapping. + * We need: + * LOWMEM_PAGES / 1024 pages (worst case, non PAE) + * LOWMEM_PAGES / 512 + 4 pages (worst casem, PAE) */ -KERNEL_PAGES = LOWMEM_PAGES -INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE +#if PTRS_PER_PMD > 1 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PMD) + PTRS_PER_PGD +#else +#define PAGE_TABLE_SIZE(pages) (pages) / PTRS_PER_PGD +#endif + +INIT_MAP_SIZE = PAGE_TABLE_SIZE(LOWMEM_PAGES) << PAGE_SHIFT RESERVE_BRK(pagetables, INIT_MAP_SIZE) + +/* Map enough space after _end for the lowmem linear map */ +MAPPING_BEYOND_END = INIT_MAP_SIZE /* * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
Signature · 1 line
1.7.4.1
Quoted 14 lines · Stratos Psomadakis
I noticed that
KERNEL_IMAGE_SIZEis no longer used byx86_32code (head_32.Sno longer uses it for the initial kernel mapping).We can thus remove the assert from the
vmlinux.lds.Sfile, and remove it completely forx86_32code.Since
head_32.Sdoesn't use it anymore, I can't find a reason why we should impose such a limit on the kernel image size (although a 512+MB kernel image isn't what one would call a realistic scenario :P)I think that a limit on the size of the image is imposed anyway by decompress_kernel()(if I understood correctly).
Quoted 8 lines
I also updated the comments in
head_32.Swhich still had references toKERNEL_IMAGE_SIZE.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
added cc, just in case anyone is interested
Signature · 2 lines
Stratos Psomadakis <[email protected]>