]> git.karo-electronics.de Git - linux-beck.git/blobdiff - arch/x86/kernel/setup_32.c
x86: change propagate_e820_map() back to find_max_pfn(), 32-bit, fix
[linux-beck.git] / arch / x86 / kernel / setup_32.c
index 2b3e5d45176bda99d2172a2484076e973d53cfd4..ccf3595202fa6a75073370b58b7b864f201384e8 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
@@ -46,6 +47,7 @@
 #include <linux/pfn.h>
 #include <linux/pci.h>
 #include <linux/init_ohci1394_dma.h>
+#include <linux/kvm_para.h>
 
 #include <video/edid.h>
 
 #include <asm/io.h>
 #include <asm/vmi.h>
 #include <setup_arch.h>
-#include <bios_ebda.h>
+#include <asm/bios_ebda.h>
 #include <asm/cacheflush.h>
+#include <asm/processor.h>
 
 /* This value is set up by the early boot code to point to the value
    immediately after the boot time page tables.  It contains a *physical*
    address, and must not be in the .bss segment! */
+unsigned long init_pg_tables_start __initdata = ~0UL;
 unsigned long init_pg_tables_end __initdata = ~0UL;
 
 /*
@@ -124,7 +128,12 @@ static struct resource standard_io_resources[] = { {
 }, {
        .name   = "keyboard",
        .start  = 0x0060,
-       .end    = 0x006f,
+       .end    = 0x0060,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "keyboard",
+       .start  = 0x0064,
+       .end    = 0x0064,
        .flags  = IORESOURCE_BUSY | IORESOURCE_IO
 }, {
        .name   = "dma page reg",
@@ -154,6 +163,8 @@ struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 EXPORT_SYMBOL(boot_cpu_data);
 
+unsigned int def_to_bigsmp;
+
 #ifndef CONFIG_X86_PAE
 unsigned long mmu_cr4_features;
 #else
@@ -189,7 +200,7 @@ EXPORT_SYMBOL(ist_info);
 extern void early_cpu_init(void);
 extern int root_mountflags;
 
-unsigned long saved_videomode;
+unsigned long saved_video_mode;
 
 #define RAMDISK_IMAGE_START_MASK       0x07FF
 #define RAMDISK_PROMPT_FLAG            0x8000
@@ -227,42 +238,6 @@ static inline void copy_edd(void)
 }
 #endif
 
-int __initdata user_defined_memmap = 0;
-
-/*
- * "mem=nopentium" disables the 4MB page tables.
- * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
- * to <mem>, overriding the bios size.
- * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from
- * <start> to <start>+<mem>, overriding the bios size.
- *
- * HPA tells me bootloaders need to parse mem=, so no new
- * option should be mem=  [also see Documentation/i386/boot.txt]
- */
-static int __init parse_mem(char *arg)
-{
-       if (!arg)
-               return -EINVAL;
-
-       if (strcmp(arg, "nopentium") == 0) {
-               setup_clear_cpu_cap(X86_FEATURE_PSE);
-       } else {
-               /* If the user specifies memory size, we
-                * limit the BIOS-provided memory map to
-                * that size. exactmap can be used to specify
-                * the exact map. mem=number can be used to
-                * trim the existing memory map.
-                */
-               unsigned long long mem_size;
-
-               mem_size = memparse(arg, &arg);
-               limit_regions(mem_size);
-               user_defined_memmap = 1;
-       }
-       return 0;
-}
-early_param("mem", parse_mem);
-
 #ifdef CONFIG_PROC_VMCORE
 /* elfcorehdr= specifies the location of elf core header
  * stored by the crashed kernel.
@@ -385,19 +360,8 @@ unsigned long __init find_max_low_pfn(void)
        return max_low_pfn;
 }
 
-/*
- * workaround for Dell systems that neglect to reserve EBDA
- */
-static void __init reserve_ebda_region(void)
-{
-       unsigned int addr;
-       addr = get_bios_ebda();
-       if (addr)
-               reserve_bootmem(addr, PAGE_SIZE, BOOTMEM_DEFAULT);
-}
-
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-void __init setup_bootmem_allocator(void);
+static void __init setup_bootmem_allocator(void);
 static unsigned long __init setup_memory(void)
 {
        /*
@@ -413,11 +377,13 @@ static unsigned long __init setup_memory(void)
        if (max_pfn > max_low_pfn) {
                highstart_pfn = max_low_pfn;
        }
+       memory_present(0, 0, highend_pfn);
        printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
                pages_to_mb(highend_pfn - highstart_pfn));
        num_physpages = highend_pfn;
        high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
 #else
+       memory_present(0, 0, max_low_pfn);
        num_physpages = max_low_pfn;
        high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
@@ -432,7 +398,7 @@ static unsigned long __init setup_memory(void)
        return max_low_pfn;
 }
 
-void __init zone_sizes_init(void)
+static void __init zone_sizes_init(void)
 {
        unsigned long max_zone_pfns[MAX_NR_ZONES];
        memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
@@ -503,44 +469,57 @@ static bool do_relocate_initrd = false;
 
 static void __init reserve_initrd(void)
 {
-       unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
-       unsigned long ramdisk_size  = boot_params.hdr.ramdisk_size;
-       unsigned long ramdisk_end   = ramdisk_image + ramdisk_size;
-       unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT;
-       unsigned long ramdisk_here;
-
-       initrd_start = 0;
+       u64 ramdisk_image = boot_params.hdr.ramdisk_image;
+       u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
+       u64 ramdisk_end   = ramdisk_image + ramdisk_size;
+       u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
+       u64 ramdisk_here;
 
        if (!boot_params.hdr.type_of_loader ||
            !ramdisk_image || !ramdisk_size)
                return;         /* No initrd provided by bootloader */
 
-       if (ramdisk_end < ramdisk_image) {
-               printk(KERN_ERR "initrd wraps around end of memory, "
-                      "disabling initrd\n");
-               return;
-       }
+       initrd_start = 0;
+
        if (ramdisk_size >= end_of_lowmem/2) {
+               free_early(ramdisk_image, ramdisk_end);
                printk(KERN_ERR "initrd too large to handle, "
                       "disabling initrd\n");
                return;
        }
+
+       printk(KERN_INFO "old RAMDISK: %08llx - %08llx\n", ramdisk_image,
+                       ramdisk_end);
+
+
        if (ramdisk_end <= end_of_lowmem) {
                /* All in lowmem, easy case */
-               reserve_bootmem(ramdisk_image, ramdisk_size, BOOTMEM_DEFAULT);
+               /*
+                * don't need to reserve again, already reserved early
+                * in i386_start_kernel
+                */
                initrd_start = ramdisk_image + PAGE_OFFSET;
                initrd_end = initrd_start+ramdisk_size;
                return;
        }
 
        /* We need to move the initrd down into lowmem */
-       ramdisk_here = (end_of_lowmem - ramdisk_size) & PAGE_MASK;
+       ramdisk_here = find_e820_area(min_low_pfn<<PAGE_SHIFT,
+                                end_of_lowmem, ramdisk_size,
+                                PAGE_SIZE);
+
+       if (ramdisk_here == -1ULL)
+               panic("Cannot find place for new RAMDISK of size %lld\n",
+                        ramdisk_size);
 
        /* Note: this includes all the lowmem currently occupied by
           the initrd, we rely on that fact to keep the data intact. */
-       reserve_bootmem(ramdisk_here, ramdisk_size, BOOTMEM_DEFAULT);
+       reserve_early(ramdisk_here, ramdisk_here + ramdisk_size,
+                        "NEW RAMDISK");
        initrd_start = ramdisk_here + PAGE_OFFSET;
        initrd_end   = initrd_start + ramdisk_size;
+       printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n",
+                        ramdisk_here, ramdisk_here + ramdisk_size);
 
        do_relocate_initrd = true;
 }
@@ -549,10 +528,10 @@ static void __init reserve_initrd(void)
 
 static void __init relocate_initrd(void)
 {
-       unsigned long ramdisk_image = boot_params.hdr.ramdisk_image;
-       unsigned long ramdisk_size  = boot_params.hdr.ramdisk_size;
-       unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT;
-       unsigned long ramdisk_here;
+       u64 ramdisk_image = boot_params.hdr.ramdisk_image;
+       u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
+       u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
+       u64 ramdisk_here;
        unsigned long slop, clen, mapaddr;
        char *p, *q;
 
@@ -569,6 +548,10 @@ static void __init relocate_initrd(void)
                p = (char *)__va(ramdisk_image);
                memcpy(q, p, clen);
                q += clen;
+               /* need to free these low pages...*/
+               printk(KERN_INFO "Freeing old partial RAMDISK %08llx-%08llx\n",
+                        ramdisk_image, ramdisk_image + clen - 1);
+               free_bootmem(ramdisk_image, clen);
                ramdisk_image += clen;
                ramdisk_size  -= clen;
        }
@@ -587,54 +570,42 @@ static void __init relocate_initrd(void)
                ramdisk_image += clen;
                ramdisk_size  -= clen;
        }
+       /* high pages is not converted by early_res_to_bootmem */
+       ramdisk_image = boot_params.hdr.ramdisk_image;
+       ramdisk_size  = boot_params.hdr.ramdisk_size;
+       printk(KERN_INFO "Copied RAMDISK from %016llx - %016llx to %08llx - %08llx\n",
+               ramdisk_image, ramdisk_image + ramdisk_size - 1,
+               ramdisk_here, ramdisk_here + ramdisk_size - 1);
 }
 
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 void __init setup_bootmem_allocator(void)
 {
-       unsigned long bootmap_size;
+       unsigned long bootmap_size, bootmap;
        /*
         * Initialize the boot-time allocator (with low memory only):
         */
-       bootmap_size = init_bootmem(min_low_pfn, max_low_pfn);
-
+       bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
+       bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
+                                max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
+                                PAGE_SIZE);
+       if (bootmap == -1L)
+               panic("Cannot find bootmem map of size %ld\n", bootmap_size);
+       reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
+#ifdef CONFIG_BLK_DEV_INITRD
+       reserve_initrd();
+#endif
+       bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
+       printk(KERN_INFO "  mapped low ram: 0 - %08lx\n",
+                max_pfn_mapped<<PAGE_SHIFT);
+       printk(KERN_INFO "  low ram: %08lx - %08lx\n",
+                min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
+       printk(KERN_INFO "  bootmap %08lx - %08lx\n",
+                bootmap, bootmap + bootmap_size);
        register_bootmem_low_pages(max_low_pfn);
+       early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
 
-       /*
-        * Reserve the bootmem bitmap itself as well. We do this in two
-        * steps (first step was init_bootmem()) because this catches
-        * the (very unlikely) case of us accidentally initializing the
-        * bootmem allocator with an invalid RAM area.
-        */
-       reserve_bootmem(__pa_symbol(_text), (PFN_PHYS(min_low_pfn) +
-                        bootmap_size + PAGE_SIZE-1) - __pa_symbol(_text),
-                        BOOTMEM_DEFAULT);
-
-       /*
-        * reserve physical page 0 - it's a special BIOS page on many boxes,
-        * enabling clean reboots, SMP operation, laptop functions.
-        */
-       reserve_bootmem(0, PAGE_SIZE, BOOTMEM_DEFAULT);
-
-       /* reserve EBDA region, it's a 4K region */
-       reserve_ebda_region();
-
-    /* could be an AMD 768MPX chipset. Reserve a page  before VGA to prevent
-       PCI prefetch into it (errata #56). Usually the page is reserved anyways,
-       unless you have no PS/2 mouse plugged in. */
-       if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
-           boot_cpu_data.x86 == 6)
-            reserve_bootmem(0xa0000 - 4096, 4096, BOOTMEM_DEFAULT);
-
-#ifdef CONFIG_SMP
-       /*
-        * But first pinch a few for the stack/trampoline stuff
-        * FIXME: Don't need the extra page at 4K, but need to fix
-        * trampoline before removing it. (see the GDT stuff)
-        */
-       reserve_bootmem(PAGE_SIZE, PAGE_SIZE, BOOTMEM_DEFAULT);
-#endif
 #ifdef CONFIG_ACPI_SLEEP
        /*
         * Reserve low memory region for sleep support.
@@ -647,11 +618,9 @@ void __init setup_bootmem_allocator(void)
         */
        find_smp_config();
 #endif
-#ifdef CONFIG_BLK_DEV_INITRD
-       reserve_initrd();
-#endif
-       numa_kva_reserve();
        reserve_crashkernel();
+
+       reserve_ibft_region();
 }
 
 /*
@@ -681,11 +650,17 @@ static void set_mca_bus(int x)
 static void set_mca_bus(int x) { }
 #endif
 
-/* Overridden in paravirt.c if CONFIG_PARAVIRT */
-char * __init __attribute__((weak)) memory_setup(void)
-{
-       return machine_specific_memory_setup();
-}
+#ifdef CONFIG_NUMA
+/*
+ * In the golden day, when everything among i386 and x86_64 will be
+ * integrated, this will not live here
+ */
+void *x86_cpu_to_node_map_early_ptr;
+int x86_cpu_to_node_map_init[NR_CPUS] = {
+       [0 ... NR_CPUS-1] = NUMA_NO_NODE
+};
+DEFINE_PER_CPU(int, x86_cpu_to_node_map) = NUMA_NO_NODE;
+#endif
 
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
@@ -714,7 +689,7 @@ void __init setup_arch(char **cmdline_p)
        edid_info = boot_params.edid_info;
        apm_info.bios = boot_params.apm_bios_info;
        ist_info = boot_params.ist_info;
-       saved_videomode = boot_params.hdr.vid_mode;
+       saved_video_mode = boot_params.hdr.vid_mode;
        if( boot_params.sys_desc_table.length != 0 ) {
                set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
                machine_id = boot_params.sys_desc_table.table[0];
@@ -730,8 +705,7 @@ void __init setup_arch(char **cmdline_p)
 #endif
        ARCH_SETUP
 
-       printk(KERN_INFO "BIOS-provided physical RAM map:\n");
-       print_memory_map(memory_setup());
+       setup_memory_map();
 
        copy_edd();
 
@@ -751,10 +725,7 @@ void __init setup_arch(char **cmdline_p)
 
        parse_early_param();
 
-       if (user_defined_memmap) {
-               printk(KERN_INFO "user-defined physical RAM map:\n");
-               print_memory_map("user");
-       }
+       finish_e820_parsing();
 
        strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;
@@ -770,6 +741,10 @@ void __init setup_arch(char **cmdline_p)
 
        max_low_pfn = setup_memory();
 
+#ifdef CONFIG_KVM_CLOCK
+       kvmclock_init();
+#endif
+
 #ifdef CONFIG_VMI
        /*
         * Must be after max_low_pfn is determined, and before kernel
@@ -777,6 +752,7 @@ void __init setup_arch(char **cmdline_p)
         */
        vmi_init();
 #endif
+       kvm_guest_init();
 
        /*
         * NOTE: before this point _nobody_ is allowed to allocate
@@ -788,9 +764,6 @@ void __init setup_arch(char **cmdline_p)
         * not to exceed the 8Mb limit.
         */
 
-#ifdef CONFIG_SMP
-       smp_alloc_memory(); /* AP processor realmode stacks in low memory*/
-#endif
        paging_init();
 
        /*
@@ -820,6 +793,18 @@ void __init setup_arch(char **cmdline_p)
 
        io_delay_init();
 
+#ifdef CONFIG_X86_SMP
+       /*
+        * setup to use the early static init tables during kernel startup
+        * X86_SMP will exclude sub-arches that don't deal well with it.
+        */
+       x86_cpu_to_apicid_early_ptr = (void *)x86_cpu_to_apicid_init;
+       x86_bios_cpu_apicid_early_ptr = (void *)x86_bios_cpu_apicid_init;
+#ifdef CONFIG_NUMA
+       x86_cpu_to_node_map_early_ptr = (void *)x86_cpu_to_node_map_init;
+#endif
+#endif
+
 #ifdef CONFIG_X86_GENERICARCH
        generic_apic_probe();
 #endif
@@ -843,13 +828,13 @@ void __init setup_arch(char **cmdline_p)
                        "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n");
 #endif
 #endif
-#ifdef CONFIG_X86_LOCAL_APIC
+#if defined(CONFIG_X86_MPPARSE) || defined(CONFIG_X86_VISWS)
        if (smp_found_config)
                get_smp_config();
 #endif
 
-       e820_register_memory();
-       e820_mark_nosave_regions();
+       e820_setup_gap();
+       e820_mark_nosave_regions(max_low_pfn);
 
 #ifdef CONFIG_VT
 #if defined(CONFIG_VGA_CONSOLE)