From owner-freebsd-amd64@FreeBSD.ORG Sat Feb 15 18:20:01 2014 Return-Path: Delivered-To: freebsd-amd64@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 770EC189 for ; Sat, 15 Feb 2014 18:20:01 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5EC791C87 for ; Sat, 15 Feb 2014 18:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id s1FIK13X075206 for ; Sat, 15 Feb 2014 18:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s1FIK1vK075205; Sat, 15 Feb 2014 18:20:01 GMT (envelope-from gnats) Date: Sat, 15 Feb 2014 18:20:01 GMT Message-Id: <201402151820.s1FIK1vK075205@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org Cc: From: Alan Cox Subject: Re: amd64/186061: FreeBSD 10 crashes as KVM guest on GNU/Linux on AMD family 10h CPUs X-Mailman-Approved-At: Sat, 15 Feb 2014 20:48:34 +0000 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Alan Cox List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Feb 2014 18:20:01 -0000 The following reply was made to PR amd64/186061; it has been noted by GNATS. From: Alan Cox To: bug-followup@FreeBSD.org, simon.matter@invoca.ch Cc: Subject: Re: amd64/186061: FreeBSD 10 crashes as KVM guest on GNU/Linux on AMD family 10h CPUs Date: Sat, 15 Feb 2014 12:09:58 -0600 This is a multi-part message in MIME format. --------------080509080501070706030501 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Can you please verify that the attached patch addresses the problem for you? Aside from addressing the crash, the objective of this patch is avoid enabling the workaround for perpetuity on all past Intel and future AMD/Intel cores on account of one broken AMD core. The systems that I've seen for VM migration look at the reported processor feature sets and only migrate among machines with like feature sets. So, if the feature set includes at least one feature that is not supported by AMD Family 10h or earlier AMD cores, then we shouldn't need to enable the workaround. --------------080509080501070706030501 Content-Type: text/plain; charset=ISO-8859-15; name="PR186061v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="PR186061v2.patch" Index: amd64/amd64/pmap.c =================================================================== --- amd64/amd64/pmap.c (revision 261162) +++ amd64/amd64/pmap.c (working copy) @@ -1008,12 +1008,18 @@ pmap_init(void) } /* - * If the kernel is running in a virtual machine on an AMD Family 10h - * processor, then it must assume that MCA is enabled by the virtual - * machine monitor. + * If the kernel is running on a virtual machine, then it must assume + * that MCA is enabled by the hypervisor. Moreover, the kernel must + * be prepared for the hypervisor changing the vendor and family that + * are reported by CPUID. Consequently, the workaround for AMD Family + * 10h Erratum 383 is enabled if the processor's feature set does not + * include at least one feature that is only supported by older Intel + * or newer AMD processors. */ - if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && - CPUID_TO_FAMILY(cpu_id) == 0x10) + if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 && + (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI | + CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP | + AMDID2_FMA4)) == 0) workaround_erratum383 = 1; /* Index: i386/i386/pmap.c =================================================================== --- i386/i386/pmap.c (revision 261162) +++ i386/i386/pmap.c (working copy) @@ -752,12 +752,18 @@ pmap_init(void) pv_entry_high_water = 9 * (pv_entry_max / 10); /* - * If the kernel is running in a virtual machine on an AMD Family 10h - * processor, then it must assume that MCA is enabled by the virtual - * machine monitor. + * If the kernel is running on a virtual machine, then it must assume + * that MCA is enabled by the hypervisor. Moreover, the kernel must + * be prepared for the hypervisor changing the vendor and family that + * are reported by CPUID. Consequently, the workaround for AMD Family + * 10h Erratum 383 is enabled if the processor's feature set does not + * include at least one feature that is only supported by older Intel + * or newer AMD processors. */ - if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && - CPUID_TO_FAMILY(cpu_id) == 0x10) + if (vm_guest == VM_GUEST_VM && (cpu_feature & CPUID_SS) == 0 && + (cpu_feature2 & (CPUID2_SSSE3 | CPUID2_SSE41 | CPUID2_AESNI | + CPUID2_AVX | CPUID2_XSAVE)) == 0 && (amd_feature2 & (AMDID2_XOP | + AMDID2_FMA4)) == 0) workaround_erratum383 = 1; /* --------------080509080501070706030501--