[PATCH] x86-64: Remove the identity mapping as early as possible
[sfrench/cifs-2.6.git] / arch / x86_64 / kernel / head64.c
index 5c529c1e3d6c9c3954691cccdb7ec7c72e5e8d32..6c34bdd22e2634df6bdb41cc1db8aba482ddf33f 100644 (file)
 #include <asm/setup.h>
 #include <asm/desc.h>
 #include <asm/pgtable.h>
+#include <asm/tlbflush.h>
 #include <asm/sections.h>
 
+static void __init zap_identity_mappings(void)
+{
+       pgd_t *pgd = pgd_offset_k(0UL);
+       pgd_clear(pgd);
+       __flush_tlb();
+}
+
 /* Don't add a printk in there. printk relies on the PDA which is not initialized 
    yet. */
 static void __init clear_bss(void)
@@ -57,18 +65,15 @@ void __init x86_64_start_kernel(char * real_mode_data)
        /* clear bss before set_intr_gate with early_idt_handler */
        clear_bss();
 
+       /* Make NULL pointers segfault */
+       zap_identity_mappings();
+
        for (i = 0; i < IDT_ENTRIES; i++)
                set_intr_gate(i, early_idt_handler);
        asm volatile("lidt %0" :: "m" (idt_descr));
 
        early_printk("Kernel alive\n");
 
-       /*
-        * switch to init_level4_pgt from boot_level4_pgt
-        */
-       memcpy(init_level4_pgt, boot_level4_pgt, PTRS_PER_PGD*sizeof(pgd_t));
-       asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt)));
-
        for (i = 0; i < NR_CPUS; i++)
                cpu_pda(i) = &boot_cpu_pda[i];