From owner-svn-src-all@FreeBSD.ORG Wed Feb 11 16:54:49 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3EC23BC8; Wed, 11 Feb 2015 16:54:49 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC796B50; Wed, 11 Feb 2015 16:54:48 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t1BGsg0u020673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 11 Feb 2015 18:54:42 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t1BGsg0u020673 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t1BGsgWU020672; Wed, 11 Feb 2015 18:54:42 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 11 Feb 2015 18:54:42 +0200 From: Konstantin Belousov To: John Baldwin Subject: Re: svn commit: r278473 - in head/sys: amd64/amd64 amd64/include amd64/vmm contrib/dev/acpica/include i386/i386 i386/include x86/acpica x86/include x86/x86 x86/xen Message-ID: <20150211165442.GT42409@kib.kiev.ua> References: <20150211083200.GO42409@kib.kiev.ua> <6564436.fIAEJlraDt@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6564436.fIAEJlraDt@ralph.baldwin.cx> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, trasz@freebsd.org, Rui Paulo X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2015 16:54:49 -0000 On Wed, Feb 11, 2015 at 10:20:03AM -0500, John Baldwin wrote: > On Wednesday, February 11, 2015 10:32:00 AM Konstantin Belousov wrote: > > On Wed, Feb 11, 2015 at 12:43:39AM +0000, Rui Paulo wrote: > > > On Feb 09, 2015, at 01:01 PM, Konstantin Belousov wrote: > > > > > > Author: kib > > > Date: Mon Feb 9 21:00:56 2015 > > > New Revision: 278473 > > > URL: https://svnweb.freebsd.org/changeset/base/278473 > > > > > > Log: > > > Add x2APIC support. Enable it by default if CPU is capable. The > > > hw.x2apic_enable tunable allows disabling it from the loader prompt. > > > > > > This breaks VMware Fusion when the host CPU has x2APIC support. In > > > my case, mpt(4) was unable to receive interrupts and USB was similarly > > > broken. It's possible that this is a VMware bug, but you might want to > > > avoid turning this on when running under the VMware hypervisor. > > > > Neel pointed this out to me when the patch was reviewed. > > He told me that x2APIC does not work in Fusion 5.x, while it seems > > to be fixed in 7.x. > > https://communities.vmware.com/message/2173695?tstart=0 > > > > Upon further discussion with Neel and Peter, it was suggested that we > > enable enable x2APIC unconditionally, which seems what is done for > > Linux benchmarks. > > > > Is vmware 5.x is used while there is already at least version 7.x ? > > I have no idea about vmware product nomenclature and lifecycle. > > I believe we can ask vmware what version it is when we notice we are running > under it (which we already detect for TSC purposes). We could quirk for that > case, or even just disable for VM_GUEST_VMWARE for now. > Ok, https://lkml.org/lkml/2013/1/17/552 Patch is below. Please, users of VMWare, test it. diff --git a/sys/x86/acpica/madt.c b/sys/x86/acpica/madt.c index f20b735..c3df686 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 c72f48d..d3d7e2d 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)