aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-10-03 19:46:53 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-10-03 19:46:53 -0400
commit3ef0a61a467639cf7def299309cd9ea524c3e1c1 (patch)
treee280447dabdf810caae1ebbc6a5ef728f2ae326b
parent1a4a2bc460721bc8f91e4c1294d39b38e5af132f (diff)
parent917db484dc6a69969d317b3e57add4208a8d9d42 (diff)
Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 boot updates from Ingo Molnar: "The changes in this cycle were: - Save e820 table RAM footprint on larger kernel configurations. (Denys Vlasenko) - pmem related fixes (Dan Williams) - theoretical e820 boundary condition fix (Wei Yang)" * 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Fix kdump, cleanup aborted E820_PRAM max_pfn manipulation x86/e820: Use much less memory for e820/e820_saved, save up to 120k x86/e820: Prepare e280 code for switch to dynamic storage x86/e820: Mark some static functions __init x86/e820: Fix very large 'size' handling boundary condition
-rw-r--r--arch/x86/include/asm/e820.h6
-rw-r--r--arch/x86/kernel/e820.c155
-rw-r--r--arch/x86/kernel/early-quirks.c2
-rw-r--r--arch/x86/kernel/kexec-bzimage64.c4
-rw-r--r--arch/x86/kernel/resource.c4
-rw-r--r--arch/x86/kernel/setup.c8
-rw-r--r--arch/x86/kernel/tboot.c8
-rw-r--r--arch/x86/mm/init.c4
-rw-r--r--arch/x86/platform/efi/efi.c2
-rw-r--r--arch/x86/xen/setup.c2
10 files changed, 112 insertions, 83 deletions
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h
index 3ab0537872fb..476b574de99e 100644
--- a/arch/x86/include/asm/e820.h
+++ b/arch/x86/include/asm/e820.h
@@ -10,8 +10,8 @@
10#include <uapi/asm/e820.h> 10#include <uapi/asm/e820.h>
11#ifndef __ASSEMBLY__ 11#ifndef __ASSEMBLY__
12/* see comment in arch/x86/kernel/e820.c */ 12/* see comment in arch/x86/kernel/e820.c */
13extern struct e820map e820; 13extern struct e820map *e820;
14extern struct e820map e820_saved; 14extern struct e820map *e820_saved;
15 15
16extern unsigned long pci_mem_start; 16extern unsigned long pci_mem_start;
17extern int e820_any_mapped(u64 start, u64 end, unsigned type); 17extern int e820_any_mapped(u64 start, u64 end, unsigned type);
@@ -53,6 +53,8 @@ extern void e820_reserve_resources_late(void);
53extern void setup_memory_map(void); 53extern void setup_memory_map(void);
54extern char *default_machine_specific_memory_setup(void); 54extern char *default_machine_specific_memory_setup(void);
55 55
56extern void e820_reallocate_tables(void);
57
56/* 58/*
57 * Returns true iff the specified range [s,e) is completely contained inside 59 * Returns true iff the specified range [s,e) is completely contained inside
58 * the ISA region. 60 * the ISA region.
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 621b501f8935..b85fe5f91c3f 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -40,8 +40,10 @@
40 * user can e.g. boot the original kernel with mem=1G while still booting the 40 * user can e.g. boot the original kernel with mem=1G while still booting the
41 * next kernel with full memory. 41 * next kernel with full memory.
42 */ 42 */
43struct e820map e820; 43static struct e820map initial_e820 __initdata;
44struct e820map e820_saved; 44static struct e820map initial_e820_saved __initdata;
45struct e820map *e820 __refdata = &initial_e820;
46struct e820map *e820_saved __refdata = &initial_e820_saved;
45 47
46/* For PCI or other memory-mapped resources */ 48/* For PCI or other memory-mapped resources */
47unsigned long pci_mem_start = 0xaeedbabe; 49unsigned long pci_mem_start = 0xaeedbabe;
@@ -58,8 +60,8 @@ e820_any_mapped(u64 start, u64 end, unsigned type)
58{ 60{
59 int i; 61 int i;
60 62
61 for (i = 0; i < e820.nr_map; i++) { 63 for (i = 0; i < e820->nr_map; i++) {
62 struct e820entry *ei = &e820.map[i]; 64 struct e820entry *ei = &e820->map[i];
63 65
64 if (type && ei->type != type) 66 if (type && ei->type != type)
65 continue; 67 continue;
@@ -81,8 +83,8 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type)
81{ 83{
82 int i; 84 int i;
83 85
84 for (i = 0; i < e820.nr_map; i++) { 86 for (i = 0; i < e820->nr_map; i++) {
85 struct e820entry *ei = &e820.map[i]; 87 struct e820entry *ei = &e820->map[i];
86 88
87 if (type && ei->type != type) 89 if (type && ei->type != type)
88 continue; 90 continue;
@@ -128,7 +130,7 @@ static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
128 130
129void __init e820_add_region(u64 start, u64 size, int type) 131void __init e820_add_region(u64 start, u64 size, int type)
130{ 132{
131 __e820_add_region(&e820, start, size, type); 133 __e820_add_region(e820, start, size, type);
132} 134}
133 135
134static void __init e820_print_type(u32 type) 136static void __init e820_print_type(u32 type)
@@ -164,12 +166,12 @@ void __init e820_print_map(char *who)
164{ 166{
165 int i; 167 int i;
166 168
167 for (i = 0; i < e820.nr_map; i++) { 169 for (i = 0; i < e820->nr_map; i++) {
168 printk(KERN_INFO "%s: [mem %#018Lx-%#018Lx] ", who, 170 printk(KERN_INFO "%s: [mem %#018Lx-%#018Lx] ", who,
169 (unsigned long long) e820.map[i].addr, 171 (unsigned long long) e820->map[i].addr,
170 (unsigned long long) 172 (unsigned long long)
171 (e820.map[i].addr + e820.map[i].size - 1)); 173 (e820->map[i].addr + e820->map[i].size - 1));
172 e820_print_type(e820.map[i].type); 174 e820_print_type(e820->map[i].type);
173 printk(KERN_CONT "\n"); 175 printk(KERN_CONT "\n");
174 } 176 }
175} 177}
@@ -348,7 +350,7 @@ int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
348 * continue building up new bios map based on this 350 * continue building up new bios map based on this
349 * information 351 * information
350 */ 352 */
351 if (current_type != last_type || current_type == E820_PRAM) { 353 if (current_type != last_type) {
352 if (last_type != 0) { 354 if (last_type != 0) {
353 new_bios[new_bios_entry].size = 355 new_bios[new_bios_entry].size =
354 change_point[chgidx]->addr - last_addr; 356 change_point[chgidx]->addr - last_addr;
@@ -388,11 +390,11 @@ static int __init __append_e820_map(struct e820entry *biosmap, int nr_map)
388 while (nr_map) { 390 while (nr_map) {
389 u64 start = biosmap->addr; 391 u64 start = biosmap->addr;
390 u64 size = biosmap->size; 392 u64 size = biosmap->size;
391 u64 end = start + size; 393 u64 end = start + size - 1;
392 u32 type = biosmap->type; 394 u32 type = biosmap->type;
393 395
394 /* Overflow in 64 bits? Ignore the memory map. */ 396 /* Overflow in 64 bits? Ignore the memory map. */
395 if (start > end) 397 if (start > end && likely(size))
396 return -1; 398 return -1;
397 399
398 e820_add_region(start, size, type); 400 e820_add_region(start, size, type);
@@ -493,13 +495,13 @@ static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
493u64 __init e820_update_range(u64 start, u64 size, unsigned old_type, 495u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
494 unsigned new_type) 496 unsigned new_type)
495{ 497{
496 return __e820_update_range(&e820, start, size, old_type, new_type); 498 return __e820_update_range(e820, start, size, old_type, new_type);
497} 499}
498 500
499static u64 __init e820_update_range_saved(u64 start, u64 size, 501static u64 __init e820_update_range_saved(u64 start, u64 size,
500 unsigned old_type, unsigned new_type) 502 unsigned old_type, unsigned new_type)
501{ 503{
502 return __e820_update_range(&e820_saved, start, size, old_type, 504 return __e820_update_range(e820_saved, start, size, old_type,
503 new_type); 505 new_type);
504} 506}
505 507
@@ -521,8 +523,8 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
521 e820_print_type(old_type); 523 e820_print_type(old_type);
522 printk(KERN_CONT "\n"); 524 printk(KERN_CONT "\n");
523 525
524 for (i = 0; i < e820.nr_map; i++) { 526 for (i = 0; i < e820->nr_map; i++) {
525 struct e820entry *ei = &e820.map[i]; 527 struct e820entry *ei = &e820->map[i];
526 u64 final_start, final_end; 528 u64 final_start, final_end;
527 u64 ei_end; 529 u64 ei_end;
528 530
@@ -566,15 +568,15 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
566 568
567void __init update_e820(void) 569void __init update_e820(void)
568{ 570{
569 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map)) 571 if (sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map))
570 return; 572 return;
571 printk(KERN_INFO "e820: modified physical RAM map:\n"); 573 printk(KERN_INFO "e820: modified physical RAM map:\n");
572 e820_print_map("modified"); 574 e820_print_map("modified");
573} 575}
574static void __init update_e820_saved(void) 576static void __init update_e820_saved(void)
575{ 577{
576 sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map), 578 sanitize_e820_map(e820_saved->map, ARRAY_SIZE(e820_saved->map),
577 &e820_saved.nr_map); 579 &e820_saved->nr_map);
578} 580}
579#define MAX_GAP_END 0x100000000ull 581#define MAX_GAP_END 0x100000000ull
580/* 582/*
@@ -584,14 +586,14 @@ __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
584 unsigned long start_addr, unsigned long long end_addr) 586 unsigned long start_addr, unsigned long long end_addr)
585{ 587{
586 unsigned long long last; 588 unsigned long long last;
587 int i = e820.nr_map; 589 int i = e820->nr_map;
588 int found = 0; 590 int found = 0;
589 591
590 last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END; 592 last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END;
591 593
592 while (--i >= 0) { 594 while (--i >= 0) {
593 unsigned long long start = e820.map[i].addr; 595 unsigned long long start = e820->map[i].addr;
594 unsigned long long end = start + e820.map[i].size; 596 unsigned long long end = start + e820->map[i].size;
595 597
596 if (end < start_addr) 598 if (end < start_addr)
597 continue; 599 continue;
@@ -649,6 +651,33 @@ __init void e820_setup_gap(void)
649 gapstart, gapstart + gapsize - 1); 651 gapstart, gapstart + gapsize - 1);
650} 652}
651 653
654/*
655 * Called late during init, in free_initmem().
656 *
657 * Initial e820 and e820_saved are largish __initdata arrays.
658 * Copy them to (usually much smaller) dynamically allocated area.
659 * This is done after all tweaks we ever do to them:
660 * all functions which modify them are __init functions,
661 * they won't exist after this point.
662 */
663__init void e820_reallocate_tables(void)
664{
665 struct e820map *n;
666 int size;
667
668 size = offsetof(struct e820map, map) + sizeof(struct e820entry) * e820->nr_map;
669 n = kmalloc(size, GFP_KERNEL);
670 BUG_ON(!n);
671 memcpy(n, e820, size);
672 e820 = n;
673
674 size = offsetof(struct e820map, map) + sizeof(struct e820entry) * e820_saved->nr_map;
675 n = kmalloc(size, GFP_KERNEL);
676 BUG_ON(!n);
677 memcpy(n, e820_saved, size);
678 e820_saved = n;
679}
680
652/** 681/**
653 * Because of the size limitation of struct boot_params, only first 682 * Because of the size limitation of struct boot_params, only first
654 * 128 E820 memory entries are passed to kernel via 683 * 128 E820 memory entries are passed to kernel via
@@ -665,7 +694,7 @@ void __init parse_e820_ext(u64 phys_addr, u32 data_len)
665 entries = sdata->len / sizeof(struct e820entry); 694 entries = sdata->len / sizeof(struct e820entry);
666 extmap = (struct e820entry *)(sdata->data); 695 extmap = (struct e820entry *)(sdata->data);
667 __append_e820_map(extmap, entries); 696 __append_e820_map(extmap, entries);
668 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 697 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
669 early_memunmap(sdata, data_len); 698 early_memunmap(sdata, data_len);
670 printk(KERN_INFO "e820: extended physical RAM map:\n"); 699 printk(KERN_INFO "e820: extended physical RAM map:\n");
671 e820_print_map("extended"); 700 e820_print_map("extended");
@@ -686,8 +715,8 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
686 int i; 715 int i;
687 unsigned long pfn = 0; 716 unsigned long pfn = 0;
688 717
689 for (i = 0; i < e820.nr_map; i++) { 718 for (i = 0; i < e820->nr_map; i++) {
690 struct e820entry *ei = &e820.map[i]; 719 struct e820entry *ei = &e820->map[i];
691 720
692 if (pfn < PFN_UP(ei->addr)) 721 if (pfn < PFN_UP(ei->addr))
693 register_nosave_region(pfn, PFN_UP(ei->addr)); 722 register_nosave_region(pfn, PFN_UP(ei->addr));
@@ -712,8 +741,8 @@ static int __init e820_mark_nvs_memory(void)
712{ 741{
713 int i; 742 int i;
714 743
715 for (i = 0; i < e820.nr_map; i++) { 744 for (i = 0; i < e820->nr_map; i++) {
716 struct e820entry *ei = &e820.map[i]; 745 struct e820entry *ei = &e820->map[i];
717 746
718 if (ei->type == E820_NVS) 747 if (ei->type == E820_NVS)
719 acpi_nvs_register(ei->addr, ei->size); 748 acpi_nvs_register(ei->addr, ei->size);
@@ -754,22 +783,18 @@ u64 __init early_reserve_e820(u64 size, u64 align)
754/* 783/*
755 * Find the highest page frame number we have available 784 * Find the highest page frame number we have available
756 */ 785 */
757static unsigned long __init e820_end_pfn(unsigned long limit_pfn) 786static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
758{ 787{
759 int i; 788 int i;
760 unsigned long last_pfn = 0; 789 unsigned long last_pfn = 0;
761 unsigned long max_arch_pfn = MAX_ARCH_PFN; 790 unsigned long max_arch_pfn = MAX_ARCH_PFN;
762 791
763 for (i = 0; i < e820.nr_map; i++) { 792 for (i = 0; i < e820->nr_map; i++) {
764 struct e820entry *ei = &e820.map[i]; 793 struct e820entry *ei = &e820->map[i];
765 unsigned long start_pfn; 794 unsigned long start_pfn;
766 unsigned long end_pfn; 795 unsigned long end_pfn;
767 796
768 /* 797 if (ei->type != type)
769 * Persistent memory is accounted as ram for purposes of
770 * establishing max_pfn and mem_map.
771 */
772 if (ei->type != E820_RAM && ei->type != E820_PRAM)
773 continue; 798 continue;
774 799
775 start_pfn = ei->addr >> PAGE_SHIFT; 800 start_pfn = ei->addr >> PAGE_SHIFT;
@@ -794,15 +819,15 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn)
794} 819}
795unsigned long __init e820_end_of_ram_pfn(void) 820unsigned long __init e820_end_of_ram_pfn(void)
796{ 821{
797 return e820_end_pfn(MAX_ARCH_PFN); 822 return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
798} 823}
799 824
800unsigned long __init e820_end_of_low_ram_pfn(void) 825unsigned long __init e820_end_of_low_ram_pfn(void)
801{ 826{
802 return e820_end_pfn(1UL << (32-PAGE_SHIFT)); 827 return e820_end_pfn(1UL << (32 - PAGE_SHIFT), E820_RAM);
803} 828}
804 829
805static void early_panic(char *msg) 830static void __init early_panic(char *msg)
806{ 831{
807 early_printk(msg); 832 early_printk(msg);
808 panic(msg); 833 panic(msg);
@@ -856,7 +881,7 @@ static int __init parse_memmap_one(char *p)
856 */ 881 */
857 saved_max_pfn = e820_end_of_ram_pfn(); 882 saved_max_pfn = e820_end_of_ram_pfn();
858#endif 883#endif
859 e820.nr_map = 0; 884 e820->nr_map = 0;
860 userdef = 1; 885 userdef = 1;
861 return 0; 886 return 0;
862 } 887 }
@@ -903,8 +928,8 @@ early_param("memmap", parse_memmap_opt);
903void __init finish_e820_parsing(void) 928void __init finish_e820_parsing(void)
904{ 929{
905 if (userdef) { 930 if (userdef) {
906 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), 931 if (sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map),
907 &e820.nr_map) < 0) 932 &e820->nr_map) < 0)
908 early_panic("Invalid user supplied memory map"); 933 early_panic("Invalid user supplied memory map");
909 934
910 printk(KERN_INFO "e820: user-defined physical RAM map:\n"); 935 printk(KERN_INFO "e820: user-defined physical RAM map:\n");
@@ -912,7 +937,7 @@ void __init finish_e820_parsing(void)
912 } 937 }
913} 938}
914 939
915static const char *e820_type_to_string(int e820_type) 940static const char *__init e820_type_to_string(int e820_type)
916{ 941{
917 switch (e820_type) { 942 switch (e820_type) {
918 case E820_RESERVED_KERN: 943 case E820_RESERVED_KERN:
@@ -926,7 +951,7 @@ static const char *e820_type_to_string(int e820_type)
926 } 951 }
927} 952}
928 953
929static unsigned long e820_type_to_iomem_type(int e820_type) 954static unsigned long __init e820_type_to_iomem_type(int e820_type)
930{ 955{
931 switch (e820_type) { 956 switch (e820_type) {
932 case E820_RESERVED_KERN: 957 case E820_RESERVED_KERN:
@@ -942,7 +967,7 @@ static unsigned long e820_type_to_iomem_type(int e820_type)
942 } 967 }
943} 968}
944 969
945static unsigned long e820_type_to_iores_desc(int e820_type) 970static unsigned long __init e820_type_to_iores_desc(int e820_type)
946{ 971{
947 switch (e820_type) { 972 switch (e820_type) {
948 case E820_ACPI: 973 case E820_ACPI:
@@ -961,7 +986,7 @@ static unsigned long e820_type_to_iores_desc(int e820_type)
961 } 986 }
962} 987}
963 988
964static bool do_mark_busy(u32 type, struct resource *res) 989static bool __init do_mark_busy(u32 type, struct resource *res)
965{ 990{
966 /* this is the legacy bios/dos rom-shadow + mmio region */ 991 /* this is the legacy bios/dos rom-shadow + mmio region */
967 if (res->start < (1ULL<<20)) 992 if (res->start < (1ULL<<20))
@@ -991,35 +1016,35 @@ void __init e820_reserve_resources(void)
991 struct resource *res; 1016 struct resource *res;
992 u64 end; 1017 u64 end;
993 1018
994 res = alloc_bootmem(sizeof(struct resource) * e820.nr_map); 1019 res = alloc_bootmem(sizeof(struct resource) * e820->nr_map);
995 e820_res = res; 1020 e820_res = res;
996 for (i = 0; i < e820.nr_map; i++) { 1021 for (i = 0; i < e820->nr_map; i++) {
997 end = e820.map[i].addr + e820.map[i].size - 1; 1022 end = e820->map[i].addr + e820->map[i].size - 1;
998 if (end != (resource_size_t)end) { 1023 if (end != (resource_size_t)end) {
999 res++; 1024 res++;
1000 continue; 1025 continue;
1001 } 1026 }
1002 res->name = e820_type_to_string(e820.map[i].type); 1027 res->name = e820_type_to_string(e820->map[i].type);
1003 res->start = e820.map[i].addr; 1028 res->start = e820->map[i].addr;
1004 res->end = end; 1029 res->end = end;
1005 1030
1006 res->flags = e820_type_to_iomem_type(e820.map[i].type); 1031 res->flags = e820_type_to_iomem_type(e820->map[i].type);
1007 res->desc = e820_type_to_iores_desc(e820.map[i].type); 1032 res->desc = e820_type_to_iores_desc(e820->map[i].type);
1008 1033
1009 /* 1034 /*
1010 * don't register the region that could be conflicted with 1035 * don't register the region that could be conflicted with
1011 * pci device BAR resource and insert them later in 1036 * pci device BAR resource and insert them later in
1012 * pcibios_resource_survey() 1037 * pcibios_resource_survey()
1013 */ 1038 */
1014 if (do_mark_busy(e820.map[i].type, res)) { 1039 if (do_mark_busy(e820->map[i].type, res)) {
1015 res->flags |= IORESOURCE_BUSY; 1040 res->flags |= IORESOURCE_BUSY;
1016 insert_resource(&iomem_resource, res); 1041 insert_resource(&iomem_resource, res);
1017 } 1042 }
1018 res++; 1043 res++;
1019 } 1044 }
1020 1045
1021 for (i = 0; i < e820_saved.nr_map; i++) { 1046 for (i = 0; i < e820_saved->nr_map; i++) {
1022 struct e820entry *entry = &e820_saved.map[i]; 1047 struct e820entry *entry = &e820_saved->map[i];
1023 firmware_map_add_early(entry->addr, 1048 firmware_map_add_early(entry->addr,
1024 entry->addr + entry->size, 1049 entry->addr + entry->size,
1025 e820_type_to_string(entry->type)); 1050 e820_type_to_string(entry->type));
@@ -1027,7 +1052,7 @@ void __init e820_reserve_resources(void)
1027} 1052}
1028 1053
1029/* How much should we pad RAM ending depending on where it is? */ 1054/* How much should we pad RAM ending depending on where it is? */
1030static unsigned long ram_alignment(resource_size_t pos) 1055static unsigned long __init ram_alignment(resource_size_t pos)
1031{ 1056{
1032 unsigned long mb = pos >> 20; 1057 unsigned long mb = pos >> 20;
1033 1058
@@ -1051,7 +1076,7 @@ void __init e820_reserve_resources_late(void)
1051 struct resource *res; 1076 struct resource *res;
1052 1077
1053 res = e820_res; 1078 res = e820_res;
1054 for (i = 0; i < e820.nr_map; i++) { 1079 for (i = 0; i < e820->nr_map; i++) {
1055 if (!res->parent && res->end) 1080 if (!res->parent && res->end)
1056 insert_resource_expand_to_fit(&iomem_resource, res); 1081 insert_resource_expand_to_fit(&iomem_resource, res);
1057 res++; 1082 res++;
@@ -1061,8 +1086,8 @@ void __init e820_reserve_resources_late(void)
1061 * Try to bump up RAM regions to reasonable boundaries to 1086 * Try to bump up RAM regions to reasonable boundaries to
1062 * avoid stolen RAM: 1087 * avoid stolen RAM:
1063 */ 1088 */
1064 for (i = 0; i < e820.nr_map; i++) { 1089 for (i = 0; i < e820->nr_map; i++) {
1065 struct e820entry *entry = &e820.map[i]; 1090 struct e820entry *entry = &e820->map[i];
1066 u64 start, end; 1091 u64 start, end;
1067 1092
1068 if (entry->type != E820_RAM) 1093 if (entry->type != E820_RAM)
@@ -1110,7 +1135,7 @@ char *__init default_machine_specific_memory_setup(void)
1110 who = "BIOS-e801"; 1135 who = "BIOS-e801";
1111 } 1136 }
1112 1137
1113 e820.nr_map = 0; 1138 e820->nr_map = 0;
1114 e820_add_region(0, LOWMEMSIZE(), E820_RAM); 1139 e820_add_region(0, LOWMEMSIZE(), E820_RAM);
1115 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM); 1140 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
1116 } 1141 }
@@ -1124,7 +1149,7 @@ void __init setup_memory_map(void)
1124 char *who; 1149 char *who;
1125 1150
1126 who = x86_init.resources.memory_setup(); 1151 who = x86_init.resources.memory_setup();
1127 memcpy(&e820_saved, &e820, sizeof(struct e820map)); 1152 memcpy(e820_saved, e820, sizeof(struct e820map));
1128 printk(KERN_INFO "e820: BIOS-provided physical RAM map:\n"); 1153 printk(KERN_INFO "e820: BIOS-provided physical RAM map:\n");
1129 e820_print_map(who); 1154 e820_print_map(who);
1130} 1155}
@@ -1141,8 +1166,8 @@ void __init memblock_x86_fill(void)
1141 */ 1166 */
1142 memblock_allow_resize(); 1167 memblock_allow_resize();
1143 1168
1144 for (i = 0; i < e820.nr_map; i++) { 1169 for (i = 0; i < e820->nr_map; i++) {
1145 struct e820entry *ei = &e820.map[i]; 1170 struct e820entry *ei = &e820->map[i];
1146 1171
1147 end = ei->addr + ei->size; 1172 end = ei->addr + ei->size;
1148 if (end != (resource_size_t)end) 1173 if (end != (resource_size_t)end)
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index de7501edb21c..18bb3a639197 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -555,7 +555,7 @@ intel_graphics_stolen(int num, int slot, int func,
555 555
556 /* Mark this space as reserved */ 556 /* Mark this space as reserved */
557 e820_add_region(base, size, E820_RESERVED); 557 e820_add_region(base, size, E820_RESERVED);
558 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 558 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
559} 559}
560 560
561static void __init intel_graphics_quirks(int num, int slot, int func) 561static void __init intel_graphics_quirks(int num, int slot, int func)
diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c
index f2356bda2b05..3407b148c240 100644
--- a/arch/x86/kernel/kexec-bzimage64.c
+++ b/arch/x86/kernel/kexec-bzimage64.c
@@ -99,14 +99,14 @@ static int setup_e820_entries(struct boot_params *params)
99{ 99{
100 unsigned int nr_e820_entries; 100 unsigned int nr_e820_entries;
101 101
102 nr_e820_entries = e820_saved.nr_map; 102 nr_e820_entries = e820_saved->nr_map;
103 103
104 /* TODO: Pass entries more than E820MAX in bootparams setup data */ 104 /* TODO: Pass entries more than E820MAX in bootparams setup data */
105 if (nr_e820_entries > E820MAX) 105 if (nr_e820_entries > E820MAX)
106 nr_e820_entries = E820MAX; 106 nr_e820_entries = E820MAX;
107 107
108 params->e820_entries = nr_e820_entries; 108 params->e820_entries = nr_e820_entries;
109 memcpy(&params->e820_map, &e820_saved.map, 109 memcpy(&params->e820_map, &e820_saved->map,
110 nr_e820_entries * sizeof(struct e820entry)); 110 nr_e820_entries * sizeof(struct e820entry));
111 111
112 return 0; 112 return 0;
diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
index 80eab01c1a68..2408c1603438 100644
--- a/arch/x86/kernel/resource.c
+++ b/arch/x86/kernel/resource.c
@@ -27,8 +27,8 @@ static void remove_e820_regions(struct resource *avail)
27 int i; 27 int i;
28 struct e820entry *entry; 28 struct e820entry *entry;
29 29
30 for (i = 0; i < e820.nr_map; i++) { 30 for (i = 0; i < e820->nr_map; i++) {
31 entry = &e820.map[i]; 31 entry = &e820->map[i];
32 32
33 resource_clip(avail, entry->addr, 33 resource_clip(avail, entry->addr,
34 entry->addr + entry->size - 1); 34 entry->addr + entry->size - 1);
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index eeb094ea794a..bbfbca5fea0c 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -458,8 +458,8 @@ static void __init e820_reserve_setup_data(void)
458 early_memunmap(data, sizeof(*data)); 458 early_memunmap(data, sizeof(*data));
459 } 459 }
460 460
461 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 461 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
462 memcpy(&e820_saved, &e820, sizeof(struct e820map)); 462 memcpy(e820_saved, e820, sizeof(struct e820map));
463 printk(KERN_INFO "extended physical RAM map:\n"); 463 printk(KERN_INFO "extended physical RAM map:\n");
464 e820_print_map("reserve setup_data"); 464 e820_print_map("reserve setup_data");
465} 465}
@@ -763,7 +763,7 @@ static void __init trim_bios_range(void)
763 */ 763 */
764 e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1); 764 e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
765 765
766 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 766 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
767} 767}
768 768
769/* called before trim_bios_range() to spare extra sanitize */ 769/* called before trim_bios_range() to spare extra sanitize */
@@ -1032,7 +1032,7 @@ void __init setup_arch(char **cmdline_p)
1032 if (ppro_with_ram_bug()) { 1032 if (ppro_with_ram_bug()) {
1033 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM, 1033 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
1034 E820_RESERVED); 1034 E820_RESERVED);
1035 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 1035 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
1036 printk(KERN_INFO "fixed physical RAM map:\n"); 1036 printk(KERN_INFO "fixed physical RAM map:\n");
1037 e820_print_map("bad_ppro"); 1037 e820_print_map("bad_ppro");
1038 } 1038 }
diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
index 654f6c66fe45..8402907825b0 100644
--- a/arch/x86/kernel/tboot.c
+++ b/arch/x86/kernel/tboot.c
@@ -188,12 +188,12 @@ static int tboot_setup_sleep(void)
188 188
189 tboot->num_mac_regions = 0; 189 tboot->num_mac_regions = 0;
190 190
191 for (i = 0; i < e820.nr_map; i++) { 191 for (i = 0; i < e820->nr_map; i++) {
192 if ((e820.map[i].type != E820_RAM) 192 if ((e820->map[i].type != E820_RAM)
193 && (e820.map[i].type != E820_RESERVED_KERN)) 193 && (e820->map[i].type != E820_RESERVED_KERN))
194 continue; 194 continue;
195 195
196 add_mac_region(e820.map[i].addr, e820.map[i].size); 196 add_mac_region(e820->map[i].addr, e820->map[i].size);
197 } 197 }
198 198
199 tboot->acpi_sinfo.kernel_s3_resume_vector = 199 tboot->acpi_sinfo.kernel_s3_resume_vector =
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index d28a2d741f9e..22af912d66d2 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -699,8 +699,10 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
699 } 699 }
700} 700}
701 701
702void free_initmem(void) 702void __ref free_initmem(void)
703{ 703{
704 e820_reallocate_tables();
705
704 free_init_pages("unused kernel", 706 free_init_pages("unused kernel",
705 (unsigned long)(&__init_begin), 707 (unsigned long)(&__init_begin),
706 (unsigned long)(&__init_end)); 708 (unsigned long)(&__init_end));
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 0955c70897ae..bf99aa7005eb 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -166,7 +166,7 @@ static void __init do_add_efi_memmap(void)
166 } 166 }
167 e820_add_region(start, size, e820_type); 167 e820_add_region(start, size, e820_type);
168 } 168 }
169 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 169 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
170} 170}
171 171
172int __init efi_memblock_x86_reserve_range(void) 172int __init efi_memblock_x86_reserve_range(void)
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 176425233e4d..f8960fca0827 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -861,7 +861,7 @@ char * __init xen_memory_setup(void)
861 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, 861 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
862 E820_RESERVED); 862 E820_RESERVED);
863 863
864 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); 864 sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
865 865
866 /* 866 /*
867 * Check whether the kernel itself conflicts with the target E820 map. 867 * Check whether the kernel itself conflicts with the target E820 map.