From eccc357ea045d465411ea1fddb448c9c35a2149b Mon Sep 17 00:00:00 2001 From: "Steven J. Magnani" Date: Wed, 14 Sep 2005 13:53:45 +0000 Subject: Abort cpu_initialize if we detect that we've lost a race. git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2032 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- src/arch/i386/lib/cpu.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/arch/i386/lib/cpu.c b/src/arch/i386/lib/cpu.c index 74db2e81f8..628bb79e91 100644 --- a/src/arch/i386/lib/cpu.c +++ b/src/arch/i386/lib/cpu.c @@ -231,22 +231,32 @@ void cpu_initialize(void) die("CPU: missing cpu device structure"); } - /* Find what type of cpu we are dealing with */ - identify_cpu(cpu); - printk_debug("CPU: vendor %s device %x\n", - cpu_vendor_name(cpu->vendor), cpu->device); - - /* Lookup the cpu's operations */ - set_cpu_ops(cpu); - - /* Initialize the cpu */ - if (cpu->ops && cpu->ops->init) { - cpu->enabled = 1; - cpu->initialized = 1; - cpu->ops->init(cpu); + // Check that we haven't been passed bad information as the result of a race + // (i.e. BSP timed out while waiting for us to load secondary_stack) + + if (cpu->path.u.apic.apic_id != lapicid()) { + printk_err("CPU #%d Initialization FAILED: APIC ID mismatch (%u != %u)\n", + info->index, cpu->path.u.apic.apic_id, lapicid()); + // return without setting initialized flag + } else { + /* Find what type of cpu we are dealing with */ + identify_cpu(cpu); + printk_debug("CPU: vendor %s device %x\n", + cpu_vendor_name(cpu->vendor), cpu->device); + + /* Lookup the cpu's operations */ + set_cpu_ops(cpu); + + /* Initialize the cpu */ + if (cpu->ops && cpu->ops->init) { + cpu->enabled = 1; + cpu->initialized = 1; + cpu->ops->init(cpu); + } + + printk_info("CPU #%d Initialized\n", info->index); } - printk_info("CPU #%d Initialized\n", info->index); return; } -- cgit v1.2.3