]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - arch/x86/kernel/setup.c
x86: Use find_e820() instead of hard coded trampoline address
[net-next-2.6.git] / arch / x86 / kernel / setup.c
index 2a34f9c5be214fd428c4197a1f09819d65759a37..f7b8b9894b226fd8498ab5f886381f68be2541c2 100644 (file)
@@ -73,6 +73,7 @@
 
 #include <asm/mtrr.h>
 #include <asm/apic.h>
+#include <asm/trampoline.h>
 #include <asm/e820.h>
 #include <asm/mpspec.h>
 #include <asm/setup.h>
 #include <asm/percpu.h>
 #include <asm/topology.h>
 #include <asm/apicdef.h>
+#include <asm/k8.h>
 #ifdef CONFIG_X86_64
 #include <asm/numa_64.h>
 #endif
+#include <asm/mce.h>
 
 /*
  * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries.
@@ -247,7 +250,7 @@ EXPORT_SYMBOL(edd);
  *              from boot_params into a safe place.
  *
  */
-static inline void copy_edd(void)
+static inline void __init copy_edd(void)
 {
      memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer,
            sizeof(edd.mbr_signature));
@@ -256,7 +259,7 @@ static inline void copy_edd(void)
      edd.edd_info_nr = boot_params.eddbuf_entries;
 }
 #else
-static inline void copy_edd(void)
+static inline void __init copy_edd(void)
 {
 }
 #endif
@@ -486,42 +489,11 @@ static void __init reserve_early_setup_data(void)
 
 #ifdef CONFIG_KEXEC
 
-/**
- * Reserve @size bytes of crashkernel memory at any suitable offset.
- *
- * @size: Size of the crashkernel memory to reserve.
- * Returns the base address on success, and -1ULL on failure.
- */
-static
-unsigned long long __init find_and_reserve_crashkernel(unsigned long long size)
-{
-       const unsigned long long alignment = 16<<20;    /* 16M */
-       unsigned long long start = 0LL;
-
-       while (1) {
-               int ret;
-
-               start = find_e820_area(start, ULONG_MAX, size, alignment);
-               if (start == -1ULL)
-                       return start;
-
-               /* try to reserve it */
-               ret = reserve_bootmem_generic(start, size, BOOTMEM_EXCLUSIVE);
-               if (ret >= 0)
-                       return start;
-
-               start += alignment;
-       }
-}
-
 static inline unsigned long long get_total_mem(void)
 {
        unsigned long long total;
 
-       total = max_low_pfn - min_low_pfn;
-#ifdef CONFIG_HIGHMEM
-       total += highend_pfn - highstart_pfn;
-#endif
+       total = max_pfn - min_low_pfn;
 
        return total << PAGE_SHIFT;
 }
@@ -541,21 +513,25 @@ static void __init reserve_crashkernel(void)
 
        /* 0 means: find the address automatically */
        if (crash_base <= 0) {
-               crash_base = find_and_reserve_crashkernel(crash_size);
+               const unsigned long long alignment = 16<<20;    /* 16M */
+
+               crash_base = find_e820_area(alignment, ULONG_MAX, crash_size,
+                                alignment);
                if (crash_base == -1ULL) {
-                       pr_info("crashkernel reservation failed. "
-                               "No suitable area found.\n");
+                       pr_info("crashkernel reservation failed - No suitable area found.\n");
                        return;
                }
        } else {
-               ret = reserve_bootmem_generic(crash_base, crash_size,
-                                       BOOTMEM_EXCLUSIVE);
-               if (ret < 0) {
-                       pr_info("crashkernel reservation failed - "
-                               "memory is in use\n");
+               unsigned long long start;
+
+               start = find_e820_area(crash_base, ULONG_MAX, crash_size,
+                                1<<20);
+               if (start != crash_base) {
+                       pr_info("crashkernel reservation failed - memory is in use.\n");
                        return;
                }
        }
+       reserve_early(crash_base, crash_base + crash_size, "CRASH KERNEL");
 
        printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
                        "for crashkernel (System RAM: %ldMB)\n",
@@ -698,6 +674,9 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = {
 
 void __init setup_arch(char **cmdline_p)
 {
+       int acpi = 0;
+       int k8 = 0;
+
 #ifdef CONFIG_X86_32
        memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data));
        visws_early_detect();
@@ -790,21 +769,18 @@ void __init setup_arch(char **cmdline_p)
        strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE);
        *cmdline_p = command_line;
 
-#ifdef CONFIG_X86_64
        /*
-        * Must call this twice: Once just to detect whether hardware doesn't
-        * support NX (so that the early EHCI debug console setup can safely
-        * call set_fixmap(), and then again after parsing early parameters to
-        * honor the respective command line option.
+        * x86_configure_nx() is called before parse_early_param() to detect
+        * whether hardware doesn't support NX (so that the early EHCI debug
+        * console setup can safely call set_fixmap()). It may then be called
+        * again from within noexec_setup() during parsing early parameters
+        * to honor the respective command line option.
         */
-       check_efer();
-#endif
+       x86_configure_nx();
 
        parse_early_param();
 
-#ifdef CONFIG_X86_64
-       check_efer();
-#endif
+       x86_report_nx();
 
        /* Must be before kernel pagetables are setup */
        vmi_activate();
@@ -900,6 +876,20 @@ void __init setup_arch(char **cmdline_p)
 
        reserve_brk();
 
+       /*
+        * Find and reserve possible boot-time SMP configuration:
+        */
+       find_smp_config();
+
+       reserve_trampoline_memory();
+
+#ifdef CONFIG_ACPI_SLEEP
+       /*
+        * Reserve low memory region for sleep support.
+        * even before init_memory_mapping
+        */
+       acpi_reserve_wakeup_memory();
+#endif
        init_gbpages();
 
        /* max_pfn_mapped is updated here */
@@ -926,6 +916,8 @@ void __init setup_arch(char **cmdline_p)
 
        reserve_initrd();
 
+       reserve_crashkernel();
+
        vsmp_init();
 
        io_delay_init();
@@ -941,23 +933,15 @@ void __init setup_arch(char **cmdline_p)
        /*
         * Parse SRAT to discover nodes.
         */
-       acpi_numa_init();
+       acpi = acpi_numa_init();
 #endif
 
-       initmem_init(0, max_pfn);
-
-#ifdef CONFIG_ACPI_SLEEP
-       /*
-        * Reserve low memory region for sleep support.
-        */
-       acpi_reserve_bootmem();
+#ifdef CONFIG_K8_NUMA
+       if (!acpi)
+               k8 = !k8_numa_init(0, max_pfn);
 #endif
-       /*
-        * Find and reserve possible boot-time SMP configuration:
-        */
-       find_smp_config();
 
-       reserve_crashkernel();
+       initmem_init(0, max_pfn, acpi, k8);
 
 #ifdef CONFIG_X86_64
        /*
@@ -1031,6 +1015,8 @@ void __init setup_arch(char **cmdline_p)
 #endif
 #endif
        x86_init.oem.banner();
+
+       mcheck_init();
 }
 
 #ifdef CONFIG_X86_32