Skip to content

Commit b7a67e0

Browse files
yu-chen-surfIngo Molnar
authored andcommitted
x86/boot/e820: Avoid overwriting e820_table_firmware
The following commit in 2013: 77ea8c9 ("x86: Reserve setup_data ranges late after parsing memmap cmdline") has fixed the issue of losing setup_data information by deferring the e820_reserve_setup_data() call until the early params have been parsed. But this also introduced a new problem that, during early params parsing, the kexec kernel might fake a mptable and saves it into the e820_table_firmware[] table (without saving the mptable to the e820_table[]), however the subsequent invoking of e820_reserve_setup_data() will overwrite the e820_table_firmware[] according to the e820_table[], thus the fake mptable information is lost. Fix this issue by updating the e820_table_firmware[] according to the setup_data information, but without overwriting it. Signed-off-by: Chen Yu <[email protected]> Cc: Dave Young <[email protected]> Cc: Len Brown <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Xunlei Pang <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 99c13b8 commit b7a67e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/kernel/e820.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,8 @@ void __init e820__memory_setup_extended(u64 phys_addr, u32 data_len)
669669
__append_e820_table(extmap, entries);
670670
e820__update_table(e820_table);
671671

672+
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));
673+
672674
early_memunmap(sdata, data_len);
673675
pr_info("e820: extended physical RAM map:\n");
674676
e820__print_table("extended");
@@ -923,13 +925,13 @@ void __init e820__reserve_setup_data(void)
923925
while (pa_data) {
924926
data = early_memremap(pa_data, sizeof(*data));
925927
e820__range_update(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN);
928+
e820__range_update_firmware(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN);
926929
pa_data = data->next;
927930
early_memunmap(data, sizeof(*data));
928931
}
929932

930933
e820__update_table(e820_table);
931-
932-
memcpy(e820_table_firmware, e820_table, sizeof(*e820_table_firmware));
934+
e820__update_table(e820_table_firmware);
933935

934936
pr_info("extended physical RAM map:\n");
935937
e820__print_table("reserve setup_data");

0 commit comments

Comments
 (0)