i386 boot pagetables cleanup part 2
PATCH 1/1 i386 boot pagetables cleanup part 2
Reorganize i386/kernel/head.S to eliminate the .org directives.
- boot_pgtables move to .data.init so they can be reclaimed after the final pagetables are set up.
- empty_zero_page and swapper_pg_dir move to .data.page_aligned
- the IDT and GDT descriptors are moved to .data
The end effect is that we can now fully use the first page of head.S saving about half a page of memory.
--
Brian Gerst
arch/i386/kernel/head.S +36 -47
@@ -339,6 +339,19 @@ iret /* + * Real beginning of normal "text" segment + */ +ENTRY(stext) +ENTRY(_stext) + +/* + * This starts the data section. Note that the above is all + * in the text section because it has alignment requirements + * that we cannot fulfill any other way. + */ +.data + +/* * The IDT and GDT 'descriptors' are a strange 48-bit object * only used by the lidt and lgdt instructions. They are not * like usual segment descriptors - they consist of a 16-bit
@@ -362,53 +375,6 @@ .fill NR_CPUS-1,6,0 # space for the other GDT descriptors -/* - * This is initialized to create an identity-mapping at 0-8M (for bootup - * purposes) and another mapping of the 0-8M area at virtual address - * PAGE_OFFSET. - */ -.org 0x1000 -ENTRY(swapper_pg_dir) - .long 0x0007 + __PA(boot_pgtables) - .long 0x1007 + __PA(boot_pgtables) - /* default: 766 entries */ - .fill BOOT_USER_PGD_PTRS-2,4,0 - .long 0x0007 + __PA(boot_pgtables) - .long 0x1007 + __PA(boot_pgtables) - /* default: 254 entries */ - .fill BOOT_KERNEL_PGD_PTRS-2,4,0 - -/* - * The page tables are initialized to only 8MB here - the final page - * tables are set up later depending on memory size. - */ -.org 0x2000 -boot_pgtables: - -/* - * empty_zero_page must immediately follow the page tables ! (The - * initialization loop counts until empty_zero_page) - */ - -.org 0x4000 -boot_pgtables_end: -ENTRY(empty_zero_page) - -.org 0x5000 - -/* - * Real beginning of normal "text" segment - */ -ENTRY(stext) -ENTRY(_stext) - -/* - * This starts the data section. Note that the above is all - * in the text section because it has alignment requirements - * that we cannot fulfill any other way. - */ -.data - ALIGN /* * The Global Descriptor Table contains 20 quadwords, per-CPU.
@@ -444,3 +410,26 @@ .fill (NR_CPUS-1)*GDT_ENTRIES,8,0 /* other CPU's GDT */ #endif +.section .data.page_aligned, "aw" +ENTRY(empty_zero_page) + .fill 4096,1,0 + +/* + * This is initialized to create an identity-mapping at 0-8M (for bootup + * purposes) and another mapping of the 0-8M area at virtual address + * PAGE_OFFSET. + */ +ENTRY(swapper_pg_dir) + .long 0x0007 + __PA(boot_pgtables) + .long 0x1007 + __PA(boot_pgtables) + /* default: 766 entries */ + .fill BOOT_USER_PGD_PTRS-2,4,0 + .long 0x0007 + __PA(boot_pgtables) + .long 0x1007 + __PA(boot_pgtables) + /* default: 254 entries */ + .fill BOOT_KERNEL_PGD_PTRS-2,4,0 + +.section .data.boot_pgtable, "aw" +boot_pgtables: + .fill 2*4096,1,0 +boot_pgtables_end:
arch/i386/vmlinux.lds +2 -1
@@ -63,6 +63,7 @@ .data.percpu : { *(.data.percpu) } __per_cpu_end = .; . = ALIGN(4096); + .data.boot_pgtable : { *(.data.boot_pgtable) } __init_end = .; . = ALIGN(4096);
@@ -72,7 +73,7 @@ __nosave_end = .; . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } + .data.page_aligned : { *(.data.page_aligned) *(.data.idt) } . = ALIGN(32); .data.cacheline_aligned : { *(.data.cacheline_aligned) }