- patches.suse/slab-handle-memoryless-nodes-v2a.patch: Refresh.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / kernel / e820.c
1 /*
2  * Handle the memory map.
3  * The functions here do the job until bootmem takes over.
4  *
5  *  Getting sanitize_e820_map() in sync with i386 version by applying change:
6  *  -  Provisions for empty E820 memory regions (reported by certain BIOSes).
7  *     Alex Achenbach <xela@slit.de>, December 2002.
8  *  Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
9  *
10  */
11 #include <linux/kernel.h>
12 #include <linux/types.h>
13 #include <linux/init.h>
14 #include <linux/bootmem.h>
15 #include <linux/ioport.h>
16 #include <linux/string.h>
17 #include <linux/kexec.h>
18 #include <linux/module.h>
19 #include <linux/mm.h>
20 #include <linux/pfn.h>
21 #include <linux/suspend.h>
22 #include <linux/firmware-map.h>
23
24 #include <asm/pgtable.h>
25 #include <asm/page.h>
26 #include <asm/e820.h>
27 #include <asm/proto.h>
28 #include <asm/setup.h>
29 #include <asm/trampoline.h>
30
31 /*
32  * The e820 map is the map that gets modified e.g. with command line parameters
33  * and that is also registered with modifications in the kernel resource tree
34  * with the iomem_resource as parent.
35  *
36  * The e820_saved is directly saved after the BIOS-provided memory map is
37  * copied. It doesn't get modified afterwards. It's registered for the
38  * /sys/firmware/memmap interface.
39  *
40  * That memory map is not modified and is used as base for kexec. The kexec'd
41  * kernel should get the same memory map as the firmware provides. Then the
42  * user can e.g. boot the original kernel with mem=1G while still booting the
43  * next kernel with full memory.
44  */
45 struct e820map e820;
46 struct e820map e820_saved;
47
48 /* For PCI or other memory-mapped resources */
49 unsigned long pci_mem_start = 0xaeedbabe;
50 #ifdef CONFIG_PCI
51 EXPORT_SYMBOL(pci_mem_start);
52 #endif
53
54 /*
55  * This function checks if any part of the range <start,end> is mapped
56  * with type.
57  */
58 int
59 e820_any_mapped(u64 start, u64 end, unsigned type)
60 {
61         int i;
62
63         for (i = 0; i < e820.nr_map; i++) {
64                 struct e820entry *ei = &e820.map[i];
65
66                 if (type && ei->type != type)
67                         continue;
68                 if (ei->addr >= end || ei->addr + ei->size <= start)
69                         continue;
70                 return 1;
71         }
72         return 0;
73 }
74 EXPORT_SYMBOL_GPL(e820_any_mapped);
75
76 /*
77  * This function checks if the entire range <start,end> is mapped with type.
78  *
79  * Note: this function only works correct if the e820 table is sorted and
80  * not-overlapping, which is the case
81  */
82 int e820_all_mapped(u64 start, u64 end, unsigned type)
83 {
84         int i;
85
86         for (i = 0; i < e820.nr_map; i++) {
87                 struct e820entry *ei = &e820.map[i];
88
89                 if (type && ei->type != type)
90                         continue;
91                 /* is the region (part) in overlap with the current region ?*/
92                 if (ei->addr >= end || ei->addr + ei->size <= start)
93                         continue;
94
95                 /* if the region is at the beginning of <start,end> we move
96                  * start to the end of the region since it's ok until there
97                  */
98                 if (ei->addr <= start)
99                         start = ei->addr + ei->size;
100                 /*
101                  * if start is now at or beyond end, we're done, full
102                  * coverage
103                  */
104                 if (start >= end)
105                         return 1;
106         }
107         return 0;
108 }
109 EXPORT_SYMBOL_GPL(e820_all_mapped);
110
111 /*
112  * Add a memory region to the kernel e820 map.
113  */
114 static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
115                                          int type)
116 {
117         int x = e820x->nr_map;
118
119         if (x >= ARRAY_SIZE(e820x->map)) {
120                 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
121                 return;
122         }
123
124         e820x->map[x].addr = start;
125         e820x->map[x].size = size;
126         e820x->map[x].type = type;
127         e820x->nr_map++;
128 }
129
130 void __init e820_add_region(u64 start, u64 size, int type)
131 {
132         __e820_add_region(&e820, start, size, type);
133 }
134
135 static void __init e820_print_type(u32 type)
136 {
137         switch (type) {
138         case E820_RAM:
139         case E820_RESERVED_KERN:
140                 printk(KERN_CONT "(usable)");
141                 break;
142         case E820_RESERVED:
143                 printk(KERN_CONT "(reserved)");
144                 break;
145         case E820_ACPI:
146                 printk(KERN_CONT "(ACPI data)");
147                 break;
148         case E820_NVS:
149                 printk(KERN_CONT "(ACPI NVS)");
150                 break;
151         case E820_UNUSABLE:
152                 printk(KERN_CONT "(unusable)");
153                 break;
154         default:
155                 printk(KERN_CONT "type %u", type);
156                 break;
157         }
158 }
159
160 void __init e820_print_map(char *who)
161 {
162         int i;
163
164         for (i = 0; i < e820.nr_map; i++) {
165                 printk(KERN_INFO " %s: %016Lx - %016Lx ", who,
166                        (unsigned long long) e820.map[i].addr,
167                        (unsigned long long)
168                        (e820.map[i].addr + e820.map[i].size));
169                 e820_print_type(e820.map[i].type);
170                 printk(KERN_CONT "\n");
171         }
172 }
173
174 /*
175  * Sanitize the BIOS e820 map.
176  *
177  * Some e820 responses include overlapping entries. The following
178  * replaces the original e820 map with a new one, removing overlaps,
179  * and resolving conflicting memory types in favor of highest
180  * numbered type.
181  *
182  * The input parameter biosmap points to an array of 'struct
183  * e820entry' which on entry has elements in the range [0, *pnr_map)
184  * valid, and which has space for up to max_nr_map entries.
185  * On return, the resulting sanitized e820 map entries will be in
186  * overwritten in the same location, starting at biosmap.
187  *
188  * The integer pointed to by pnr_map must be valid on entry (the
189  * current number of valid entries located at biosmap) and will
190  * be updated on return, with the new number of valid entries
191  * (something no more than max_nr_map.)
192  *
193  * The return value from sanitize_e820_map() is zero if it
194  * successfully 'sanitized' the map entries passed in, and is -1
195  * if it did nothing, which can happen if either of (1) it was
196  * only passed one map entry, or (2) any of the input map entries
197  * were invalid (start + size < start, meaning that the size was
198  * so big the described memory range wrapped around through zero.)
199  *
200  *      Visually we're performing the following
201  *      (1,2,3,4 = memory types)...
202  *
203  *      Sample memory map (w/overlaps):
204  *         ____22__________________
205  *         ______________________4_
206  *         ____1111________________
207  *         _44_____________________
208  *         11111111________________
209  *         ____________________33__
210  *         ___________44___________
211  *         __________33333_________
212  *         ______________22________
213  *         ___________________2222_
214  *         _________111111111______
215  *         _____________________11_
216  *         _________________4______
217  *
218  *      Sanitized equivalent (no overlap):
219  *         1_______________________
220  *         _44_____________________
221  *         ___1____________________
222  *         ____22__________________
223  *         ______11________________
224  *         _________1______________
225  *         __________3_____________
226  *         ___________44___________
227  *         _____________33_________
228  *         _______________2________
229  *         ________________1_______
230  *         _________________4______
231  *         ___________________2____
232  *         ____________________33__
233  *         ______________________4_
234  */
235
236 int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
237                              u32 *pnr_map)
238 {
239         struct change_member {
240                 struct e820entry *pbios; /* pointer to original bios entry */
241                 unsigned long long addr; /* address for this change point */
242         };
243         static struct change_member change_point_list[2*E820_X_MAX] __initdata;
244         static struct change_member *change_point[2*E820_X_MAX] __initdata;
245         static struct e820entry *overlap_list[E820_X_MAX] __initdata;
246         static struct e820entry new_bios[E820_X_MAX] __initdata;
247         struct change_member *change_tmp;
248         unsigned long current_type, last_type;
249         unsigned long long last_addr;
250         int chgidx, still_changing;
251         int overlap_entries;
252         int new_bios_entry;
253         int old_nr, new_nr, chg_nr;
254         int i;
255
256         /* if there's only one memory region, don't bother */
257         if (*pnr_map < 2)
258                 return -1;
259
260         old_nr = *pnr_map;
261         BUG_ON(old_nr > max_nr_map);
262
263         /* bail out if we find any unreasonable addresses in bios map */
264         for (i = 0; i < old_nr; i++)
265                 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
266                         return -1;
267
268         /* create pointers for initial change-point information (for sorting) */
269         for (i = 0; i < 2 * old_nr; i++)
270                 change_point[i] = &change_point_list[i];
271
272         /* record all known change-points (starting and ending addresses),
273            omitting those that are for empty memory regions */
274         chgidx = 0;
275         for (i = 0; i < old_nr; i++)    {
276                 if (biosmap[i].size != 0) {
277                         change_point[chgidx]->addr = biosmap[i].addr;
278                         change_point[chgidx++]->pbios = &biosmap[i];
279                         change_point[chgidx]->addr = biosmap[i].addr +
280                                 biosmap[i].size;
281                         change_point[chgidx++]->pbios = &biosmap[i];
282                 }
283         }
284         chg_nr = chgidx;
285
286         /* sort change-point list by memory addresses (low -> high) */
287         still_changing = 1;
288         while (still_changing)  {
289                 still_changing = 0;
290                 for (i = 1; i < chg_nr; i++)  {
291                         unsigned long long curaddr, lastaddr;
292                         unsigned long long curpbaddr, lastpbaddr;
293
294                         curaddr = change_point[i]->addr;
295                         lastaddr = change_point[i - 1]->addr;
296                         curpbaddr = change_point[i]->pbios->addr;
297                         lastpbaddr = change_point[i - 1]->pbios->addr;
298
299                         /*
300                          * swap entries, when:
301                          *
302                          * curaddr > lastaddr or
303                          * curaddr == lastaddr and curaddr == curpbaddr and
304                          * lastaddr != lastpbaddr
305                          */
306                         if (curaddr < lastaddr ||
307                             (curaddr == lastaddr && curaddr == curpbaddr &&
308                              lastaddr != lastpbaddr)) {
309                                 change_tmp = change_point[i];
310                                 change_point[i] = change_point[i-1];
311                                 change_point[i-1] = change_tmp;
312                                 still_changing = 1;
313                         }
314                 }
315         }
316
317         /* create a new bios memory map, removing overlaps */
318         overlap_entries = 0;     /* number of entries in the overlap table */
319         new_bios_entry = 0;      /* index for creating new bios map entries */
320         last_type = 0;           /* start with undefined memory type */
321         last_addr = 0;           /* start with 0 as last starting address */
322
323         /* loop through change-points, determining affect on the new bios map */
324         for (chgidx = 0; chgidx < chg_nr; chgidx++) {
325                 /* keep track of all overlapping bios entries */
326                 if (change_point[chgidx]->addr ==
327                     change_point[chgidx]->pbios->addr) {
328                         /*
329                          * add map entry to overlap list (> 1 entry
330                          * implies an overlap)
331                          */
332                         overlap_list[overlap_entries++] =
333                                 change_point[chgidx]->pbios;
334                 } else {
335                         /*
336                          * remove entry from list (order independent,
337                          * so swap with last)
338                          */
339                         for (i = 0; i < overlap_entries; i++) {
340                                 if (overlap_list[i] ==
341                                     change_point[chgidx]->pbios)
342                                         overlap_list[i] =
343                                                 overlap_list[overlap_entries-1];
344                         }
345                         overlap_entries--;
346                 }
347                 /*
348                  * if there are overlapping entries, decide which
349                  * "type" to use (larger value takes precedence --
350                  * 1=usable, 2,3,4,4+=unusable)
351                  */
352                 current_type = 0;
353                 for (i = 0; i < overlap_entries; i++)
354                         if (overlap_list[i]->type > current_type)
355                                 current_type = overlap_list[i]->type;
356                 /*
357                  * continue building up new bios map based on this
358                  * information
359                  */
360                 if (current_type != last_type)  {
361                         if (last_type != 0)      {
362                                 new_bios[new_bios_entry].size =
363                                         change_point[chgidx]->addr - last_addr;
364                                 /*
365                                  * move forward only if the new size
366                                  * was non-zero
367                                  */
368                                 if (new_bios[new_bios_entry].size != 0)
369                                         /*
370                                          * no more space left for new
371                                          * bios entries ?
372                                          */
373                                         if (++new_bios_entry >= max_nr_map)
374                                                 break;
375                         }
376                         if (current_type != 0)  {
377                                 new_bios[new_bios_entry].addr =
378                                         change_point[chgidx]->addr;
379                                 new_bios[new_bios_entry].type = current_type;
380                                 last_addr = change_point[chgidx]->addr;
381                         }
382                         last_type = current_type;
383                 }
384         }
385         /* retain count for new bios entries */
386         new_nr = new_bios_entry;
387
388         /* copy new bios mapping into original location */
389         memcpy(biosmap, new_bios, new_nr * sizeof(struct e820entry));
390         *pnr_map = new_nr;
391
392         return 0;
393 }
394
395 static int __init __append_e820_map(struct e820entry *biosmap, int nr_map)
396 {
397         while (nr_map) {
398                 u64 start = biosmap->addr;
399                 u64 size = biosmap->size;
400                 u64 end = start + size;
401                 u32 type = biosmap->type;
402
403                 /* Overflow in 64 bits? Ignore the memory map. */
404                 if (start > end)
405                         return -1;
406
407                 e820_add_region(start, size, type);
408
409                 biosmap++;
410                 nr_map--;
411         }
412         return 0;
413 }
414
415 /*
416  * Copy the BIOS e820 map into a safe place.
417  *
418  * Sanity-check it while we're at it..
419  *
420  * If we're lucky and live on a modern system, the setup code
421  * will have given us a memory map that we can use to properly
422  * set up memory.  If we aren't, we'll fake a memory map.
423  */
424 static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
425 {
426         /* Only one memory region (or negative)? Ignore it */
427         if (nr_map < 2)
428                 return -1;
429
430         return __append_e820_map(biosmap, nr_map);
431 }
432
433 static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
434                                         u64 size, unsigned old_type,
435                                         unsigned new_type)
436 {
437         u64 end;
438         unsigned int i;
439         u64 real_updated_size = 0;
440
441         BUG_ON(old_type == new_type);
442
443         if (size > (ULLONG_MAX - start))
444                 size = ULLONG_MAX - start;
445
446         end = start + size;
447         printk(KERN_DEBUG "e820 update range: %016Lx - %016Lx ",
448                        (unsigned long long) start,
449                        (unsigned long long) end);
450         e820_print_type(old_type);
451         printk(KERN_CONT " ==> ");
452         e820_print_type(new_type);
453         printk(KERN_CONT "\n");
454
455         for (i = 0; i < e820x->nr_map; i++) {
456                 struct e820entry *ei = &e820x->map[i];
457                 u64 final_start, final_end;
458                 u64 ei_end;
459
460                 if (ei->type != old_type)
461                         continue;
462
463                 ei_end = ei->addr + ei->size;
464                 /* totally covered by new range? */
465                 if (ei->addr >= start && ei_end <= end) {
466                         ei->type = new_type;
467                         real_updated_size += ei->size;
468                         continue;
469                 }
470
471                 /* new range is totally covered? */
472                 if (ei->addr < start && ei_end > end) {
473                         __e820_add_region(e820x, start, size, new_type);
474                         __e820_add_region(e820x, end, ei_end - end, ei->type);
475                         ei->size = start - ei->addr;
476                         real_updated_size += size;
477                         continue;
478                 }
479
480                 /* partially covered */
481                 final_start = max(start, ei->addr);
482                 final_end = min(end, ei_end);
483                 if (final_start >= final_end)
484                         continue;
485
486                 __e820_add_region(e820x, final_start, final_end - final_start,
487                                   new_type);
488
489                 real_updated_size += final_end - final_start;
490
491                 /*
492                  * left range could be head or tail, so need to update
493                  * size at first.
494                  */
495                 ei->size -= final_end - final_start;
496                 if (ei->addr < final_start)
497                         continue;
498                 ei->addr = final_end;
499         }
500         return real_updated_size;
501 }
502
503 u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
504                              unsigned new_type)
505 {
506         return __e820_update_range(&e820, start, size, old_type, new_type);
507 }
508
509 static u64 __init e820_update_range_saved(u64 start, u64 size,
510                                           unsigned old_type, unsigned new_type)
511 {
512         return __e820_update_range(&e820_saved, start, size, old_type,
513                                      new_type);
514 }
515
516 /* make e820 not cover the range */
517 u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
518                              int checktype)
519 {
520         int i;
521         u64 real_removed_size = 0;
522
523         if (size > (ULLONG_MAX - start))
524                 size = ULLONG_MAX - start;
525
526         for (i = 0; i < e820.nr_map; i++) {
527                 struct e820entry *ei = &e820.map[i];
528                 u64 final_start, final_end;
529
530                 if (checktype && ei->type != old_type)
531                         continue;
532                 /* totally covered? */
533                 if (ei->addr >= start &&
534                     (ei->addr + ei->size) <= (start + size)) {
535                         real_removed_size += ei->size;
536                         memset(ei, 0, sizeof(struct e820entry));
537                         continue;
538                 }
539                 /* partially covered */
540                 final_start = max(start, ei->addr);
541                 final_end = min(start + size, ei->addr + ei->size);
542                 if (final_start >= final_end)
543                         continue;
544                 real_removed_size += final_end - final_start;
545
546                 ei->size -= final_end - final_start;
547                 if (ei->addr < final_start)
548                         continue;
549                 ei->addr = final_end;
550         }
551         return real_removed_size;
552 }
553
554 void __init update_e820(void)
555 {
556         u32 nr_map;
557
558         nr_map = e820.nr_map;
559         if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr_map))
560                 return;
561         e820.nr_map = nr_map;
562         printk(KERN_INFO "modified physical RAM map:\n");
563         e820_print_map("modified");
564 }
565 static void __init update_e820_saved(void)
566 {
567         u32 nr_map;
568
569         nr_map = e820_saved.nr_map;
570         if (sanitize_e820_map(e820_saved.map, ARRAY_SIZE(e820_saved.map), &nr_map))
571                 return;
572         e820_saved.nr_map = nr_map;
573 }
574 #define MAX_GAP_END 0x100000000ull
575 /*
576  * Search for a gap in the e820 memory space from start_addr to end_addr.
577  */
578 __init int e820_search_gap(unsigned long *gapstart, unsigned long *gapsize,
579                 unsigned long start_addr, unsigned long long end_addr)
580 {
581         unsigned long long last;
582         int i = e820.nr_map;
583         int found = 0;
584
585         last = (end_addr && end_addr < MAX_GAP_END) ? end_addr : MAX_GAP_END;
586
587         while (--i >= 0) {
588                 unsigned long long start = e820.map[i].addr;
589                 unsigned long long end = start + e820.map[i].size;
590
591                 if (end < start_addr)
592                         continue;
593
594                 /*
595                  * Since "last" is at most 4GB, we know we'll
596                  * fit in 32 bits if this condition is true
597                  */
598                 if (last > end) {
599                         unsigned long gap = last - end;
600
601                         if (gap >= *gapsize) {
602                                 *gapsize = gap;
603                                 *gapstart = end;
604                                 found = 1;
605                         }
606                 }
607                 if (start < last)
608                         last = start;
609         }
610         return found;
611 }
612
613 /*
614  * Search for the biggest gap in the low 32 bits of the e820
615  * memory space.  We pass this space to PCI to assign MMIO resources
616  * for hotplug or unconfigured devices in.
617  * Hopefully the BIOS let enough space left.
618  */
619 __init void e820_setup_gap(void)
620 {
621         unsigned long gapstart, gapsize;
622         int found;
623
624         gapstart = 0x10000000;
625         gapsize = 0x400000;
626         found  = e820_search_gap(&gapstart, &gapsize, 0, MAX_GAP_END);
627
628 #ifdef CONFIG_X86_64
629         if (!found) {
630                 gapstart = (max_pfn << PAGE_SHIFT) + 1024*1024;
631                 printk(KERN_ERR
632         "PCI: Warning: Cannot find a gap in the 32bit address range\n"
633         "PCI: Unassigned devices with 32bit resource registers may break!\n");
634         }
635 #endif
636
637         /*
638          * e820_reserve_resources_late protect stolen RAM already
639          */
640         pci_mem_start = gapstart;
641
642         printk(KERN_INFO
643                "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
644                pci_mem_start, gapstart, gapsize);
645 }
646
647 /**
648  * Because of the size limitation of struct boot_params, only first
649  * 128 E820 memory entries are passed to kernel via
650  * boot_params.e820_map, others are passed via SETUP_E820_EXT node of
651  * linked list of struct setup_data, which is parsed here.
652  */
653 void __init parse_e820_ext(struct setup_data *sdata, unsigned long pa_data)
654 {
655         u32 map_len;
656         int entries;
657         struct e820entry *extmap;
658
659         entries = sdata->len / sizeof(struct e820entry);
660         map_len = sdata->len + sizeof(struct setup_data);
661         if (map_len > PAGE_SIZE)
662                 sdata = early_ioremap(pa_data, map_len);
663         extmap = (struct e820entry *)(sdata->data);
664         __append_e820_map(extmap, entries);
665         sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
666         if (map_len > PAGE_SIZE)
667                 early_iounmap(sdata, map_len);
668         printk(KERN_INFO "extended physical RAM map:\n");
669         e820_print_map("extended");
670 }
671
672 #if defined(CONFIG_X86_64) || \
673         (defined(CONFIG_X86_32) && defined(CONFIG_HIBERNATION))
674 /**
675  * Find the ranges of physical addresses that do not correspond to
676  * e820 RAM areas and mark the corresponding pages as nosave for
677  * hibernation (32 bit) or software suspend and suspend to RAM (64 bit).
678  *
679  * This function requires the e820 map to be sorted and without any
680  * overlapping entries and assumes the first e820 area to be RAM.
681  */
682 void __init e820_mark_nosave_regions(unsigned long limit_pfn)
683 {
684         int i;
685         unsigned long pfn;
686
687         pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
688         for (i = 1; i < e820.nr_map; i++) {
689                 struct e820entry *ei = &e820.map[i];
690
691                 if (pfn < PFN_UP(ei->addr))
692                         register_nosave_region(pfn, PFN_UP(ei->addr));
693
694                 pfn = PFN_DOWN(ei->addr + ei->size);
695                 if (ei->type != E820_RAM && ei->type != E820_RESERVED_KERN)
696                         register_nosave_region(PFN_UP(ei->addr), pfn);
697
698                 if (pfn >= limit_pfn)
699                         break;
700         }
701 }
702 #endif
703
704 #ifdef CONFIG_HIBERNATION
705 /**
706  * Mark ACPI NVS memory region, so that we can save/restore it during
707  * hibernation and the subsequent resume.
708  */
709 static int __init e820_mark_nvs_memory(void)
710 {
711         int i;
712
713         for (i = 0; i < e820.nr_map; i++) {
714                 struct e820entry *ei = &e820.map[i];
715
716                 if (ei->type == E820_NVS)
717                         hibernate_nvs_register(ei->addr, ei->size);
718         }
719
720         return 0;
721 }
722 core_initcall(e820_mark_nvs_memory);
723 #endif
724
725 /*
726  * Early reserved memory areas.
727  */
728 #define MAX_EARLY_RES 32
729
730 struct early_res {
731         u64 start, end;
732         char name[16];
733         char overlap_ok;
734 };
735 static struct early_res early_res[MAX_EARLY_RES] __initdata = {
736         { 0, PAGE_SIZE, "BIOS data page", 1 },  /* BIOS data page */
737 #if defined(CONFIG_X86_32) && defined(CONFIG_X86_TRAMPOLINE)
738         /*
739          * But first pinch a few for the stack/trampoline stuff
740          * FIXME: Don't need the extra page at 4K, but need to fix
741          * trampoline before removing it. (see the GDT stuff)
742          */
743         { PAGE_SIZE, PAGE_SIZE + PAGE_SIZE, "EX TRAMPOLINE", 1 },
744 #endif
745
746         {}
747 };
748
749 static int __init find_overlapped_early(u64 start, u64 end)
750 {
751         int i;
752         struct early_res *r;
753
754         for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) {
755                 r = &early_res[i];
756                 if (end > r->start && start < r->end)
757                         break;
758         }
759
760         return i;
761 }
762
763 /*
764  * Drop the i-th range from the early reservation map,
765  * by copying any higher ranges down one over it, and
766  * clearing what had been the last slot.
767  */
768 static void __init drop_range(int i)
769 {
770         int j;
771
772         for (j = i + 1; j < MAX_EARLY_RES && early_res[j].end; j++)
773                 ;
774
775         memmove(&early_res[i], &early_res[i + 1],
776                (j - 1 - i) * sizeof(struct early_res));
777
778         early_res[j - 1].end = 0;
779 }
780
781 /*
782  * Split any existing ranges that:
783  *  1) are marked 'overlap_ok', and
784  *  2) overlap with the stated range [start, end)
785  * into whatever portion (if any) of the existing range is entirely
786  * below or entirely above the stated range.  Drop the portion
787  * of the existing range that overlaps with the stated range,
788  * which will allow the caller of this routine to then add that
789  * stated range without conflicting with any existing range.
790  */
791 static void __init drop_overlaps_that_are_ok(u64 start, u64 end)
792 {
793         int i;
794         struct early_res *r;
795         u64 lower_start, lower_end;
796         u64 upper_start, upper_end;
797         char name[16];
798
799         for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) {
800                 r = &early_res[i];
801
802                 /* Continue past non-overlapping ranges */
803                 if (end <= r->start || start >= r->end)
804                         continue;
805
806                 /*
807                  * Leave non-ok overlaps as is; let caller
808                  * panic "Overlapping early reservations"
809                  * when it hits this overlap.
810                  */
811                 if (!r->overlap_ok)
812                         return;
813
814                 /*
815                  * We have an ok overlap.  We will drop it from the early
816                  * reservation map, and add back in any non-overlapping
817                  * portions (lower or upper) as separate, overlap_ok,
818                  * non-overlapping ranges.
819                  */
820
821                 /* 1. Note any non-overlapping (lower or upper) ranges. */
822                 strncpy(name, r->name, sizeof(name) - 1);
823
824                 lower_start = lower_end = 0;
825                 upper_start = upper_end = 0;
826                 if (r->start < start) {
827                         lower_start = r->start;
828                         lower_end = start;
829                 }
830                 if (r->end > end) {
831                         upper_start = end;
832                         upper_end = r->end;
833                 }
834
835                 /* 2. Drop the original ok overlapping range */
836                 drop_range(i);
837
838                 i--;            /* resume for-loop on copied down entry */
839
840                 /* 3. Add back in any non-overlapping ranges. */
841                 if (lower_end)
842                         reserve_early_overlap_ok(lower_start, lower_end, name);
843                 if (upper_end)
844                         reserve_early_overlap_ok(upper_start, upper_end, name);
845         }
846 }
847
848 static void __init __reserve_early(u64 start, u64 end, char *name,
849                                                 int overlap_ok)
850 {
851         int i;
852         struct early_res *r;
853
854         i = find_overlapped_early(start, end);
855         if (i >= MAX_EARLY_RES)
856                 panic("Too many early reservations");
857         r = &early_res[i];
858         if (r->end)
859                 panic("Overlapping early reservations "
860                       "%llx-%llx %s to %llx-%llx %s\n",
861                       start, end - 1, name?name:"", r->start,
862                       r->end - 1, r->name);
863         r->start = start;
864         r->end = end;
865         r->overlap_ok = overlap_ok;
866         if (name)
867                 strncpy(r->name, name, sizeof(r->name) - 1);
868 }
869
870 /*
871  * A few early reservtations come here.
872  *
873  * The 'overlap_ok' in the name of this routine does -not- mean it
874  * is ok for these reservations to overlap an earlier reservation.
875  * Rather it means that it is ok for subsequent reservations to
876  * overlap this one.
877  *
878  * Use this entry point to reserve early ranges when you are doing
879  * so out of "Paranoia", reserving perhaps more memory than you need,
880  * just in case, and don't mind a subsequent overlapping reservation
881  * that is known to be needed.
882  *
883  * The drop_overlaps_that_are_ok() call here isn't really needed.
884  * It would be needed if we had two colliding 'overlap_ok'
885  * reservations, so that the second such would not panic on the
886  * overlap with the first.  We don't have any such as of this
887  * writing, but might as well tolerate such if it happens in
888  * the future.
889  */
890 void __init reserve_early_overlap_ok(u64 start, u64 end, char *name)
891 {
892         drop_overlaps_that_are_ok(start, end);
893         __reserve_early(start, end, name, 1);
894 }
895
896 /*
897  * Most early reservations come here.
898  *
899  * We first have drop_overlaps_that_are_ok() drop any pre-existing
900  * 'overlap_ok' ranges, so that we can then reserve this memory
901  * range without risk of panic'ing on an overlapping overlap_ok
902  * early reservation.
903  */
904 void __init reserve_early(u64 start, u64 end, char *name)
905 {
906         if (start >= end)
907                 return;
908
909         drop_overlaps_that_are_ok(start, end);
910         __reserve_early(start, end, name, 0);
911 }
912
913 void __init free_early(u64 start, u64 end)
914 {
915         struct early_res *r;
916         int i;
917
918         i = find_overlapped_early(start, end);
919         r = &early_res[i];
920         if (i >= MAX_EARLY_RES || r->end != end || r->start != start)
921                 panic("free_early on not reserved area: %llx-%llx!",
922                          start, end - 1);
923
924         drop_range(i);
925 }
926
927 void __init early_res_to_bootmem(u64 start, u64 end)
928 {
929         int i, count;
930         u64 final_start, final_end;
931
932         count  = 0;
933         for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++)
934                 count++;
935
936         printk(KERN_INFO "(%d early reservations) ==> bootmem [%010llx - %010llx]\n",
937                          count, start, end);
938         for (i = 0; i < count; i++) {
939                 struct early_res *r = &early_res[i];
940                 printk(KERN_INFO "  #%d [%010llx - %010llx] %16s", i,
941                         r->start, r->end, r->name);
942                 final_start = max(start, r->start);
943                 final_end = min(end, r->end);
944                 if (final_start >= final_end) {
945                         printk(KERN_CONT "\n");
946                         continue;
947                 }
948                 printk(KERN_CONT " ==> [%010llx - %010llx]\n",
949                         final_start, final_end);
950                 reserve_bootmem_generic(final_start, final_end - final_start,
951                                 BOOTMEM_DEFAULT);
952         }
953 }
954
955 /* Check for already reserved areas */
956 static inline int __init bad_addr(u64 *addrp, u64 size, u64 align)
957 {
958         int i;
959         u64 addr = *addrp;
960         int changed = 0;
961         struct early_res *r;
962 again:
963         i = find_overlapped_early(addr, addr + size);
964         r = &early_res[i];
965         if (i < MAX_EARLY_RES && r->end) {
966                 *addrp = addr = round_up(r->end, align);
967                 changed = 1;
968                 goto again;
969         }
970         return changed;
971 }
972
973 /* Check for already reserved areas */
974 static inline int __init bad_addr_size(u64 *addrp, u64 *sizep, u64 align)
975 {
976         int i;
977         u64 addr = *addrp, last;
978         u64 size = *sizep;
979         int changed = 0;
980 again:
981         last = addr + size;
982         for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) {
983                 struct early_res *r = &early_res[i];
984                 if (last > r->start && addr < r->start) {
985                         size = r->start - addr;
986                         changed = 1;
987                         goto again;
988                 }
989                 if (last > r->end && addr < r->end) {
990                         addr = round_up(r->end, align);
991                         size = last - addr;
992                         changed = 1;
993                         goto again;
994                 }
995                 if (last <= r->end && addr >= r->start) {
996                         (*sizep)++;
997                         return 0;
998                 }
999         }
1000         if (changed) {
1001                 *addrp = addr;
1002                 *sizep = size;
1003         }
1004         return changed;
1005 }
1006
1007 /*
1008  * Find a free area with specified alignment in a specific range.
1009  */
1010 u64 __init find_e820_area(u64 start, u64 end, u64 size, u64 align)
1011 {
1012         int i;
1013
1014         for (i = 0; i < e820.nr_map; i++) {
1015                 struct e820entry *ei = &e820.map[i];
1016                 u64 addr, last;
1017                 u64 ei_last;
1018
1019                 if (ei->type != E820_RAM)
1020                         continue;
1021                 addr = round_up(ei->addr, align);
1022                 ei_last = ei->addr + ei->size;
1023                 if (addr < start)
1024                         addr = round_up(start, align);
1025                 if (addr >= ei_last)
1026                         continue;
1027                 while (bad_addr(&addr, size, align) && addr+size <= ei_last)
1028                         ;
1029                 last = addr + size;
1030                 if (last > ei_last)
1031                         continue;
1032                 if (last > end)
1033                         continue;
1034                 return addr;
1035         }
1036         return -1ULL;
1037 }
1038
1039 /*
1040  * Find next free range after *start
1041  */
1042 u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align)
1043 {
1044         int i;
1045
1046         for (i = 0; i < e820.nr_map; i++) {
1047                 struct e820entry *ei = &e820.map[i];
1048                 u64 addr, last;
1049                 u64 ei_last;
1050
1051                 if (ei->type != E820_RAM)
1052                         continue;
1053                 addr = round_up(ei->addr, align);
1054                 ei_last = ei->addr + ei->size;
1055                 if (addr < start)
1056                         addr = round_up(start, align);
1057                 if (addr >= ei_last)
1058                         continue;
1059                 *sizep = ei_last - addr;
1060                 while (bad_addr_size(&addr, sizep, align) &&
1061                         addr + *sizep <= ei_last)
1062                         ;
1063                 last = addr + *sizep;
1064                 if (last > ei_last)
1065                         continue;
1066                 return addr;
1067         }
1068
1069         return -1ULL;
1070 }
1071
1072 /*
1073  * pre allocated 4k and reserved it in e820
1074  */
1075 u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align)
1076 {
1077         u64 size = 0;
1078         u64 addr;
1079         u64 start;
1080
1081         for (start = startt; ; start += size) {
1082                 start = find_e820_area_size(start, &size, align);
1083                 if (!(start + 1))
1084                         return 0;
1085                 if (size >= sizet)
1086                         break;
1087         }
1088
1089 #ifdef CONFIG_X86_32
1090         if (start >= MAXMEM)
1091                 return 0;
1092         if (start + size > MAXMEM)
1093                 size = MAXMEM - start;
1094 #endif
1095
1096         addr = round_down(start + size - sizet, align);
1097         if (addr < start)
1098                 return 0;
1099         e820_update_range(addr, sizet, E820_RAM, E820_RESERVED);
1100         e820_update_range_saved(addr, sizet, E820_RAM, E820_RESERVED);
1101         printk(KERN_INFO "update e820 for early_reserve_e820\n");
1102         update_e820();
1103         update_e820_saved();
1104
1105         return addr;
1106 }
1107
1108 #ifdef CONFIG_X86_32
1109 # ifdef CONFIG_X86_PAE
1110 #  define MAX_ARCH_PFN          (1ULL<<(36-PAGE_SHIFT))
1111 # else
1112 #  define MAX_ARCH_PFN          (1ULL<<(32-PAGE_SHIFT))
1113 # endif
1114 #else /* CONFIG_X86_32 */
1115 # define MAX_ARCH_PFN MAXMEM>>PAGE_SHIFT
1116 #endif
1117
1118 /*
1119  * Find the highest page frame number we have available
1120  */
1121 static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
1122 {
1123         int i;
1124         unsigned long last_pfn = 0;
1125         unsigned long max_arch_pfn = MAX_ARCH_PFN;
1126
1127         for (i = 0; i < e820.nr_map; i++) {
1128                 struct e820entry *ei = &e820.map[i];
1129                 unsigned long start_pfn;
1130                 unsigned long end_pfn;
1131
1132                 if (ei->type != type)
1133                         continue;
1134
1135                 start_pfn = ei->addr >> PAGE_SHIFT;
1136                 end_pfn = (ei->addr + ei->size) >> PAGE_SHIFT;
1137
1138                 if (start_pfn >= limit_pfn)
1139                         continue;
1140                 if (end_pfn > limit_pfn) {
1141                         last_pfn = limit_pfn;
1142                         break;
1143                 }
1144                 if (end_pfn > last_pfn)
1145                         last_pfn = end_pfn;
1146         }
1147
1148         if (last_pfn > max_arch_pfn)
1149                 last_pfn = max_arch_pfn;
1150
1151         printk(KERN_INFO "last_pfn = %#lx max_arch_pfn = %#lx\n",
1152                          last_pfn, max_arch_pfn);
1153         return last_pfn;
1154 }
1155 unsigned long __init e820_end_of_ram_pfn(void)
1156 {
1157         return e820_end_pfn(MAX_ARCH_PFN, E820_RAM);
1158 }
1159
1160 unsigned long __init e820_end_of_low_ram_pfn(void)
1161 {
1162         return e820_end_pfn(1UL<<(32 - PAGE_SHIFT), E820_RAM);
1163 }
1164 /*
1165  * Finds an active region in the address range from start_pfn to last_pfn and
1166  * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
1167  */
1168 int __init e820_find_active_region(const struct e820entry *ei,
1169                                   unsigned long start_pfn,
1170                                   unsigned long last_pfn,
1171                                   unsigned long *ei_startpfn,
1172                                   unsigned long *ei_endpfn)
1173 {
1174         u64 align = PAGE_SIZE;
1175
1176         *ei_startpfn = round_up(ei->addr, align) >> PAGE_SHIFT;
1177         *ei_endpfn = round_down(ei->addr + ei->size, align) >> PAGE_SHIFT;
1178
1179         /* Skip map entries smaller than a page */
1180         if (*ei_startpfn >= *ei_endpfn)
1181                 return 0;
1182
1183         /* Skip if map is outside the node */
1184         if (ei->type != E820_RAM || *ei_endpfn <= start_pfn ||
1185                                     *ei_startpfn >= last_pfn)
1186                 return 0;
1187
1188         /* Check for overlaps */
1189         if (*ei_startpfn < start_pfn)
1190                 *ei_startpfn = start_pfn;
1191         if (*ei_endpfn > last_pfn)
1192                 *ei_endpfn = last_pfn;
1193
1194         return 1;
1195 }
1196
1197 /* Walk the e820 map and register active regions within a node */
1198 void __init e820_register_active_regions(int nid, unsigned long start_pfn,
1199                                          unsigned long last_pfn)
1200 {
1201         unsigned long ei_startpfn;
1202         unsigned long ei_endpfn;
1203         int i;
1204
1205         for (i = 0; i < e820.nr_map; i++)
1206                 if (e820_find_active_region(&e820.map[i],
1207                                             start_pfn, last_pfn,
1208                                             &ei_startpfn, &ei_endpfn))
1209                         add_active_range(nid, ei_startpfn, ei_endpfn);
1210 }
1211
1212 /*
1213  * Find the hole size (in bytes) in the memory range.
1214  * @start: starting address of the memory range to scan
1215  * @end: ending address of the memory range to scan
1216  */
1217 u64 __init e820_hole_size(u64 start, u64 end)
1218 {
1219         unsigned long start_pfn = start >> PAGE_SHIFT;
1220         unsigned long last_pfn = end >> PAGE_SHIFT;
1221         unsigned long ei_startpfn, ei_endpfn, ram = 0;
1222         int i;
1223
1224         for (i = 0; i < e820.nr_map; i++) {
1225                 if (e820_find_active_region(&e820.map[i],
1226                                             start_pfn, last_pfn,
1227                                             &ei_startpfn, &ei_endpfn))
1228                         ram += ei_endpfn - ei_startpfn;
1229         }
1230         return end - start - ((u64)ram << PAGE_SHIFT);
1231 }
1232
1233 static void early_panic(char *msg)
1234 {
1235         early_printk(msg);
1236         panic(msg);
1237 }
1238
1239 static int userdef __initdata;
1240
1241 /* "mem=nopentium" disables the 4MB page tables. */
1242 static int __init parse_memopt(char *p)
1243 {
1244         u64 mem_size;
1245
1246         if (!p)
1247                 return -EINVAL;
1248
1249 #ifdef CONFIG_X86_32
1250         if (!strcmp(p, "nopentium")) {
1251                 setup_clear_cpu_cap(X86_FEATURE_PSE);
1252                 return 0;
1253         }
1254 #endif
1255
1256         userdef = 1;
1257         mem_size = memparse(p, &p);
1258         e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
1259
1260         return 0;
1261 }
1262 early_param("mem", parse_memopt);
1263
1264 static int __init parse_memmap_opt(char *p)
1265 {
1266         char *oldp;
1267         u64 start_at, mem_size;
1268
1269         if (!p)
1270                 return -EINVAL;
1271
1272         if (!strncmp(p, "exactmap", 8)) {
1273 #ifdef CONFIG_CRASH_DUMP
1274                 /*
1275                  * If we are doing a crash dump, we still need to know
1276                  * the real mem size before original memory map is
1277                  * reset.
1278                  */
1279                 saved_max_pfn = e820_end_of_ram_pfn();
1280 #endif
1281                 e820.nr_map = 0;
1282                 userdef = 1;
1283                 return 0;
1284         }
1285
1286         oldp = p;
1287         mem_size = memparse(p, &p);
1288         if (p == oldp)
1289                 return -EINVAL;
1290
1291         userdef = 1;
1292         if (*p == '@') {
1293                 start_at = memparse(p+1, &p);
1294                 e820_add_region(start_at, mem_size, E820_RAM);
1295         } else if (*p == '#') {
1296                 start_at = memparse(p+1, &p);
1297                 e820_add_region(start_at, mem_size, E820_ACPI);
1298         } else if (*p == '$') {
1299                 start_at = memparse(p+1, &p);
1300                 e820_add_region(start_at, mem_size, E820_RESERVED);
1301         } else
1302                 e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
1303
1304         return *p == '\0' ? 0 : -EINVAL;
1305 }
1306 early_param("memmap", parse_memmap_opt);
1307
1308 void __init finish_e820_parsing(void)
1309 {
1310         if (userdef) {
1311                 u32 nr = e820.nr_map;
1312
1313                 if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr) < 0)
1314                         early_panic("Invalid user supplied memory map");
1315                 e820.nr_map = nr;
1316
1317                 printk(KERN_INFO "user-defined physical RAM map:\n");
1318                 e820_print_map("user");
1319         }
1320 }
1321
1322 static inline const char *e820_type_to_string(int e820_type)
1323 {
1324         switch (e820_type) {
1325         case E820_RESERVED_KERN:
1326         case E820_RAM:  return "System RAM";
1327         case E820_ACPI: return "ACPI Tables";
1328         case E820_NVS:  return "ACPI Non-volatile Storage";
1329         case E820_UNUSABLE:     return "Unusable memory";
1330         default:        return "reserved";
1331         }
1332 }
1333
1334 /*
1335  * Mark e820 reserved areas as busy for the resource manager.
1336  */
1337 static struct resource __initdata *e820_res;
1338 void __init e820_reserve_resources(void)
1339 {
1340         int i;
1341         struct resource *res;
1342         u64 end;
1343
1344         res = alloc_bootmem(sizeof(struct resource) * e820.nr_map);
1345         e820_res = res;
1346         for (i = 0; i < e820.nr_map; i++) {
1347                 end = e820.map[i].addr + e820.map[i].size - 1;
1348                 if (end != (resource_size_t)end) {
1349                         res++;
1350                         continue;
1351                 }
1352                 res->name = e820_type_to_string(e820.map[i].type);
1353                 res->start = e820.map[i].addr;
1354                 res->end = end;
1355
1356                 res->flags = IORESOURCE_MEM;
1357
1358                 /*
1359                  * don't register the region that could be conflicted with
1360                  * pci device BAR resource and insert them later in
1361                  * pcibios_resource_survey()
1362                  */
1363                 if (e820.map[i].type != E820_RESERVED || res->start < (1ULL<<20)) {
1364                         res->flags |= IORESOURCE_BUSY;
1365                         insert_resource(&iomem_resource, res);
1366                 }
1367                 res++;
1368         }
1369
1370         for (i = 0; i < e820_saved.nr_map; i++) {
1371                 struct e820entry *entry = &e820_saved.map[i];
1372                 firmware_map_add_early(entry->addr,
1373                         entry->addr + entry->size - 1,
1374                         e820_type_to_string(entry->type));
1375         }
1376 }
1377
1378 /* How much should we pad RAM ending depending on where it is? */
1379 static unsigned long ram_alignment(resource_size_t pos)
1380 {
1381         unsigned long mb = pos >> 20;
1382
1383         /* To 64kB in the first megabyte */
1384         if (!mb)
1385                 return 64*1024;
1386
1387         /* To 1MB in the first 16MB */
1388         if (mb < 16)
1389                 return 1024*1024;
1390
1391         /* To 64MB for anything above that */
1392         return 64*1024*1024;
1393 }
1394
1395 #define MAX_RESOURCE_SIZE ((resource_size_t)-1)
1396
1397 void __init e820_reserve_resources_late(void)
1398 {
1399         int i;
1400         struct resource *res;
1401
1402         res = e820_res;
1403         for (i = 0; i < e820.nr_map; i++) {
1404                 if (!res->parent && res->end)
1405                         insert_resource_expand_to_fit(&iomem_resource, res);
1406                 res++;
1407         }
1408
1409         /*
1410          * Try to bump up RAM regions to reasonable boundaries to
1411          * avoid stolen RAM:
1412          */
1413         for (i = 0; i < e820.nr_map; i++) {
1414                 struct e820entry *entry = &e820.map[i];
1415                 u64 start, end;
1416
1417                 if (entry->type != E820_RAM)
1418                         continue;
1419                 start = entry->addr + entry->size;
1420                 end = round_up(start, ram_alignment(start)) - 1;
1421                 if (end > MAX_RESOURCE_SIZE)
1422                         end = MAX_RESOURCE_SIZE;
1423                 if (start >= end)
1424                         continue;
1425                 reserve_region_with_split(&iomem_resource, start, end,
1426                                           "RAM buffer");
1427         }
1428 }
1429
1430 char *__init default_machine_specific_memory_setup(void)
1431 {
1432         char *who = "BIOS-e820";
1433         u32 new_nr;
1434         /*
1435          * Try to copy the BIOS-supplied E820-map.
1436          *
1437          * Otherwise fake a memory map; one section from 0k->640k,
1438          * the next section from 1mb->appropriate_mem_k
1439          */
1440         new_nr = boot_params.e820_entries;
1441         sanitize_e820_map(boot_params.e820_map,
1442                         ARRAY_SIZE(boot_params.e820_map),
1443                         &new_nr);
1444         boot_params.e820_entries = new_nr;
1445         if (append_e820_map(boot_params.e820_map, boot_params.e820_entries)
1446           < 0) {
1447                 u64 mem_size;
1448
1449                 /* compare results from other methods and take the greater */
1450                 if (boot_params.alt_mem_k
1451                     < boot_params.screen_info.ext_mem_k) {
1452                         mem_size = boot_params.screen_info.ext_mem_k;
1453                         who = "BIOS-88";
1454                 } else {
1455                         mem_size = boot_params.alt_mem_k;
1456                         who = "BIOS-e801";
1457                 }
1458
1459                 e820.nr_map = 0;
1460                 e820_add_region(0, LOWMEMSIZE(), E820_RAM);
1461                 e820_add_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
1462         }
1463
1464         /* In case someone cares... */
1465         return who;
1466 }
1467
1468 void __init setup_memory_map(void)
1469 {
1470         char *who;
1471
1472         who = x86_init.resources.memory_setup();
1473         memcpy(&e820_saved, &e820, sizeof(struct e820map));
1474         printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1475         e820_print_map(who);
1476 }