Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: e820: Remove conditional early mapping in parse_e820_ext

This patch ensures that the memory passed from parse_setup_data() is
large enough to cover the complete data structure. That means that the
conditional mapping in parse_e820_ext() can go.

While here, I also attempt not to map two pages if the address is not
aligned to a page boundary.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Cc: sodaville@linutronix.de
Cc: devicetree-discuss@lists.ozlabs.org
LKML-Reference: <1298405266-1624-2-git-send-email-bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Sebastian Andrzej Siewior and committed by
Thomas Gleixner
f1c2b357 cb4cfd56

+16 -11
+1 -1
arch/x86/include/asm/e820.h
··· 96 96 extern int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize, 97 97 unsigned long start_addr, unsigned long long end_addr); 98 98 struct setup_data; 99 - extern void parse_e820_ext(struct setup_data *data, unsigned long pa_data); 99 + extern void parse_e820_ext(struct setup_data *data); 100 100 101 101 #if defined(CONFIG_X86_64) || \ 102 102 (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
+1 -7
arch/x86/kernel/e820.c
··· 667 667 * boot_params.e820_map, others are passed via SETUP_E820_EXT node of 668 668 * linked list of struct setup_data, which is parsed here. 669 669 */ 670 - void __init parse_e820_ext(struct setup_data *sdata, unsigned long pa_data) 670 + void __init parse_e820_ext(struct setup_data *sdata) 671 671 { 672 - u32 map_len; 673 672 int entries; 674 673 struct e820entry *extmap; 675 674 676 675 entries = sdata->len / sizeof(struct e820entry); 677 - map_len = sdata->len + sizeof(struct setup_data); 678 - if (map_len > PAGE_SIZE) 679 - sdata = early_ioremap(pa_data, map_len); 680 676 extmap = (struct e820entry *)(sdata->data); 681 677 __append_e820_map(extmap, entries); 682 678 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 683 - if (map_len > PAGE_SIZE) 684 - early_iounmap(sdata, map_len); 685 679 printk(KERN_INFO "extended physical RAM map:\n"); 686 680 e820_print_map("extended"); 687 681 }
+14 -3
arch/x86/kernel/setup.c
··· 429 429 return; 430 430 pa_data = boot_params.hdr.setup_data; 431 431 while (pa_data) { 432 - data = early_memremap(pa_data, PAGE_SIZE); 432 + u32 data_len, map_len; 433 + 434 + map_len = max(PAGE_SIZE - (pa_data & ~PAGE_MASK), 435 + (u64)sizeof(struct setup_data)); 436 + data = early_memremap(pa_data, map_len); 437 + data_len = data->len + sizeof(struct setup_data); 438 + if (data_len > map_len) { 439 + early_iounmap(data, map_len); 440 + data = early_memremap(pa_data, data_len); 441 + map_len = data_len; 442 + } 443 + 433 444 switch (data->type) { 434 445 case SETUP_E820_EXT: 435 - parse_e820_ext(data, pa_data); 446 + parse_e820_ext(data); 436 447 break; 437 448 default: 438 449 break; 439 450 } 440 451 pa_data = data->next; 441 - early_iounmap(data, PAGE_SIZE); 452 + early_iounmap(data, map_len); 442 453 } 443 454 } 444 455