x86: limit scan to 1k of EBDA.
[sfrench/cifs-2.6.git] / arch / x86 / kernel / mpparse_64.c
index 8bf0ca03ac8e8a78f13ca5ea86842e02cfca9be0..19c8264855166b4b921f16da74e37803d356681e 100644 (file)
 #include <asm/io_apic.h>
 #include <asm/proto.h>
 #include <asm/acpi.h>
+#include <asm/bios_ebda.h>
+
+#include <mach_apic.h>
 
 /* Have we found an MP table */
 int smp_found_config;
+unsigned int __cpuinitdata maxcpus = NR_CPUS;
 
 /*
  * Various Linux-internal data structures created from the
  * MP-table.
  */
 DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
-int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
+int mp_bus_id_to_pci_bus[MAX_MP_BUSSES] = {[0 ... MAX_MP_BUSSES - 1] = -1 };
 
 static int mp_current_pci_id = 0;
 /* I/O APIC entries */
@@ -53,20 +57,23 @@ int mp_irq_entries;
 int nr_ioapics;
 unsigned long mp_lapic_addr = 0;
 
-
-
 /* Processor that is doing the boot up */
-unsigned int boot_cpu_id = -1U;
+unsigned int boot_cpu_physical_apicid = -1U;
+EXPORT_SYMBOL(boot_cpu_physical_apicid);
+
 /* Internal processor count */
-unsigned int num_processors __cpuinitdata = 0;
+unsigned int num_processors;
 
 unsigned disabled_cpus __cpuinitdata;
 
 /* Bitmask of physically existing CPUs */
 physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
 
-u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
-
+u16 x86_bios_cpu_apicid_init[NR_CPUS] __initdata
+    = {[0 ... NR_CPUS - 1] = BAD_APICID };
+void *x86_bios_cpu_apicid_early_ptr;
+DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
+EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
 
 /*
  * Intel MP BIOS table parsing routines:
@@ -86,7 +93,7 @@ static int __init mpf_checksum(unsigned char *mp, int len)
        return sum & 0xFF;
 }
 
-static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
+static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
 {
        int cpu;
        cpumask_t tmp_map;
@@ -98,14 +105,20 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
        }
        if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
                bootup_cpu = " (Bootup-CPU)";
-               boot_cpu_id = m->mpc_apicid;
+               boot_cpu_physical_apicid = m->mpc_apicid;
        }
 
        printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
 
        if (num_processors >= NR_CPUS) {
                printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
-                       " Processor ignored.\n", NR_CPUS);
+                      " Processor ignored.\n", NR_CPUS);
+               return;
+       }
+
+       if (num_processors >= maxcpus) {
+               printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
+                      " Processor ignored.\n", maxcpus);
                return;
        }
 
@@ -114,22 +127,31 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
        cpu = first_cpu(tmp_map);
 
        physid_set(m->mpc_apicid, phys_cpu_present_map);
-       if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
-               /*
-                * bios_cpu_apicid is required to have processors listed
-                * in same order as logical cpu numbers. Hence the first
-                * entry is BSP, and so on.
-                */
+       if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
+               /*
+                * x86_bios_cpu_apicid is required to have processors listed
+                * in same order as logical cpu numbers. Hence the first
+                * entry is BSP, and so on.
+                */
                cpu = 0;
-       }
-       bios_cpu_apicid[cpu] = m->mpc_apicid;
-       x86_cpu_to_apicid[cpu] = m->mpc_apicid;
+       }
+       /* are we being called early in kernel startup? */
+       if (x86_cpu_to_apicid_early_ptr) {
+               u16 *cpu_to_apicid = x86_cpu_to_apicid_early_ptr;
+               u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;
+
+               cpu_to_apicid[cpu] = m->mpc_apicid;
+               bios_cpu_apicid[cpu] = m->mpc_apicid;
+       } else {
+               per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
+               per_cpu(x86_bios_cpu_apicid, cpu) = m->mpc_apicid;
+       }
 
        cpu_set(cpu, cpu_possible_map);
        cpu_set(cpu, cpu_present_map);
 }
 
-static void __init MP_bus_info (struct mpc_config_bus *m)
+static void __init MP_bus_info(struct mpc_config_bus *m)
 {
        char str[7];
 
@@ -152,24 +174,24 @@ static int bad_ioapic(unsigned long address)
 {
        if (nr_ioapics >= MAX_IO_APICS) {
                printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
-                       "(found %d)\n", MAX_IO_APICS, nr_ioapics);
+                      "(found %d)\n", MAX_IO_APICS, nr_ioapics);
                panic("Recompile kernel with bigger MAX_IO_APICS!\n");
        }
        if (!address) {
                printk(KERN_ERR "WARNING: Bogus (zero) I/O APIC address"
-                       " found in table, skipping!\n");
+                      " found in table, skipping!\n");
                return 1;
        }
        return 0;
 }
 
-static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
+static void __init MP_ioapic_info(struct mpc_config_ioapic *m)
 {
        if (!(m->mpc_flags & MPC_APIC_USABLE))
                return;
 
-       printk("I/O APIC #%d at 0x%X.\n",
-               m->mpc_apicid, m->mpc_apicaddr);
+       printk(KERN_INFO "I/O APIC #%d at 0x%X.\n", m->mpc_apicid,
+              m->mpc_apicaddr);
 
        if (bad_ioapic(m->mpc_apicaddr))
                return;
@@ -178,119 +200,120 @@ static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
        nr_ioapics++;
 }
 
-static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
+static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
 {
-       mp_irqs [mp_irq_entries] = *m;
+       mp_irqs[mp_irq_entries] = *m;
        Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
                " IRQ %02x, APIC ID %x, APIC INT %02x\n",
-                       m->mpc_irqtype, m->mpc_irqflag & 3,
-                       (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
-                       m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
+               m->mpc_irqtype, m->mpc_irqflag & 3,
+               (m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
+               m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
        if (++mp_irq_entries >= MAX_IRQ_SOURCES)
                panic("Max # of irq sources exceeded!!\n");
 }
 
-static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
+static void __init MP_lintsrc_info(struct mpc_config_lintsrc *m)
 {
        Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
                " IRQ %02x, APIC ID %x, APIC LINT %02x\n",
-                       m->mpc_irqtype, m->mpc_irqflag & 3,
-                       (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
-                       m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
+               m->mpc_irqtype, m->mpc_irqflag & 3,
+               (m->mpc_irqflag >> 2) & 3, m->mpc_srcbusid,
+               m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
 }
 
 /*
  * Read/parse the MPC
  */
-
-static int __init smp_read_mpc(struct mp_config_table *mpc)
+static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
 {
        char str[16];
-       int count=sizeof(*mpc);
-       unsigned char *mpt=((unsigned char *)mpc)+count;
-
-       if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
-               printk("MPTABLE: bad signature [%c%c%c%c]!\n",
-                       mpc->mpc_signature[0],
-                       mpc->mpc_signature[1],
-                       mpc->mpc_signature[2],
-                       mpc->mpc_signature[3]);
+       int count = sizeof(*mpc);
+       unsigned char *mpt = ((unsigned char *)mpc) + count;
+
+       if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) {
+               printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n",
+                      mpc->mpc_signature[0],
+                      mpc->mpc_signature[1],
+                      mpc->mpc_signature[2], mpc->mpc_signature[3]);
                return 0;
        }
-       if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
-               printk("MPTABLE: checksum error!\n");
+       if (mpf_checksum((unsigned char *)mpc, mpc->mpc_length)) {
+               printk(KERN_ERR "MPTABLE: checksum error!\n");
                return 0;
        }
-       if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
+       if (mpc->mpc_spec != 0x01 && mpc->mpc_spec != 0x04) {
                printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
-                       mpc->mpc_spec);
+                      mpc->mpc_spec);
                return 0;
        }
        if (!mpc->mpc_lapic) {
                printk(KERN_ERR "MPTABLE: null local APIC address!\n");
                return 0;
        }
-       memcpy(str,mpc->mpc_oem,8);
+       memcpy(str, mpc->mpc_oem, 8);
        str[8] = 0;
-       printk(KERN_INFO "MPTABLE: OEM ID: %s ",str);
+       printk(KERN_INFO "MPTABLE: OEM ID: %s ", str);
 
-       memcpy(str,mpc->mpc_productid,12);
+       memcpy(str, mpc->mpc_productid, 12);
        str[12] = 0;
-       printk("MPTABLE: Product ID: %s ",str);
+       printk(KERN_INFO "MPTABLE: Product ID: %s ", str);
 
-       printk("MPTABLE: APIC at: 0x%X\n",mpc->mpc_lapic);
+       printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic);
 
        /* save the local APIC address, it might be non-default */
        if (!acpi_lapic)
                mp_lapic_addr = mpc->mpc_lapic;
 
+       if (early)
+               return 1;
+
        /*
-        *      Now process the configuration blocks.
+        *      Now process the configuration blocks.
         */
        while (count < mpc->mpc_length) {
-               switch(*mpt) {
-                       case MP_PROCESSOR:
+               switch (*mpt) {
+               case MP_PROCESSOR:
                        {
-                               struct mpc_config_processor *m=
-                                       (struct mpc_config_processor *)mpt;
+                               struct mpc_config_processor *m =
+                                   (struct mpc_config_processor *)mpt;
                                if (!acpi_lapic)
                                        MP_processor_info(m);
                                mpt += sizeof(*m);
                                count += sizeof(*m);
                                break;
                        }
-                       case MP_BUS:
+               case MP_BUS:
                        {
-                               struct mpc_config_bus *m=
-                                       (struct mpc_config_bus *)mpt;
+                               struct mpc_config_bus *m =
+                                   (struct mpc_config_bus *)mpt;
                                MP_bus_info(m);
                                mpt += sizeof(*m);
                                count += sizeof(*m);
                                break;
                        }
-                       case MP_IOAPIC:
+               case MP_IOAPIC:
                        {
-                               struct mpc_config_ioapic *m=
-                                       (struct mpc_config_ioapic *)mpt;
+                               struct mpc_config_ioapic *m =
+                                   (struct mpc_config_ioapic *)mpt;
                                MP_ioapic_info(m);
                                mpt += sizeof(*m);
                                count += sizeof(*m);
                                break;
                        }
-                       case MP_INTSRC:
+               case MP_INTSRC:
                        {
-                               struct mpc_config_intsrc *m=
-                                       (struct mpc_config_intsrc *)mpt;
+                               struct mpc_config_intsrc *m =
+                                   (struct mpc_config_intsrc *)mpt;
 
                                MP_intsrc_info(m);
                                mpt += sizeof(*m);
                                count += sizeof(*m);
                                break;
                        }
-                       case MP_LINTSRC:
+               case MP_LINTSRC:
                        {
-                               struct mpc_config_lintsrc *m=
-                                       (struct mpc_config_lintsrc *)mpt;
+                               struct mpc_config_lintsrc *m =
+                                   (struct mpc_config_lintsrc *)mpt;
                                MP_lintsrc_info(m);
                                mpt += sizeof(*m);
                                count += sizeof(*m);
@@ -319,7 +342,7 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
        int ELCR_fallback = 0;
 
        intsrc.mpc_type = MP_INTSRC;
-       intsrc.mpc_irqflag = 0;                 /* conforming */
+       intsrc.mpc_irqflag = 0; /* conforming */
        intsrc.mpc_srcbus = 0;
        intsrc.mpc_dstapic = mp_ioapics[0].mpc_apicid;
 
@@ -334,12 +357,16 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
         *  If it does, we assume it's valid.
         */
        if (mpc_default_type == 5) {
-               printk(KERN_INFO "ISA/PCI bus type with no IRQ information... falling back to ELCR\n");
+               printk(KERN_INFO "ISA/PCI bus type with no IRQ information... "
+                      "falling back to ELCR\n");
 
-               if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) || ELCR_trigger(13))
-                       printk(KERN_ERR "ELCR contains invalid data... not using ELCR\n");
+               if (ELCR_trigger(0) || ELCR_trigger(1) || ELCR_trigger(2) ||
+                   ELCR_trigger(13))
+                       printk(KERN_ERR "ELCR contains invalid data... "
+                              "not using ELCR\n");
                else {
-                       printk(KERN_INFO "Using ELCR to identify PCI interrupts\n");
+                       printk(KERN_INFO
+                              "Using ELCR to identify PCI interrupts\n");
                        ELCR_fallback = 1;
                }
        }
@@ -368,13 +395,13 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
                }
 
                intsrc.mpc_srcbusirq = i;
-               intsrc.mpc_dstirq = i ? i : 2;          /* IRQ0 to INTIN2 */
+               intsrc.mpc_dstirq = i ? i : 2;  /* IRQ0 to INTIN2 */
                MP_intsrc_info(&intsrc);
        }
 
        intsrc.mpc_irqtype = mp_ExtINT;
        intsrc.mpc_srcbusirq = 0;
-       intsrc.mpc_dstirq = 0;                          /* 8259A to INTIN0 */
+       intsrc.mpc_dstirq = 0;  /* 8259A to INTIN0 */
        MP_intsrc_info(&intsrc);
 }
 
@@ -410,14 +437,14 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
        bus.mpc_type = MP_BUS;
        bus.mpc_busid = 0;
        switch (mpc_default_type) {
-               default:
-                       printk(KERN_ERR "???\nUnknown standard configuration %d\n",
-                               mpc_default_type);
-                       /* fall through */
-               case 1:
-               case 5:
-                       memcpy(bus.mpc_bustype, "ISA   ", 6);
-                       break;
+       default:
+               printk(KERN_ERR "???\nUnknown standard configuration %d\n",
+                      mpc_default_type);
+               /* fall through */
+       case 1:
+       case 5:
+               memcpy(bus.mpc_bustype, "ISA   ", 6);
+               break;
        }
        MP_bus_info(&bus);
        if (mpc_default_type > 4) {
@@ -439,7 +466,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
        construct_default_ioirq_mptable(mpc_default_type);
 
        lintsrc.mpc_type = MP_LINTSRC;
-       lintsrc.mpc_irqflag = 0;                /* conforming */
+       lintsrc.mpc_irqflag = 0;        /* conforming */
        lintsrc.mpc_srcbusid = 0;
        lintsrc.mpc_srcbusirq = 0;
        lintsrc.mpc_destapic = MP_APIC_ALL;
@@ -455,29 +482,41 @@ static struct intel_mp_floating *mpf_found;
 /*
  * Scan the memory blocks for an SMP configuration block.
  */
-void __init get_smp_config (void)
+static void __init __get_smp_config(unsigned early)
 {
        struct intel_mp_floating *mpf = mpf_found;
 
+       if (acpi_lapic && early)
+               return;
        /*
-        * ACPI supports both logical (e.g. Hyper-Threading) and physical 
-        * processors, where MPS only supports physical.
-        */
-       if (acpi_lapic && acpi_ioapic) {
-               printk(KERN_INFO "Using ACPI (MADT) for SMP configuration information\n");
-               return;
-       }
-       else if (acpi_lapic)
-               printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
+        * ACPI supports both logical (e.g. Hyper-Threading) and physical
+        * processors, where MPS only supports physical.
+        */
+       if (acpi_lapic && acpi_ioapic) {
+               printk(KERN_INFO "Using ACPI (MADT) for SMP configuration "
+                      "information\n");
+               return;
+       } else if (acpi_lapic)
+               printk(KERN_INFO "Using ACPI for processor (LAPIC) "
+                      "configuration information\n");
 
-       printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
+       printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n",
+              mpf->mpf_specification);
 
        /*
         * Now see if we need to read further.
         */
        if (mpf->mpf_feature1 != 0) {
+               if (early) {
+                       /*
+                        * local APIC has default address
+                        */
+                       mp_lapic_addr = APIC_DEFAULT_PHYS_BASE;
+                       return;
+               }
 
-               printk(KERN_INFO "Default MP configuration #%d\n", mpf->mpf_feature1);
+               printk(KERN_INFO "Default MP configuration #%d\n",
+                      mpf->mpf_feature1);
                construct_default_ISA_mptable(mpf->mpf_feature1);
 
        } else if (mpf->mpf_physptr) {
@@ -486,12 +525,17 @@ void __init get_smp_config (void)
                 * Read the physical hardware table.  Anything here will
                 * override the defaults.
                 */
-               if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
+               if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr), early)) {
                        smp_found_config = 0;
-                       printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
-                       printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
+                       printk(KERN_ERR
+                              "BIOS bug, MP table errors detected!...\n");
+                       printk(KERN_ERR "... disabling SMP support. "
+                              "(tell your hw vendor)\n");
                        return;
                }
+
+               if (early)
+                       return;
                /*
                 * If there are no explicit MP IRQ entries, then we are
                 * broken.  We set up most of the low 16 IO-APIC pins to
@@ -500,7 +544,9 @@ void __init get_smp_config (void)
                if (!mp_irq_entries) {
                        struct mpc_config_bus bus;
 
-                       printk(KERN_ERR "BIOS bug, no explicit IRQ entries, using default mptable. (tell your hw vendor)\n");
+                       printk(KERN_ERR "BIOS bug, no explicit IRQ entries, "
+                              "using default mptable. "
+                              "(tell your hw vendor)\n");
 
                        bus.mpc_type = MP_BUS;
                        bus.mpc_busid = 0;
@@ -513,35 +559,52 @@ void __init get_smp_config (void)
        } else
                BUG();
 
-       printk(KERN_INFO "Processors: %d\n", num_processors);
+       if (!early)
+               printk(KERN_INFO "Processors: %d\n", num_processors);
        /*
         * Only use the first configuration found.
         */
 }
 
-static int __init smp_scan_config (unsigned long base, unsigned long length)
+void __init early_get_smp_config(void)
+{
+       __get_smp_config(1);
+}
+
+void __init get_smp_config(void)
 {
-       extern void __bad_mpf_size(void); 
+       __get_smp_config(0);
+}
+
+static int __init smp_scan_config(unsigned long base, unsigned long length,
+                                 unsigned reserve)
+{
+       extern void __bad_mpf_size(void);
        unsigned int *bp = phys_to_virt(base);
        struct intel_mp_floating *mpf;
 
-       Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
+       Dprintk("Scan SMP from %p for %ld bytes.\n", bp, length);
        if (sizeof(*mpf) != 16)
                __bad_mpf_size();
 
        while (length > 0) {
                mpf = (struct intel_mp_floating *)bp;
                if ((*bp == SMP_MAGIC_IDENT) &&
-                       (mpf->mpf_length == 1) &&
-                       !mpf_checksum((unsigned char *)bp, 16) &&
-                       ((mpf->mpf_specification == 1)
-                               || (mpf->mpf_specification == 4)) ) {
+                   (mpf->mpf_length == 1) &&
+                   !mpf_checksum((unsigned char *)bp, 16) &&
+                   ((mpf->mpf_specification == 1)
+                    || (mpf->mpf_specification == 4))) {
 
                        smp_found_config = 1;
+                       mpf_found = mpf;
+
+                       if (!reserve)
+                               return 1;
+
                        reserve_bootmem_generic(virt_to_phys(mpf), PAGE_SIZE);
                        if (mpf->mpf_physptr)
-                               reserve_bootmem_generic(mpf->mpf_physptr, PAGE_SIZE);
-                       mpf_found = mpf;
+                               reserve_bootmem_generic(mpf->mpf_physptr,
+                                                       PAGE_SIZE);
                        return 1;
                }
                bp += 4;
@@ -550,7 +613,7 @@ static int __init smp_scan_config (unsigned long base, unsigned long length)
        return 0;
 }
 
-void __init find_smp_config(void)
+static void __init __find_smp_config(unsigned reserve)
 {
        unsigned int address;
 
@@ -562,9 +625,9 @@ void __init find_smp_config(void)
         * 2) Scan the top 1K of base RAM
         * 3) Scan the 64K of bios
         */
-       if (smp_scan_config(0x0,0x400) ||
-               smp_scan_config(639*0x400,0x400) ||
-                       smp_scan_config(0xF0000,0x10000))
+       if (smp_scan_config(0x0, 0x400, reserve) ||
+           smp_scan_config(639 * 0x400, 0x400, reserve) ||
+           smp_scan_config(0xF0000, 0x10000, reserve))
                return;
        /*
         * If it is an SMP machine we should know now.
@@ -577,15 +640,23 @@ void __init find_smp_config(void)
         * trustworthy, simply because the SMP table may have been
         * stomped on during early boot. These loaders are buggy and
         * should be fixed.
+        *
+        * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
         */
 
-       address = *(unsigned short *)phys_to_virt(0x40E);
-       address <<= 4;
-       if (smp_scan_config(address, 0x1000))
-               return;
+       address = get_bios_ebda();
+       if (address)
+               smp_scan_config(address, 0x400, reserve);
+}
 
-       /* If we have come this far, we did not find an MP table  */
-        printk(KERN_INFO "No mptable found.\n");
+void __init early_find_smp_config(void)
+{
+       __find_smp_config(0);
+}
+
+void __init find_smp_config(void)
+{
+       __find_smp_config(1);
 }
 
 /* --------------------------------------------------------------------------
@@ -596,18 +667,18 @@ void __init find_smp_config(void)
 
 void __init mp_register_lapic_address(u64 address)
 {
-       mp_lapic_addr = (unsigned long) address;
+       mp_lapic_addr = (unsigned long)address;
        set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
-       if (boot_cpu_id == -1U)
-               boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
+       if (boot_cpu_physical_apicid == -1U)
+               boot_cpu_physical_apicid  = GET_APIC_ID(apic_read(APIC_ID));
 }
 
-void __cpuinit mp_register_lapic (u8 id, u8 enabled)
+void __cpuinit mp_register_lapic(u8 id, u8 enabled)
 {
        struct mpc_config_processor processor;
-       int                     boot_cpu = 0;
-       
-       if (id == boot_cpu_id)
+       int boot_cpu = 0;
+
+       if (id == boot_cpu_physical_apicid)
                boot_cpu = 1;
 
        processor.mpc_type = MP_PROCESSOR;
@@ -627,10 +698,10 @@ void __cpuinit mp_register_lapic (u8 id, u8 enabled)
 #define MP_MAX_IOAPIC_PIN      127
 
 static struct mp_ioapic_routing {
-       int                     apic_id;
-       int                     gsi_start;
-       int                     gsi_end;
-       u32                     pin_programmed[4];
+       int apic_id;
+       int gsi_start;
+       int gsi_end;
+       u32 pin_programmed[4];
 } mp_ioapic_routing[MAX_IO_APICS];
 
 static int mp_find_ioapic(int gsi)
@@ -640,7 +711,7 @@ static int mp_find_ioapic(int gsi)
        /* Find the IOAPIC that manages this GSI. */
        for (i = 0; i < nr_ioapics; i++) {
                if ((gsi >= mp_ioapic_routing[i].gsi_start)
-                       && (gsi <= mp_ioapic_routing[i].gsi_end))
+                   && (gsi <= mp_ioapic_routing[i].gsi_end))
                        return i;
        }
 
@@ -678,31 +749,30 @@ void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
        set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
        mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
        mp_ioapics[idx].mpc_apicver = 0;
-       
+
        /* 
         * Build basic IRQ lookup table to facilitate gsi->io_apic lookups
         * and to prevent reprogramming of IOAPIC pins (PCI IRQs).
         */
        mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
        mp_ioapic_routing[idx].gsi_start = gsi_base;
-       mp_ioapic_routing[idx].gsi_end = gsi_base + 
-               io_apic_get_redir_entries(idx);
+       mp_ioapic_routing[idx].gsi_end = gsi_base +
+           io_apic_get_redir_entries(idx);
 
        printk(KERN_INFO "IOAPIC[%d]: apic_id %d, address 0x%x, "
-               "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid, 
-               mp_ioapics[idx].mpc_apicaddr,
-               mp_ioapic_routing[idx].gsi_start,
-               mp_ioapic_routing[idx].gsi_end);
+              "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
+              mp_ioapics[idx].mpc_apicaddr,
+              mp_ioapic_routing[idx].gsi_start,
+              mp_ioapic_routing[idx].gsi_end);
 
        nr_ioapics++;
 }
 
-void __init
-mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32        gsi)
+void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
 {
        struct mpc_config_intsrc intsrc;
-       int                     ioapic = -1;
-       int                     pin = -1;
+       int ioapic = -1;
+       int pin = -1;
 
        /* 
         * Convert 'gsi' to 'ioapic.pin'.
@@ -724,13 +794,13 @@ mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32   gsi)
        intsrc.mpc_irqtype = mp_INT;
        intsrc.mpc_irqflag = (trigger << 2) | polarity;
        intsrc.mpc_srcbus = MP_ISA_BUS;
-       intsrc.mpc_srcbusirq = bus_irq;                                /* IRQ */
-       intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;        /* APIC ID */
-       intsrc.mpc_dstirq = pin;                                    /* INTIN# */
+       intsrc.mpc_srcbusirq = bus_irq; /* IRQ */
+       intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;     /* APIC ID */
+       intsrc.mpc_dstirq = pin;        /* INTIN# */
 
-       Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n", 
-               intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-               (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
+       Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
+               intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
+               (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
                intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
 
        mp_irqs[mp_irq_entries] = intsrc;
@@ -757,7 +827,7 @@ void __init mp_config_acpi_legacy_irqs(void)
                return;
 
        intsrc.mpc_type = MP_INTSRC;
-       intsrc.mpc_irqflag = 0;                                 /* Conforming */
+       intsrc.mpc_irqflag = 0; /* Conforming */
        intsrc.mpc_srcbus = MP_ISA_BUS;
        intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
 
@@ -772,28 +842,29 @@ void __init mp_config_acpi_legacy_irqs(void)
                        struct mpc_config_intsrc *irq = mp_irqs + idx;
 
                        /* Do we already have a mapping for this ISA IRQ? */
-                       if (irq->mpc_srcbus == MP_ISA_BUS && irq->mpc_srcbusirq == i)
+                       if (irq->mpc_srcbus == MP_ISA_BUS
+                           && irq->mpc_srcbusirq == i)
                                break;
 
                        /* Do we already have a mapping for this IOAPIC pin */
                        if ((irq->mpc_dstapic == intsrc.mpc_dstapic) &&
-                               (irq->mpc_dstirq == i))
+                           (irq->mpc_dstirq == i))
                                break;
                }
 
                if (idx != mp_irq_entries) {
                        printk(KERN_DEBUG "ACPI: IRQ%d used by override.\n", i);
-                       continue;                       /* IRQ already used */
+                       continue;       /* IRQ already used */
                }
 
                intsrc.mpc_irqtype = mp_INT;
-               intsrc.mpc_srcbusirq = i;                  /* Identity mapped */
+               intsrc.mpc_srcbusirq = i;       /* Identity mapped */
                intsrc.mpc_dstirq = i;
 
                Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
-                       "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-                       (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-                       intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, 
+                       "%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3,
+                       (intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus,
+                       intsrc.mpc_srcbusirq, intsrc.mpc_dstapic,
                        intsrc.mpc_dstirq);
 
                mp_irqs[mp_irq_entries] = intsrc;
@@ -832,21 +903,21 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
        idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
        if (idx > 3) {
                printk(KERN_ERR "Invalid reference to IOAPIC pin "
-                       "%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
-                       ioapic_pin);
+                      "%d-%d\n", mp_ioapic_routing[ioapic].apic_id,
+                      ioapic_pin);
                return gsi;
        }
-       if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
+       if ((1 << bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
                Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
                        mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
                return gsi;
        }
 
-       mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
+       mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1 << bit);
 
        io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
-               triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
-               polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
+                               triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
+                               polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
        return gsi;
 }
-#endif /*CONFIG_ACPI*/
+#endif /* CONFIG_ACPI */