From owner-freebsd-amd64@FreeBSD.ORG Thu Feb 6 11:00:02 2014 Return-Path: Delivered-To: freebsd-amd64@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5CEA9EB8 for ; Thu, 6 Feb 2014 11:00:02 +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 3AC4914A0 for ; Thu, 6 Feb 2014 11:00:02 +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 s16B01Sg028962 for ; Thu, 6 Feb 2014 11:00:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s16B01pU028961; Thu, 6 Feb 2014 11:00:01 GMT (envelope-from gnats) Date: Thu, 6 Feb 2014 11:00:01 GMT Message-Id: <201402061100.s16B01pU028961@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org Cc: From: "Simon Matter" Subject: Re: amd64/186061: FreeBSD 10 crashes as KVM guest on GNU/Linux on AMD family 10h CPUs X-Mailman-Approved-At: Thu, 06 Feb 2014 13:32:40 +0000 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Simon Matter List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Feb 2014 11:00:02 -0000 The following reply was made to PR amd64/186061; it has been noted by GNATS. From: "Simon Matter" To: bug-followup@FreeBSD.org Cc: simon.matter@invoca.ch Subject: Re: amd64/186061: FreeBSD 10 crashes as KVM guest on GNU/Linux on AMD family 10h CPUs Date: Thu, 6 Feb 2014 11:46:41 +0100 ------=_20140206114641_95473 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Hi, After thinking about it again it seems the proposed solution may not be enough. At least KVM allows to migrate guests from an Intel to an AMD processor. That means in case of running as a vm guest, it's required to always enable "AMD Erratum 383" workaround. Otherwise, after migration to an affected AMD Family 10h processor, the guest could triggered AMD Erratum 383. I've tried to implement this and attached patch fixes the problem for me. Would me nice if someone with more experience than me could have a look at it. Thanks, Simon ------=_20140206114641_95473 Content-Type: text/x-diff; name="vm-erratum383.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="vm-erratum383.patch" --- /usr/src/sys/x86/x86/mca.c.orig 2014-01-16 21:35:03.000000000 +0100 +++ /usr/src/sys/x86/x86/mca.c 2014-02-05 22:15:53.109619475 +0100 @@ -720,8 +720,8 @@ * parity (L1TP) errors is disabled, enable the recommended workaround * for Erratum 383. */ - if (cpu_vendor_id == CPU_VENDOR_AMD && - CPUID_TO_FAMILY(cpu_id) == 0x10 && amd10h_L1TP) + if (vm_guest != VM_GUEST_NO || (cpu_vendor_id == CPU_VENDOR_AMD && + CPUID_TO_FAMILY(cpu_id) == 0x10 && amd10h_L1TP)) workaround_erratum383 = 1; mca_banks = mcg_cap & MCG_CAP_COUNT; --- /usr/src/sys/i386/i386/pmap.c.orig 2014-01-16 21:33:36.000000000 +0100 +++ /usr/src/sys/i386/i386/pmap.c 2014-02-05 22:25:28.395821316 +0100 @@ -752,12 +752,12 @@ 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 in a virtual machine on any processor + * family, then it must assume that MCA is enabled by the virtual + * machine monitor and the vm may migrate to an AMD Family 10h + * processor. */ - if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && - CPUID_TO_FAMILY(cpu_id) == 0x10) + if (vm_guest != VM_GUEST_NO) workaround_erratum383 = 1; /* --- /usr/src/sys/amd64/amd64/pmap.c.orig 2014-01-16 21:33:04.000000000 +0100 +++ /usr/src/sys/amd64/amd64/pmap.c 2014-02-05 22:28:25.814349113 +0100 @@ -1005,12 +1005,12 @@ } /* - * 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 in a virtual machine on any processor + * family, then it must assume that MCA is enabled by the virtual + * machine monitor and the vm may migrate to an AMD Family 10h + * processor. */ - if (vm_guest == VM_GUEST_VM && cpu_vendor_id == CPU_VENDOR_AMD && - CPUID_TO_FAMILY(cpu_id) == 0x10) + if (vm_guest != VM_GUEST_NO) workaround_erratum383 = 1; /* ------=_20140206114641_95473--