Index: sys/x86/x86/mca.c =================================================================== --- sys/x86/x86/mca.c +++ sys/x86/x86/mca.c @@ -1103,7 +1103,7 @@ if (mcg_cap & MCG_CAP_CTL_P) /* Enable MCA features. */ wrmsr(MSR_MCG_CTL, MCG_CTL_ENABLE); - if (PCPU_GET(cpuid) == 0 && boot) + if (IS_BSP() && boot) mca_setup(mcg_cap); /* @@ -1119,6 +1119,14 @@ if ((mask & (1UL << 5)) == 0) wrmsr(MSR_MC0_CTL_MASK, mask | (1UL << 5)); } + + /* + * The cmci_monitor() must not be executed + * simultaneously by several CPUs. + */ + if (boot) + mtx_lock_spin(&mca_lock); + for (i = 0; i < (mcg_cap & MCG_CAP_COUNT); i++) { /* By default enable logging of all errors. */ ctl = 0xffffffffffffffffUL; @@ -1158,6 +1166,8 @@ /* Clear all errors. */ wrmsr(MSR_MC_STATUS(i), 0); } + if (boot) + mtx_unlock_spin(&mca_lock); #ifdef DEV_APIC if (!amd_thresholding_supported() && Index: sys/x86/x86/mp_x86.c =================================================================== --- sys/x86/x86/mp_x86.c +++ sys/x86/x86/mp_x86.c @@ -1007,10 +1007,10 @@ KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread")); PCPU_SET(curthread, PCPU_GET(idlethread)); - mca_init(); - mtx_lock_spin(&ap_boot_mtx); + mca_init(); + /* Init local apic for irq's */ lapic_setup(1);