Don't restor the APIC_SVR value - doing so confuses kvm.
When running on an emulator, get the smp count from cmos (timing on an
emulator - especially when simulating large cpu counts - is too
unreliable to do a count based on timers.)
#define CMOS_MEM_HIGHMEM_LOW 0x5b
#define CMOS_MEM_HIGHMEM_MID 0x5c
#define CMOS_MEM_HIGHMEM_HIGH 0x5d
+#define CMOS_BIOS_SMP_COUNT 0x5f
// CMOS_FLOPPY_DRIVE_TYPE bitdefs
#define CFD_NO_DRIVE 0
#include "util.h" // dprintf
#include "config.h" // CONFIG_*
+#include "cmos.h" // CMOS_BIOS_SMP_COUNT
#define CPUID_APIC (1 << 9)
writel(APIC_ICR_LOW, 0x000C4600 | sipi_vector);
// Wait for other CPUs to process the SIPI.
- mdelay(10);
+ if (CONFIG_COREBOOT)
+ mdelay(10);
+ else
+ while (inb_cmos(CMOS_BIOS_SMP_COUNT) + 1 != readl(&smp_cpus))
+ ;
// Restore memory.
- writel(APIC_SVR, val);
*(u64*)BUILD_AP_BOOT_ADDR = old;
u32 count = readl(&smp_cpus);