- supported.conf: Added sparse_keymap (eeepc_laptop depends on it)
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / kernel / setup-xen.c
1 /*
2  *  Copyright (C) 1995  Linus Torvalds
3  *
4  *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
5  *
6  *  Memory region support
7  *      David Parsons <orc@pell.chi.il.us>, July-August 1999
8  *
9  *  Added E820 sanitization routine (removes overlapping memory regions);
10  *  Brian Moyle <bmoyle@mvista.com>, February 2001
11  *
12  * Moved CPU detection code to cpu/${cpu}.c
13  *    Patrick Mochel <mochel@osdl.org>, March 2002
14  *
15  *  Provisions for empty E820 memory regions (reported by certain BIOSes).
16  *  Alex Achenbach <xela@slit.de>, December 2002.
17  *
18  */
19
20 /*
21  * This file handles the architecture-dependent parts of initialization
22  */
23
24 #include <linux/sched.h>
25 #include <linux/mm.h>
26 #include <linux/mmzone.h>
27 #include <linux/screen_info.h>
28 #include <linux/ioport.h>
29 #include <linux/acpi.h>
30 #include <linux/sfi.h>
31 #include <linux/apm_bios.h>
32 #include <linux/initrd.h>
33 #include <linux/bootmem.h>
34 #include <linux/seq_file.h>
35 #include <linux/console.h>
36 #include <linux/mca.h>
37 #include <linux/root_dev.h>
38 #include <linux/highmem.h>
39 #include <linux/module.h>
40 #include <linux/efi.h>
41 #include <linux/init.h>
42 #include <linux/edd.h>
43 #include <linux/iscsi_ibft.h>
44 #include <linux/nodemask.h>
45 #include <linux/kexec.h>
46 #include <linux/dmi.h>
47 #include <linux/pfn.h>
48 #include <linux/pci.h>
49 #include <asm/pci-direct.h>
50 #include <linux/init_ohci1394_dma.h>
51 #include <linux/kvm_para.h>
52
53 #include <linux/errno.h>
54 #include <linux/kernel.h>
55 #include <linux/stddef.h>
56 #include <linux/unistd.h>
57 #include <linux/ptrace.h>
58 #include <linux/slab.h>
59 #include <linux/user.h>
60 #include <linux/delay.h>
61
62 #include <linux/kallsyms.h>
63 #include <linux/cpufreq.h>
64 #include <linux/dma-mapping.h>
65 #include <linux/ctype.h>
66 #include <linux/uaccess.h>
67
68 #include <linux/percpu.h>
69 #include <linux/crash_dump.h>
70 #include <linux/tboot.h>
71
72 #include <video/edid.h>
73
74 #include <asm/mtrr.h>
75 #include <asm/apic.h>
76 #include <asm/e820.h>
77 #include <asm/mpspec.h>
78 #include <asm/setup.h>
79 #include <asm/efi.h>
80 #include <asm/timer.h>
81 #include <asm/i8259.h>
82 #include <asm/sections.h>
83 #include <asm/dmi.h>
84 #include <asm/io_apic.h>
85 #include <asm/ist.h>
86 #include <asm/vmi.h>
87 #include <asm/setup_arch.h>
88 #include <asm/bios_ebda.h>
89 #include <asm/cacheflush.h>
90 #include <asm/processor.h>
91 #include <asm/bugs.h>
92
93 #include <asm/system.h>
94 #include <asm/vsyscall.h>
95 #include <asm/cpu.h>
96 #include <asm/desc.h>
97 #include <asm/dma.h>
98 #include <asm/iommu.h>
99 #include <asm/gart.h>
100 #include <asm/mmu_context.h>
101 #include <asm/proto.h>
102
103 #include <asm/paravirt.h>
104 #include <asm/hypervisor.h>
105
106 #include <asm/percpu.h>
107 #include <asm/topology.h>
108 #include <asm/apicdef.h>
109 #ifdef CONFIG_X86_64
110 #include <asm/numa_64.h>
111 #endif
112 #include <asm/mce.h>
113
114 #ifdef CONFIG_XEN
115 #include <asm/hypervisor.h>
116 #include <xen/interface/kexec.h>
117 #include <xen/interface/memory.h>
118 #include <xen/interface/nmi.h>
119 #include <xen/interface/physdev.h>
120 #include <xen/features.h>
121 #include <xen/firmware.h>
122 #include <xen/xencons.h>
123
124 static int xen_panic_event(struct notifier_block *, unsigned long, void *);
125 static struct notifier_block xen_panic_block = {
126         xen_panic_event, NULL, 0 /* try to go last */
127 };
128
129 unsigned long *phys_to_machine_mapping;
130 EXPORT_SYMBOL(phys_to_machine_mapping);
131
132 unsigned long *pfn_to_mfn_frame_list_list, **pfn_to_mfn_frame_list;
133
134 /* Raw start-of-day parameters from the hypervisor. */
135 start_info_t *xen_start_info;
136 EXPORT_SYMBOL(xen_start_info);
137 #endif
138
139 /*
140  * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
141  * The direct mapping extends to max_pfn_mapped, so that we can directly access
142  * apertures, ACPI and other tables without having to play with fixmaps.
143  */
144 unsigned long max_low_pfn_mapped;
145 unsigned long max_pfn_mapped;
146
147 RESERVE_BRK(dmi_alloc, 65536);
148
149 unsigned int boot_cpu_id __read_mostly;
150
151 static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
152 unsigned long _brk_end = (unsigned long)__brk_base;
153
154 #ifndef CONFIG_XEN
155 #ifdef CONFIG_X86_64
156 int default_cpu_present_to_apicid(int mps_cpu)
157 {
158         return __default_cpu_present_to_apicid(mps_cpu);
159 }
160
161 int default_check_phys_apicid_present(int phys_apicid)
162 {
163         return __default_check_phys_apicid_present(phys_apicid);
164 }
165 #endif
166
167 #ifndef CONFIG_DEBUG_BOOT_PARAMS
168 struct boot_params __initdata boot_params;
169 #else
170 struct boot_params boot_params;
171 #endif
172 #endif
173
174 /*
175  * Machine setup..
176  */
177 static struct resource data_resource = {
178         .name   = "Kernel data",
179         .start  = 0,
180         .end    = 0,
181         .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
182 };
183
184 static struct resource code_resource = {
185         .name   = "Kernel code",
186         .start  = 0,
187         .end    = 0,
188         .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
189 };
190
191 static struct resource bss_resource = {
192         .name   = "Kernel bss",
193         .start  = 0,
194         .end    = 0,
195         .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
196 };
197
198
199 #ifdef CONFIG_X86_32
200 /* cpu data as detected by the assembly code in head.S */
201 struct cpuinfo_x86 new_cpu_data __cpuinitdata = {0, 0, 0, 0, -1, 1, 0, 0, -1};
202 /* common cpu data for all cpus */
203 struct cpuinfo_x86 boot_cpu_data __read_mostly = {0, 0, 0, 0, -1, 1, 0, 0, -1};
204 EXPORT_SYMBOL(boot_cpu_data);
205 #ifndef CONFIG_XEN
206 static void set_mca_bus(int x)
207 {
208 #ifdef CONFIG_MCA
209         MCA_bus = x;
210 #endif
211 }
212
213 unsigned int def_to_bigsmp;
214
215 /* for MCA, but anyone else can use it if they want */
216 unsigned int machine_id;
217 unsigned int machine_submodel_id;
218 unsigned int BIOS_revision;
219
220 struct apm_info apm_info;
221 EXPORT_SYMBOL(apm_info);
222 #endif
223
224 #if defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
225 struct ist_info ist_info;
226 EXPORT_SYMBOL(ist_info);
227 #elif defined(CONFIG_X86_SPEEDSTEP_SMI)
228 struct ist_info ist_info;
229 #endif
230
231 #else
232 struct cpuinfo_x86 boot_cpu_data __read_mostly = {
233         .x86_phys_bits = MAX_PHYSMEM_BITS,
234 };
235 EXPORT_SYMBOL(boot_cpu_data);
236 #endif
237
238
239 #if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
240 unsigned long mmu_cr4_features;
241 #else
242 unsigned long mmu_cr4_features = X86_CR4_PAE;
243 #endif
244
245 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
246 int bootloader_type, bootloader_version;
247
248 /*
249  * Setup options
250  */
251 struct screen_info screen_info;
252 EXPORT_SYMBOL(screen_info);
253 struct edid_info edid_info;
254 EXPORT_SYMBOL_GPL(edid_info);
255
256 extern int root_mountflags;
257
258 unsigned long saved_video_mode;
259
260 #define RAMDISK_IMAGE_START_MASK        0x07FF
261 #define RAMDISK_PROMPT_FLAG             0x8000
262 #define RAMDISK_LOAD_FLAG               0x4000
263
264 static char __initdata command_line[COMMAND_LINE_SIZE];
265 #ifdef CONFIG_CMDLINE_BOOL
266 static char __initdata builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
267 #endif
268
269 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
270 struct edd edd;
271 #ifdef CONFIG_EDD_MODULE
272 EXPORT_SYMBOL(edd);
273 #endif
274 #ifndef CONFIG_XEN
275 /**
276  * copy_edd() - Copy the BIOS EDD information
277  *              from boot_params into a safe place.
278  *
279  */
280 static inline void copy_edd(void)
281 {
282      memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
283             sizeof(edd.mbr_signature));
284      memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info));
285      edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries;
286      edd.edd_info_nr = boot_params.eddbuf_entries;
287 }
288 #endif
289 #else
290 static inline void copy_edd(void)
291 {
292 }
293 #endif
294
295 void * __init extend_brk(size_t size, size_t align)
296 {
297         size_t mask = align - 1;
298         void *ret;
299
300         BUG_ON(_brk_start == 0);
301         BUG_ON(align & mask);
302
303         _brk_end = (_brk_end + mask) & ~mask;
304         BUG_ON((char *)(_brk_end + size) > __brk_limit);
305
306         ret = (void *)_brk_end;
307         _brk_end += size;
308
309         memset(ret, 0, size);
310
311         return ret;
312 }
313
314 #if defined(CONFIG_X86_64) && !defined(CONFIG_XEN)
315 static void __init init_gbpages(void)
316 {
317         if (direct_gbpages && cpu_has_gbpages)
318                 printk(KERN_INFO "Using GB pages for direct mapping\n");
319         else
320                 direct_gbpages = 0;
321 }
322 #else
323 static inline void init_gbpages(void)
324 {
325 }
326 #endif
327
328 static void __init reserve_brk(void)
329 {
330         if (_brk_end > _brk_start)
331                 reserve_early(__pa(_brk_start), __pa(_brk_end), "BRK");
332
333         /* Mark brk area as locked down and no longer taking any
334            new allocations */
335         _brk_start = 0;
336 }
337
338 #ifdef CONFIG_BLK_DEV_INITRD
339
340 #define MAX_MAP_CHUNK   (NR_FIX_BTMAPS << PAGE_SHIFT)
341 static void __init relocate_initrd(void)
342 {
343 #ifndef CONFIG_XEN
344         u64 ramdisk_image = boot_params.hdr.ramdisk_image;
345         u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
346         u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
347         u64 ramdisk_here;
348         unsigned long slop, clen, mapaddr;
349         char *p, *q;
350
351         /* We need to move the initrd down into lowmem */
352         ramdisk_here = find_e820_area(0, end_of_lowmem, ramdisk_size,
353                                          PAGE_SIZE);
354
355         if (ramdisk_here == -1ULL)
356                 panic("Cannot find place for new RAMDISK of size %lld\n",
357                          ramdisk_size);
358
359         /* Note: this includes all the lowmem currently occupied by
360            the initrd, we rely on that fact to keep the data intact. */
361         reserve_early(ramdisk_here, ramdisk_here + ramdisk_size,
362                          "NEW RAMDISK");
363         initrd_start = ramdisk_here + PAGE_OFFSET;
364         initrd_end   = initrd_start + ramdisk_size;
365         printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
366                          ramdisk_here, ramdisk_here + ramdisk_size);
367
368         q = (char *)initrd_start;
369
370         /* Copy any lowmem portion of the initrd */
371         if (ramdisk_image < end_of_lowmem) {
372                 clen = end_of_lowmem - ramdisk_image;
373                 p = (char *)__va(ramdisk_image);
374                 memcpy(q, p, clen);
375                 q += clen;
376                 ramdisk_image += clen;
377                 ramdisk_size  -= clen;
378         }
379
380         /* Copy the highmem portion of the initrd */
381         while (ramdisk_size) {
382                 slop = ramdisk_image & ~PAGE_MASK;
383                 clen = ramdisk_size;
384                 if (clen > MAX_MAP_CHUNK-slop)
385                         clen = MAX_MAP_CHUNK-slop;
386                 mapaddr = ramdisk_image & PAGE_MASK;
387                 p = early_memremap(mapaddr, clen+slop);
388                 memcpy(q, p+slop, clen);
389                 early_iounmap(p, clen+slop);
390                 q += clen;
391                 ramdisk_image += clen;
392                 ramdisk_size  -= clen;
393         }
394         /* high pages is not converted by early_res_to_bootmem */
395         ramdisk_image = boot_params.hdr.ramdisk_image;
396         ramdisk_size  = boot_params.hdr.ramdisk_size;
397         printk(KERN_INFO "Move RAMDISK from %016llx - %016llx to"
398                 " %08llx - %08llx\n",
399                 ramdisk_image, ramdisk_image + ramdisk_size - 1,
400                 ramdisk_here, ramdisk_here + ramdisk_size - 1);
401 #else
402         printk(KERN_ERR "initrd extends beyond end of memory "
403                "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
404                __pa(xen_start_info->mod_start) + xen_start_info->mod_len,
405                max_low_pfn_mapped << PAGE_SHIFT);
406         initrd_start = 0;
407 #endif
408 }
409
410 static void __init reserve_initrd(void)
411 {
412 #ifndef CONFIG_XEN
413         u64 ramdisk_image = boot_params.hdr.ramdisk_image;
414         u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
415         u64 ramdisk_end   = ramdisk_image + ramdisk_size;
416         u64 end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
417
418         if (!boot_params.hdr.type_of_loader ||
419             !ramdisk_image || !ramdisk_size)
420                 return;         /* No initrd provided by bootloader */
421 #else
422         unsigned long ramdisk_image = __pa(xen_start_info->mod_start);
423         unsigned long ramdisk_size  = xen_start_info->mod_len;
424         unsigned long ramdisk_end   = ramdisk_image + ramdisk_size;
425         unsigned long end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
426
427         if (!xen_start_info->mod_start || !ramdisk_size)
428                 return;         /* No initrd provided by bootloader */
429 #endif
430
431         initrd_start = 0;
432
433         if (ramdisk_size >= (end_of_lowmem>>1)) {
434                 free_early(ramdisk_image, ramdisk_end);
435                 printk(KERN_ERR "initrd too large to handle, "
436                        "disabling initrd\n");
437                 return;
438         }
439
440         printk(KERN_INFO "RAMDISK: %08lx - %08lx\n", ramdisk_image,
441                         ramdisk_end);
442
443
444         if (ramdisk_end <= end_of_lowmem) {
445                 /* All in lowmem, easy case */
446                 /*
447                  * don't need to reserve again, already reserved early
448                  * in i386_start_kernel
449                  */
450                 initrd_start = ramdisk_image + PAGE_OFFSET;
451                 initrd_end = initrd_start + ramdisk_size;
452 #ifdef CONFIG_X86_64_XEN
453                 initrd_below_start_ok = 1;
454 #endif
455                 return;
456         }
457
458         relocate_initrd();
459
460         free_early(ramdisk_image, ramdisk_end);
461 }
462 #else
463 static void __init reserve_initrd(void)
464 {
465 }
466 #endif /* CONFIG_BLK_DEV_INITRD */
467
468 static void __init parse_setup_data(void)
469 {
470 #ifndef CONFIG_XEN
471         struct setup_data *data;
472         u64 pa_data;
473
474         if (boot_params.hdr.version < 0x0209)
475                 return;
476         pa_data = boot_params.hdr.setup_data;
477         while (pa_data) {
478                 data = early_memremap(pa_data, PAGE_SIZE);
479                 switch (data->type) {
480                 case SETUP_E820_EXT:
481                         parse_e820_ext(data, pa_data);
482                         break;
483                 default:
484                         break;
485                 }
486                 pa_data = data->next;
487                 early_iounmap(data, PAGE_SIZE);
488         }
489 #endif
490 }
491
492 static void __init e820_reserve_setup_data(void)
493 {
494 #ifndef CONFIG_XEN
495         struct setup_data *data;
496         u64 pa_data;
497         int found = 0;
498
499         if (boot_params.hdr.version < 0x0209)
500                 return;
501         pa_data = boot_params.hdr.setup_data;
502         while (pa_data) {
503                 data = early_memremap(pa_data, sizeof(*data));
504                 e820_update_range(pa_data, sizeof(*data)+data->len,
505                          E820_RAM, E820_RESERVED_KERN);
506                 found = 1;
507                 pa_data = data->next;
508                 early_iounmap(data, sizeof(*data));
509         }
510         if (!found)
511                 return;
512
513         sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
514         memcpy(&e820_saved, &e820, sizeof(struct e820map));
515         printk(KERN_INFO "extended physical RAM map:\n");
516         e820_print_map("reserve setup_data");
517 #endif
518 }
519
520 static void __init reserve_early_setup_data(void)
521 {
522 #ifndef CONFIG_XEN
523         struct setup_data *data;
524         u64 pa_data;
525         char buf[32];
526
527         if (boot_params.hdr.version < 0x0209)
528                 return;
529         pa_data = boot_params.hdr.setup_data;
530         while (pa_data) {
531                 data = early_memremap(pa_data, sizeof(*data));
532                 sprintf(buf, "setup data %x", data->type);
533                 reserve_early(pa_data, pa_data+sizeof(*data)+data->len, buf);
534                 pa_data = data->next;
535                 early_iounmap(data, sizeof(*data));
536         }
537 #endif
538 }
539
540 /*
541  * --------- Crashkernel reservation ------------------------------
542  */
543
544 #ifdef CONFIG_KEXEC
545
546 #ifndef CONFIG_XEN
547 /**
548  * Reserve @size bytes of crashkernel memory at any suitable offset.
549  *
550  * @size: Size of the crashkernel memory to reserve.
551  * Returns the base address on success, and -1ULL on failure.
552  */
553 static
554 unsigned long long __init find_and_reserve_crashkernel(unsigned long long size)
555 {
556         const unsigned long long alignment = 16<<20;    /* 16M */
557         unsigned long long start = 0LL;
558
559         while (1) {
560                 int ret;
561
562                 start = find_e820_area(start, ULONG_MAX, size, alignment);
563                 if (start == -1ULL)
564                         return start;
565
566                 /* try to reserve it */
567                 ret = reserve_bootmem_generic(start, size, BOOTMEM_EXCLUSIVE);
568                 if (ret >= 0)
569                         return start;
570
571                 start += alignment;
572         }
573 }
574
575 static inline unsigned long long get_total_mem(void)
576 {
577         unsigned long long total;
578
579         total = max_low_pfn - min_low_pfn;
580 #ifdef CONFIG_HIGHMEM
581         total += highend_pfn - highstart_pfn;
582 #endif
583
584         return total << PAGE_SHIFT;
585 }
586
587 static void __init reserve_crashkernel(void)
588 {
589         unsigned long long total_mem;
590         unsigned long long crash_size, crash_base;
591         int ret;
592
593         total_mem = get_total_mem();
594
595         ret = parse_crashkernel(boot_command_line, total_mem,
596                         &crash_size, &crash_base);
597         if (ret != 0 || crash_size <= 0)
598                 return;
599
600         /* 0 means: find the address automatically */
601         if (crash_base <= 0) {
602                 crash_base = find_and_reserve_crashkernel(crash_size);
603                 if (crash_base == -1ULL) {
604                         pr_info("crashkernel reservation failed. "
605                                 "No suitable area found.\n");
606                         return;
607                 }
608         } else {
609                 ret = reserve_bootmem_generic(crash_base, crash_size,
610                                         BOOTMEM_EXCLUSIVE);
611                 if (ret < 0) {
612                         pr_info("crashkernel reservation failed - "
613                                 "memory is in use\n");
614                         return;
615                 }
616         }
617
618         printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
619                         "for crashkernel (System RAM: %ldMB)\n",
620                         (unsigned long)(crash_size >> 20),
621                         (unsigned long)(crash_base >> 20),
622                         (unsigned long)(total_mem >> 20));
623
624         crashk_res.start = crash_base;
625         crashk_res.end   = crash_base + crash_size - 1;
626         insert_resource(&iomem_resource, &crashk_res);
627 }
628 #else
629 #define reserve_crashkernel xen_machine_kexec_setup_resources
630 #endif
631 #else
632 static void __init reserve_crashkernel(void)
633 {
634 }
635 #endif
636
637 static struct resource standard_io_resources[] = {
638         { .name = "dma1", .start = 0x00, .end = 0x1f,
639                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
640         { .name = "pic1", .start = 0x20, .end = 0x21,
641                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
642         { .name = "timer0", .start = 0x40, .end = 0x43,
643                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
644         { .name = "timer1", .start = 0x50, .end = 0x53,
645                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
646         { .name = "keyboard", .start = 0x60, .end = 0x60,
647                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
648         { .name = "keyboard", .start = 0x64, .end = 0x64,
649                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
650         { .name = "dma page reg", .start = 0x80, .end = 0x8f,
651                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
652         { .name = "pic2", .start = 0xa0, .end = 0xa1,
653                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
654         { .name = "dma2", .start = 0xc0, .end = 0xdf,
655                 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
656         { .name = "fpu", .start = 0xf0, .end = 0xff,
657                 .flags = IORESOURCE_BUSY | IORESOURCE_IO }
658 };
659
660 void __init reserve_standard_io_resources(void)
661 {
662         int i;
663
664         /* Nothing to do if not running in dom0. */
665         if (!is_initial_xendomain())
666                 return;
667
668         /* request I/O space for devices used on all i[345]86 PCs */
669         for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
670                 request_resource(&ioport_resource, &standard_io_resources[i]);
671
672 }
673
674 /*
675  * Note: elfcorehdr_addr is not just limited to vmcore. It is also used by
676  * is_kdump_kernel() to determine if we are booting after a panic. Hence
677  * ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE.
678  */
679
680 #ifdef CONFIG_CRASH_DUMP
681 /* elfcorehdr= specifies the location of elf core header
682  * stored by the crashed kernel. This option will be passed
683  * by kexec loader to the capture kernel.
684  */
685 static int __init setup_elfcorehdr(char *arg)
686 {
687         char *end;
688         if (!arg)
689                 return -EINVAL;
690         elfcorehdr_addr = memparse(arg, &end);
691         return end > arg ? 0 : -EINVAL;
692 }
693 early_param("elfcorehdr", setup_elfcorehdr);
694 #endif
695
696 #ifdef CONFIG_X86_RESERVE_LOW_64K
697 static int __init dmi_low_memory_corruption(const struct dmi_system_id *d)
698 {
699         printk(KERN_NOTICE
700                 "%s detected: BIOS may corrupt low RAM, working around it.\n",
701                 d->ident);
702
703         e820_update_range(0, 0x10000, E820_RAM, E820_RESERVED);
704         sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
705
706         return 0;
707 }
708 #endif
709
710 /* List of systems that have known low memory corruption BIOS problems */
711 static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
712 #ifdef CONFIG_X86_RESERVE_LOW_64K
713         {
714                 .callback = dmi_low_memory_corruption,
715                 .ident = "AMI BIOS",
716                 .matches = {
717                         DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
718                 },
719         },
720         {
721                 .callback = dmi_low_memory_corruption,
722                 .ident = "Phoenix BIOS",
723                 .matches = {
724                         DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies"),
725                 },
726         },
727         {
728                 .callback = dmi_low_memory_corruption,
729                 .ident = "Phoenix/MSC BIOS",
730                 .matches = {
731                         DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix/MSC"),
732                 },
733         },
734         {
735         /*
736          * AMI BIOS with low memory corruption was found on Intel DG45ID board.
737          * It hase different DMI_BIOS_VENDOR = "Intel Corp.", for now we will
738          * match only DMI_BOARD_NAME and see if there is more bad products
739          * with this vendor.
740          */
741                 .callback = dmi_low_memory_corruption,
742                 .ident = "AMI BIOS",
743                 .matches = {
744                         DMI_MATCH(DMI_BOARD_NAME, "DG45ID"),
745                 },
746         },
747 #endif
748         {}
749 };
750
751 /*
752  * Determine if we were loaded by an EFI loader.  If so, then we have also been
753  * passed the efi memmap, systab, etc., so we should use these data structures
754  * for initialization.  Note, the efi init code path is determined by the
755  * global efi_enabled. This allows the same kernel image to be used on existing
756  * systems (with a traditional BIOS) as well as on EFI systems.
757  */
758 /*
759  * setup_arch - architecture-specific boot-time initializations
760  *
761  * Note: On x86_64, fixmaps are ready for use even before this is called.
762  */
763
764 void __init setup_arch(char **cmdline_p)
765 {
766 #ifdef CONFIG_XEN
767         unsigned int i;
768         unsigned long p2m_pages;
769         struct physdev_set_iopl set_iopl;
770
771         if (!is_initial_xendomain()) {
772 #ifdef CONFIG_X86_32
773                 /* Force a quick death if the kernel panics (not domain 0). */
774                 extern int panic_timeout;
775                 if (!panic_timeout)
776                         panic_timeout = 1;
777 #endif
778
779                 /* Register a call for panic conditions. */
780                 atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
781         }
782 #endif /* CONFIG_XEN */
783
784 #ifdef CONFIG_X86_32
785         memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
786         visws_early_detect();
787 #else
788         printk(KERN_INFO "Command line: %s\n", boot_command_line);
789 #endif
790
791         /* VMI may relocate the fixmap; do this before touching ioremap area */
792         vmi_init();
793
794         early_cpu_init();
795         early_ioremap_init();
796
797 #ifndef CONFIG_XEN
798         ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev);
799         screen_info = boot_params.screen_info;
800         edid_info = boot_params.edid_info;
801 #ifdef CONFIG_X86_32
802         apm_info.bios = boot_params.apm_bios_info;
803         ist_info = boot_params.ist_info;
804         if (boot_params.sys_desc_table.length != 0) {
805                 set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
806                 machine_id = boot_params.sys_desc_table.table[0];
807                 machine_submodel_id = boot_params.sys_desc_table.table[1];
808                 BIOS_revision = boot_params.sys_desc_table.table[2];
809         }
810 #endif
811         saved_video_mode = boot_params.hdr.vid_mode;
812         bootloader_type = boot_params.hdr.type_of_loader;
813         if ((bootloader_type >> 4) == 0xe) {
814                 bootloader_type &= 0xf;
815                 bootloader_type |= (boot_params.hdr.ext_loader_type+0x10) << 4;
816         }
817         bootloader_version  = bootloader_type & 0xf;
818         bootloader_version |= boot_params.hdr.ext_loader_ver << 4;
819
820 #ifdef CONFIG_BLK_DEV_RAM
821         rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
822         rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
823         rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
824 #endif
825 #ifdef CONFIG_EFI
826         if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
827 #ifdef CONFIG_X86_32
828                      "EL32",
829 #else
830                      "EL64",
831 #endif
832          4)) {
833                 efi_enabled = 1;
834                 efi_reserve_early();
835         }
836 #endif
837 #else /* CONFIG_XEN */
838 #ifdef CONFIG_X86_32
839         /* This must be initialized to UNNAMED_MAJOR for ipconfig to work
840            properly.  Setting ROOT_DEV to default to /dev/ram0 breaks initrd.
841         */
842         ROOT_DEV = MKDEV(UNNAMED_MAJOR,0);
843 #else
844         ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
845 #endif
846         if (is_initial_xendomain()) {
847                 const struct dom0_vga_console_info *info =
848                         (void *)((char *)xen_start_info +
849                                  xen_start_info->console.dom0.info_off);
850
851                 dom0_init_screen_info(info,
852                                       xen_start_info->console.dom0.info_size);
853                 xen_start_info->console.domU.mfn = 0;
854                 xen_start_info->console.domU.evtchn = 0;
855         } else
856                 screen_info.orig_video_isVGA = 0;
857         copy_edid();
858 #endif /* CONFIG_XEN */
859
860         x86_init.oem.arch_setup();
861
862         setup_memory_map();
863         parse_setup_data();
864         /* update the e820_saved too */
865         e820_reserve_setup_data();
866
867         copy_edd();
868
869 #ifndef CONFIG_XEN
870         if (!boot_params.hdr.root_flags)
871                 root_mountflags &= ~MS_RDONLY;
872 #endif
873         init_mm.start_code = (unsigned long) _text;
874         init_mm.end_code = (unsigned long) _etext;
875         init_mm.end_data = (unsigned long) _edata;
876         init_mm.brk = _brk_end;
877
878         code_resource.start = virt_to_phys(_text);
879         code_resource.end = virt_to_phys(_etext)-1;
880         data_resource.start = virt_to_phys(_etext);
881         data_resource.end = virt_to_phys(_edata)-1;
882         bss_resource.start = virt_to_phys(&__bss_start);
883         bss_resource.end = virt_to_phys(&__bss_stop)-1;
884
885 #ifdef CONFIG_CMDLINE_BOOL
886 #ifdef CONFIG_CMDLINE_OVERRIDE
887         strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
888 #else
889         if (builtin_cmdline[0]) {
890                 /* append boot loader cmdline to builtin */
891                 strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
892                 strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
893                 strlcpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
894         }
895 #endif
896 #endif
897
898         strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
899         *cmdline_p = command_line;
900
901 #ifdef CONFIG_X86_64
902         /*
903          * Must call this twice: Once just to detect whether hardware doesn't
904          * support NX (so that the early EHCI debug console setup can safely
905          * call set_fixmap(), and then again after parsing early parameters to
906          * honor the respective command line option.
907          */
908         check_efer();
909 #endif
910
911         parse_early_param();
912
913 #ifdef CONFIG_X86_64
914         check_efer();
915 #endif
916
917         /* Must be before kernel pagetables are setup */
918         vmi_activate();
919
920         /* after early param, so could get panic from serial */
921         reserve_early_setup_data();
922
923         if (acpi_mps_check()) {
924 #if defined(CONFIG_X86_LOCAL_APIC) && !defined(CONFIG_XEN)
925                 disable_apic = 1;
926 #endif
927                 setup_clear_cpu_cap(X86_FEATURE_APIC);
928         }
929
930 #ifdef CONFIG_PCI
931         if (pci_early_dump_regs)
932                 early_dump_pci_devices();
933 #endif
934
935         finish_e820_parsing();
936
937         if (efi_enabled)
938                 efi_init();
939
940         if (is_initial_xendomain()) {
941                 dmi_scan_machine();
942
943                 dmi_check_system(bad_bios_dmi_table);
944         }
945
946         /*
947          * VMware detection requires dmi to be available, so this
948          * needs to be done after dmi_scan_machine, for the BP.
949          */
950         init_hypervisor_platform();
951
952         x86_init.resources.probe_roms();
953
954 #ifndef CONFIG_XEN
955         /* after parse_early_param, so could debug it */
956         insert_resource(&iomem_resource, &code_resource);
957         insert_resource(&iomem_resource, &data_resource);
958         insert_resource(&iomem_resource, &bss_resource);
959
960
961 #ifdef CONFIG_X86_32
962         if (ppro_with_ram_bug()) {
963                 e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM,
964                                   E820_RESERVED);
965                 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
966                 printk(KERN_INFO "fixed physical RAM map:\n");
967                 e820_print_map("bad_ppro");
968         }
969 #else
970         early_gart_iommu_check();
971 #endif
972 #endif /* CONFIG_XEN */
973
974         /*
975          * partially used pages are not usable - thus
976          * we are rounding upwards:
977          */
978         max_pfn = e820_end_of_ram_pfn();
979
980         /* preallocate 4k for mptable mpc */
981         early_reserve_e820_mpc_new();
982         /* update e820 for memory not covered by WB MTRRs */
983         mtrr_bp_init();
984 #ifndef CONFIG_XEN
985         if (mtrr_trim_uncached_memory(max_pfn))
986                 max_pfn = e820_end_of_ram_pfn();
987 #endif
988
989 #ifdef CONFIG_X86_32
990         /* max_low_pfn get updated here */
991         find_low_pfn_range();
992 #else
993         num_physpages = max_pfn;
994         max_mapnr = max_pfn;
995
996 #ifdef CONFIG_X86_LOCAL_APIC
997         check_x2apic();
998 #endif
999
1000         /* How many end-of-memory variables you have, grandma! */
1001         /* need this before calling reserve_initrd */
1002         if (max_pfn > (1UL<<(32 - PAGE_SHIFT)))
1003                 max_low_pfn = e820_end_of_low_ram_pfn();
1004         else
1005                 max_low_pfn = max_pfn;
1006
1007         high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
1008 #ifndef CONFIG_XEN
1009         max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT;
1010 #endif
1011 #endif
1012
1013 #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
1014         setup_bios_corruption_check();
1015 #endif
1016
1017         printk(KERN_DEBUG "initial memory mapped : 0 - %08lx\n",
1018                         max_pfn_mapped<<PAGE_SHIFT);
1019
1020         reserve_brk();
1021
1022         init_gbpages();
1023
1024         /* max_pfn_mapped is updated here */
1025         max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT);
1026         max_pfn_mapped = max_low_pfn_mapped;
1027
1028 #ifdef CONFIG_X86_64
1029         if (max_pfn > max_low_pfn) {
1030                 max_pfn_mapped = init_memory_mapping(1UL<<32,
1031                                                      max_pfn<<PAGE_SHIFT);
1032                 /* can we preseve max_low_pfn ?*/
1033                 max_low_pfn = max_pfn;
1034         }
1035 #endif
1036
1037         /*
1038          * NOTE: On x86-32, only from this point on, fixmaps are ready for use.
1039          */
1040
1041 #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
1042         if (init_ohci1394_dma_early)
1043                 init_ohci1394_dma_on_all_controllers();
1044 #endif
1045
1046         reserve_initrd();
1047
1048 #ifndef CONFIG_XEN
1049         vsmp_init();
1050 #endif
1051
1052         io_delay_init();
1053
1054 #ifdef CONFIG_ACPI
1055         if (!is_initial_xendomain()) {
1056                 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
1057                 disable_acpi();
1058         }
1059 #endif
1060
1061         /*
1062          * Parse the ACPI tables for possible boot-time SMP configuration.
1063          */
1064         acpi_boot_table_init();
1065
1066         early_acpi_boot_init();
1067
1068 #ifdef CONFIG_ACPI_NUMA
1069         /*
1070          * Parse SRAT to discover nodes.
1071          */
1072         acpi_numa_init();
1073 #endif
1074
1075         initmem_init(0, max_pfn);
1076
1077 #ifdef CONFIG_ACPI_SLEEP
1078         /*
1079          * Reserve low memory region for sleep support.
1080          */
1081         acpi_reserve_bootmem();
1082 #endif
1083         /*
1084          * Find and reserve possible boot-time SMP configuration:
1085          */
1086         find_smp_config();
1087
1088         reserve_crashkernel();
1089
1090 #if defined(CONFIG_X86_64) && !defined(CONFIG_XEN)
1091         /*
1092          * dma32_reserve_bootmem() allocates bootmem which may conflict
1093          * with the crashkernel command line, so do that after
1094          * reserve_crashkernel()
1095          */
1096         dma32_reserve_bootmem();
1097 #endif
1098
1099         reserve_ibft_region();
1100
1101 #ifdef CONFIG_KVM_CLOCK
1102         kvmclock_init();
1103 #endif
1104
1105         x86_init.paging.pagetable_setup_start(swapper_pg_dir);
1106         paging_init();
1107         x86_init.paging.pagetable_setup_done(swapper_pg_dir);
1108
1109         tboot_probe();
1110
1111 #ifdef CONFIG_X86_64
1112         map_vsyscall();
1113 #endif
1114
1115 #ifdef CONFIG_XEN
1116         p2m_pages = max_pfn;
1117         if (xen_start_info->nr_pages > max_pfn) {
1118                 /*
1119                  * the max_pfn was shrunk (probably by mem= or highmem=
1120                  * kernel parameter); shrink reservation with the HV
1121                  */
1122                 struct xen_memory_reservation reservation = {
1123                         .address_bits = 0,
1124                         .extent_order = 0,
1125                         .domid = DOMID_SELF
1126                 };
1127                 unsigned int difference;
1128                 int ret;
1129
1130                 difference = xen_start_info->nr_pages - max_pfn;
1131
1132                 set_xen_guest_handle(reservation.extent_start,
1133                                      phys_to_machine_mapping + max_pfn);
1134                 reservation.nr_extents = difference;
1135                 ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
1136                                            &reservation);
1137                 BUG_ON(ret != difference);
1138         }
1139         else if (max_pfn > xen_start_info->nr_pages)
1140                 p2m_pages = xen_start_info->nr_pages;
1141
1142         if (!xen_feature(XENFEAT_auto_translated_physmap)) {
1143                 unsigned long i, j, size;
1144                 unsigned int k, fpp;
1145
1146                 /* Make sure we have a large enough P->M table. */
1147                 phys_to_machine_mapping = alloc_bootmem_pages(
1148                         max_pfn * sizeof(unsigned long));
1149                 memcpy(phys_to_machine_mapping,
1150                        __va(__pa(xen_start_info->mfn_list)),
1151                        p2m_pages * sizeof(unsigned long));
1152                 memset(phys_to_machine_mapping + p2m_pages, ~0,
1153                        (max_pfn - p2m_pages) * sizeof(unsigned long));
1154
1155 #ifdef CONFIG_X86_64
1156                 if (xen_start_info->mfn_list == VMEMMAP_START) {
1157                         /*
1158                          * Since it is well isolated we can (and since it is
1159                          * perhaps large we should) also free the page tables
1160                          * mapping the initial P->M table.
1161                          */
1162                         unsigned long va = VMEMMAP_START, pa;
1163                         pgd_t *pgd = pgd_offset_k(va);
1164                         pud_t *pud_page = pud_offset(pgd, 0);
1165
1166                         BUILD_BUG_ON(VMEMMAP_START & ~PGDIR_MASK);
1167                         xen_l4_entry_update(pgd, __pgd(0));
1168                         for(;;) {
1169                                 pud_t *pud = pud_page + pud_index(va);
1170
1171                                 if (pud_none(*pud))
1172                                         va += PUD_SIZE;
1173                                 else if (pud_large(*pud)) {
1174                                         pa = pud_val(*pud) & PHYSICAL_PAGE_MASK;
1175                                         make_pages_writable(__va(pa),
1176                                                 PUD_SIZE >> PAGE_SHIFT,
1177                                                 XENFEAT_writable_page_tables);
1178                                         free_bootmem(pa, PUD_SIZE);
1179                                         va += PUD_SIZE;
1180                                 } else {
1181                                         pmd_t *pmd = pmd_offset(pud, va);
1182
1183                                         if (pmd_large(*pmd)) {
1184                                                 pa = pmd_val(*pmd) & PHYSICAL_PAGE_MASK;
1185                                                 make_pages_writable(__va(pa),
1186                                                         PMD_SIZE >> PAGE_SHIFT,
1187                                                         XENFEAT_writable_page_tables);
1188                                                 free_bootmem(pa, PMD_SIZE);
1189                                         } else if (!pmd_none(*pmd)) {
1190                                                 pte_t *pte = pte_offset_kernel(pmd, va);
1191
1192                                                 for (i = 0; i < PTRS_PER_PTE; ++i) {
1193                                                         if (pte_none(pte[i]))
1194                                                                 break;
1195                                                         pa = pte_pfn(pte[i]) << PAGE_SHIFT;
1196                                                         make_page_writable(__va(pa),
1197                                                                 XENFEAT_writable_page_tables);
1198                                                         free_bootmem(pa, PAGE_SIZE);
1199                                                 }
1200                                                 ClearPagePinned(virt_to_page(pte));
1201                                                 make_page_writable(pte,
1202                                                         XENFEAT_writable_page_tables);
1203                                                 free_bootmem(__pa(pte), PAGE_SIZE);
1204                                         }
1205                                         va += PMD_SIZE;
1206                                         if (pmd_index(va))
1207                                                 continue;
1208                                         ClearPagePinned(virt_to_page(pmd));
1209                                         make_page_writable(pmd,
1210                                                 XENFEAT_writable_page_tables);
1211                                         free_bootmem(__pa((unsigned long)pmd
1212                                                           & PAGE_MASK),
1213                                                 PAGE_SIZE);
1214                                 }
1215                                 if (!pud_index(va))
1216                                         break;
1217                         }
1218                         ClearPagePinned(virt_to_page(pud_page));
1219                         make_page_writable(pud_page,
1220                                 XENFEAT_writable_page_tables);
1221                         free_bootmem(__pa((unsigned long)pud_page & PAGE_MASK),
1222                                 PAGE_SIZE);
1223                 } else if (!WARN_ON(xen_start_info->mfn_list
1224                                     < __START_KERNEL_map))
1225 #endif
1226                         free_bootmem(__pa(xen_start_info->mfn_list),
1227                                 PFN_PHYS(PFN_UP(xen_start_info->nr_pages *
1228                                                 sizeof(unsigned long))));
1229
1230
1231                 /*
1232                  * Initialise the list of the frames that specify the list of
1233                  * frames that make up the p2m table. Used by save/restore.
1234                  */
1235                 fpp = PAGE_SIZE/sizeof(unsigned long);
1236                 size = (max_pfn + fpp - 1) / fpp;
1237                 size = (size + fpp - 1) / fpp;
1238                 ++size; /* include a zero terminator for crash tools */
1239                 size *= sizeof(unsigned long);
1240                 pfn_to_mfn_frame_list_list = alloc_bootmem_pages(size);
1241                 if (size > PAGE_SIZE
1242                     && xen_create_contiguous_region((unsigned long)
1243                                                     pfn_to_mfn_frame_list_list,
1244                                                     get_order(size), 0))
1245                         BUG();
1246                 size -= sizeof(unsigned long);
1247                 pfn_to_mfn_frame_list = alloc_bootmem(size);
1248
1249                 for (i = j = 0, k = -1; i < max_pfn; i += fpp, j++) {
1250                         if (j == fpp)
1251                                 j = 0;
1252                         if (j == 0) {
1253                                 k++;
1254                                 BUG_ON(k * sizeof(unsigned long) >= size);
1255                                 pfn_to_mfn_frame_list[k] =
1256                                         alloc_bootmem_pages(PAGE_SIZE);
1257                                 pfn_to_mfn_frame_list_list[k] =
1258                                         virt_to_mfn(pfn_to_mfn_frame_list[k]);
1259                         }
1260                         pfn_to_mfn_frame_list[k][j] =
1261                                 virt_to_mfn(&phys_to_machine_mapping[i]);
1262                 }
1263                 HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
1264                 HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
1265                         virt_to_mfn(pfn_to_mfn_frame_list_list);
1266         }
1267
1268         /* Mark all ISA DMA channels in-use - using them wouldn't work. */
1269         for (i = 0; i < MAX_DMA_CHANNELS; ++i)
1270                 if (i != 4 && request_dma(i, "xen") != 0)
1271                         BUG();
1272 #else /* CONFIG_XEN */
1273         generic_apic_probe();
1274
1275         early_quirks();
1276 #endif
1277
1278         /*
1279          * Read APIC and some other early information from ACPI tables.
1280          */
1281         acpi_boot_init();
1282
1283         sfi_init();
1284
1285         /*
1286          * get boot-time SMP configuration:
1287          */
1288         if (smp_found_config)
1289                 get_smp_config();
1290
1291         prefill_possible_map();
1292
1293 #ifdef CONFIG_X86_64
1294         init_cpu_to_node();
1295 #endif
1296
1297 #ifndef CONFIG_XEN
1298         init_apic_mappings();
1299         ioapic_init_mappings();
1300
1301         /* need to wait for io_apic is mapped */
1302         probe_nr_irqs_gsi();
1303
1304         kvm_guest_init();
1305
1306         e820_reserve_resources();
1307         e820_mark_nosave_regions(max_low_pfn);
1308 #else
1309         if (is_initial_xendomain())
1310                 e820_reserve_resources();
1311 #endif
1312
1313         x86_init.resources.reserve_resources();
1314
1315 #ifndef CONFIG_XEN
1316         e820_setup_gap();
1317
1318 #ifdef CONFIG_VT
1319 #if defined(CONFIG_VGA_CONSOLE)
1320         if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY))
1321                 conswitchp = &vga_con;
1322 #elif defined(CONFIG_DUMMY_CONSOLE)
1323         conswitchp = &dummy_con;
1324 #endif
1325 #endif
1326 #else /* CONFIG_XEN */
1327         if (is_initial_xendomain())
1328                 e820_setup_gap();
1329
1330         set_iopl.iopl = 1;
1331         WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl));
1332
1333 #ifdef CONFIG_VT
1334 #ifdef CONFIG_DUMMY_CONSOLE
1335         conswitchp = &dummy_con;
1336 #endif
1337 #ifdef CONFIG_VGA_CONSOLE
1338         if (is_initial_xendomain())
1339                 conswitchp = &vga_con;
1340 #endif
1341 #endif
1342 #endif /* CONFIG_XEN */
1343         x86_init.oem.banner();
1344
1345         mcheck_intel_therm_init();
1346 }
1347
1348 #ifdef CONFIG_X86_32
1349
1350 static struct resource video_ram_resource = {
1351         .name   = "Video RAM area",
1352         .start  = 0xa0000,
1353         .end    = 0xbffff,
1354         .flags  = IORESOURCE_BUSY | IORESOURCE_MEM
1355 };
1356
1357 void __init i386_reserve_resources(void)
1358 {
1359         if (is_initial_xendomain())
1360                 request_resource(&iomem_resource, &video_ram_resource);
1361         reserve_standard_io_resources();
1362 }
1363
1364 #endif /* CONFIG_X86_32 */
1365
1366 #ifdef CONFIG_XEN
1367 static int
1368 xen_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
1369 {
1370         HYPERVISOR_shutdown(SHUTDOWN_crash);
1371         /* we're never actually going to get here... */
1372         return NOTIFY_DONE;
1373 }
1374 #endif /* !CONFIG_XEN */