[PATCH] x86: fix kexec with vmlinux

From: Yinghai Lu
Date: Mon Feb 02 2009 - 21:17:33 EST



Impact: fix regression with kexec with vmlinux

split data.init into data.init, percpu, data.init2 sections
instead of let data.init wrap percpu secion.

so kexec loading will be happy that there will not have overlapping.

before patch have
Elf file type is EXEC (Executable file)
Entry point 0x200000
There are 6 program headers, starting at offset 64

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000200000 0xffffffff80200000 0x0000000000200000
0x0000000000ca6000 0x0000000000ca6000 R E 200000
LOAD 0x0000000000ea6000 0xffffffff80ea6000 0x0000000000ea6000
0x000000000014dfe0 0x000000000014dfe0 RWE 200000
LOAD 0x0000000001000000 0xffffffffff600000 0x0000000000ff4000
0x0000000000000888 0x0000000000000888 RWE 200000
LOAD 0x00000000011f6000 0xffffffff80ff6000 0x0000000000ff6000
0x0000000000073086 0x0000000000a2d938 RWE 200000
LOAD 0x0000000001400000 0x0000000000000000 0x000000000106a000
0x00000000001d2ce0 0x00000000001d2ce0 RWE 200000
NOTE 0x00000000009e2c1c 0xffffffff809e2c1c 0x00000000009e2c1c
0x0000000000000024 0x0000000000000024 4

Section to Segment mapping:
Segment Sections...
00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw __ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param
01 .data .init.rodata .data.cacheline_aligned .data.read_mostly
02 .vsyscall_0 .vsyscall_fn .vsyscall_gtod_data .vsyscall_1 .vsyscall_2 .vgetcpu_mode .jiffies
03 .data.init_task .smp_locks .init.text .init.data .init.setup .initcall.init .con_initcall.init .x86_cpu_dev.init .altinstructions .altinstr_replacement .exit.text .init.ramfs .bss
04 .data.percpu
05 .notes


after patch got

Elf file type is EXEC (Executable file)
Entry point 0x200000
There are 7 program headers, starting at offset 64

Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000200000 0xffffffff80200000 0x0000000000200000
0x0000000000ca6000 0x0000000000ca6000 R E 200000
LOAD 0x0000000000ea6000 0xffffffff80ea6000 0x0000000000ea6000
0x000000000014dfe0 0x000000000014dfe0 RWE 200000
LOAD 0x0000000001000000 0xffffffffff600000 0x0000000000ff4000
0x0000000000000888 0x0000000000000888 RWE 200000
LOAD 0x00000000011f6000 0xffffffff80ff6000 0x0000000000ff6000
0x0000000000073086 0x0000000000073086 RWE 200000
LOAD 0x0000000001400000 0x0000000000000000 0x000000000106a000
0x00000000001d2ce0 0x00000000001d2ce0 RWE 200000
LOAD 0x000000000163d000 0xffffffff8123d000 0x000000000123d000
0x0000000000000000 0x00000000007e6938 RWE 200000
NOTE 0x00000000009e2c1c 0xffffffff809e2c1c 0x00000000009e2c1c
0x0000000000000024 0x0000000000000024 4

Section to Segment mapping:
Segment Sections...
00 .text .notes __ex_table .rodata __bug_table .pci_fixup .builtin_fw __ksymtab __ksymtab_gpl __ksymtab_strings __init_rodata __param
01 .data .init.rodata .data.cacheline_aligned .data.read_mostly
02 .vsyscall_0 .vsyscall_fn .vsyscall_gtod_data .vsyscall_1 .vsyscall_2 .vgetcpu_mode .jiffies
03 .data.init_task .smp_locks .init.text .init.data .init.setup .initcall.init .con_initcall.init .x86_cpu_dev.init .altinstructions .altinstr_replacement .exit.text .init.ramfs
04 .data.percpu
05 .bss
06 .notes

Signed-off-by: Yinghai Lu <yinghai@xxxxxxxxxx>

---
arch/x86/kernel/vmlinux_64.lds.S | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/x86/kernel/vmlinux_64.lds.S
===================================================================
--- linux-2.6.orig/arch/x86/kernel/vmlinux_64.lds.S
+++ linux-2.6/arch/x86/kernel/vmlinux_64.lds.S
@@ -22,6 +22,7 @@ PHDRS {
#ifdef CONFIG_SMP
percpu PT_LOAD FLAGS(7); /* RWE */
#endif
+ data.init2 PT_LOAD FLAGS(7); /* RWE */
note PT_NOTE FLAGS(0); /* ___ */
}
SECTIONS
@@ -215,7 +216,7 @@ SECTIONS
/*
* percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
* output PHDR, so the next output section - __data_nosave - should
- * switch it back to data.init. Also, pda should be at the head of
+ * start another section data.init2. Also, pda should be at the head of
* percpu area. Preallocate it and define the percpu offset symbol
* so that it can be accessed as a percpu variable.
*/
@@ -232,7 +233,7 @@ SECTIONS
__nosave_begin = .;
.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
*(.data.nosave)
- } :data.init /* switch back to data.init, see PERCPU_VADDR() above */
+ } :data.init2 /* use another section data.init2, see PERCPU_VADDR() above */
. = ALIGN(PAGE_SIZE);
__nosave_end = .;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/