Merge branch 'iommu-fixes-2.6.28' of git://git.kernel.org/pub/scm/linux/kernel/git...
[safe/jmp/linux-2.6] / arch / x86 / kernel / head64.c
index 24dbf56..d16084f 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/string.h>
 #include <linux/percpu.h>
 #include <linux/start_kernel.h>
+#include <linux/io.h>
 
 #include <asm/processor.h>
 #include <asm/proto.h>
 #include <asm/sections.h>
 #include <asm/kdebug.h>
 #include <asm/e820.h>
+#include <asm/bios_ebda.h>
+
+/* boot cpu pda */
+static struct x8664_pda _boot_cpu_pda __read_mostly;
+
+#ifdef CONFIG_SMP
+/*
+ * We install an empty cpu_pda pointer table to indicate to early users
+ * (numa_set_node) that the cpu_pda pointer table for cpus other than
+ * the boot cpu is not yet setup.
+ */
+static struct x8664_pda *__cpu_pda[NR_CPUS] __initdata;
+#else
+static struct x8664_pda *__cpu_pda[NR_CPUS] __read_mostly;
+#endif
+
+void __init x86_64_init_pda(void)
+{
+       _cpu_pda = __cpu_pda;
+       cpu_pda(0) = &_boot_cpu_pda;
+       pda_init(0);
+}
 
 static void __init zap_identity_mappings(void)
 {
@@ -49,38 +72,23 @@ static void __init copy_bootdata(char *real_mode_data)
        }
 }
 
-#define EBDA_ADDR_POINTER 0x40E
-
-static __init void reserve_ebda(void)
+void __init x86_64_start_kernel(char * real_mode_data)
 {
-       unsigned ebda_addr, ebda_size;
+       int i;
 
        /*
-        * there is a real-mode segmented pointer pointing to the
-        * 4K EBDA area at 0x40E
+        * Build-time sanity checks on the kernel image and module
+        * area mappings. (these are purely build-time and produce no code)
         */
-       ebda_addr = *(unsigned short *)__va(EBDA_ADDR_POINTER);
-       ebda_addr <<= 4;
-
-       if (!ebda_addr)
-               return;
-
-       ebda_size = *(unsigned short *)__va(ebda_addr);
-
-       /* Round EBDA up to pages */
-       if (ebda_size == 0)
-               ebda_size = 1;
-       ebda_size <<= 10;
-       ebda_size = round_up(ebda_size + (ebda_addr & ~PAGE_MASK), PAGE_SIZE);
-       if (ebda_size > 64*1024)
-               ebda_size = 64*1024;
-
-       reserve_early(ebda_addr, ebda_addr + ebda_size, "EBDA");
-}
-
-void __init x86_64_start_kernel(char * real_mode_data)
-{
-       int i;
+       BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
+       BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
+       BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
+       BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
+       BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
+       BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
+       BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
+                               (__START_KERNEL & PGDIR_MASK)));
+       BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END);
 
        /* clear bss before set_intr_gate with early_idt_handler */
        clear_bss();
@@ -88,7 +96,10 @@ void __init x86_64_start_kernel(char * real_mode_data)
        /* Make NULL pointers segfault */
        zap_identity_mappings();
 
-       for (i = 0; i < IDT_ENTRIES; i++) {
+       /* Cleanup the over mapped high alias */
+       cleanup_highmap();
+
+       for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) {
 #ifdef CONFIG_EARLY_PRINTK
                set_intr_gate(i, &early_idt_handlers[i]);
 #else
@@ -97,16 +108,21 @@ void __init x86_64_start_kernel(char * real_mode_data)
        }
        load_idt((const struct desc_ptr *)&idt_descr);
 
-       early_printk("Kernel alive\n");
+       if (console_loglevel == 10)
+               early_printk("Kernel alive\n");
 
-       for (i = 0; i < NR_CPUS; i++)
-               cpu_pda(i) = &boot_cpu_pda[i];
+       x86_64_init_pda();
 
-       pda_init(0);
+       x86_64_start_reservations(real_mode_data);
+}
+
+void __init x86_64_start_reservations(char *real_mode_data)
+{
        copy_bootdata(__va(real_mode_data));
 
        reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
 
+#ifdef CONFIG_BLK_DEV_INITRD
        /* Reserve INITRD */
        if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
                unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
@@ -114,8 +130,9 @@ void __init x86_64_start_kernel(char * real_mode_data)
                unsigned long ramdisk_end   = ramdisk_image + ramdisk_size;
                reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
        }
+#endif
 
-       reserve_ebda();
+       reserve_ebda_region();
 
        /*
         * At this point everything still needed from the boot loader