x86_64/lapic: Allow vmware with single CPU to boot SMP kernel
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 22 May 2011 11:22:33 +0000 (19:22 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sun, 22 May 2011 11:22:33 +0000 (19:22 +0800)
sys/cpu/x86_64/include/specialreg.h
sys/platform/pc64/apic/lapic.c

index c27422f..b7df461 100644 (file)
 #define        CPUID2_X2APIC   0x00200000
 #define        CPUID2_POPCNT   0x00800000
 #define        CPUID2_AESNI    0x02000000
+#define CPUID2_VMM     0x80000000
 
 /*
  * Important bits in the AMD extended cpuid flags
index d0e5b05..3b14084 100644 (file)
@@ -37,6 +37,7 @@
 #include <machine_base/apic/lapic.h>
 #include <machine_base/apic/ioapic_abi.h>
 #include <machine/segments.h>
+#include <machine/specialreg.h>
 #include <sys/thread2.h>
 
 #include <machine/intr_machdep.h>
@@ -741,6 +742,18 @@ lapic_config(void)
                mp_naps = ap_max;
        }
 
+       if ((cpu_feature2 & CPUID2_VMM) && mp_naps == 0) {
+               /*
+                * XXX
+                * Special hack for vmware.  It looks like that
+                * if only one CPU is configured (mp_naps == 0)
+                * in vmware (cpu_feature2 & CPUID2_VMM),
+                * then LAPIC will not work at all.
+                */
+               kprintf("LAPIC: single CPU virtual machine detected, "
+                       "disable LAPIC\n");
+               return ENXIO;
+       }
        return 0;
 }