diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c index f20b73521e9c..c3df686fa02e 100644 --- a/sys/x86/acpica/madt.c +++ b/sys/x86/acpica/madt.c @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -130,6 +132,7 @@ madt_setup_local(void) { ACPI_TABLE_DMAR *dmartbl; vm_paddr_t dmartbl_physaddr; + u_int p[4]; madt = pmap_mapbios(madt_physaddr, madt_length); if ((cpu_feature2 & CPUID2_X2APIC) != 0) { @@ -146,6 +149,16 @@ madt_setup_local(void) } acpi_unmap_table(dmartbl); } + if (vm_guest == VM_GUEST_VMWARE) { + vmware_hvcall(VMW_HVCMD_GETVCPU_INFO, p); + if ((p[0] & VMW_VCPUINFO_VCPU_RESERVED) != 0 || + (p[0] & VMW_VCPUINFO_LEGACY_X2APIC) == 0) { + x2apic_mode = 0; + if (bootverbose) + printf( + "x2APIC available but disabled inside VMWare without intr redirection\n"); + } + } TUNABLE_INT_FETCH("hw.x2apic_enable", &x2apic_mode); } diff --git a/sys/x86/include/vmware.h b/sys/x86/include/vmware.h index c72f48deb825..d3d7e2dca1da 100644 --- a/sys/x86/include/vmware.h +++ b/sys/x86/include/vmware.h @@ -31,8 +31,13 @@ #define VMW_HVMAGIC 0x564d5868 #define VMW_HVPORT 0x5658 + #define VMW_HVCMD_GETVERSION 10 #define VMW_HVCMD_GETHZ 45 +#define VMW_HVCMD_GETVCPU_INFO 68 + +#define VMW_VCPUINFO_LEGACY_X2APIC (1 << 3) +#define VMW_VCPUINFO_VCPU_RESERVED (1 << 31) static __inline void vmware_hvcall(u_int cmd, u_int *p)