From owner-freebsd-current@FreeBSD.ORG Thu Nov 8 17:32:35 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F3ED0702; Thu, 8 Nov 2012 17:32:34 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 5EB018FC0A; Thu, 8 Nov 2012 17:32:33 +0000 (UTC) Received: from tom.home (localhost [127.0.0.1]) by kib.kiev.ua (8.14.5/8.14.5) with ESMTP id qA8HWLIc017972; Thu, 8 Nov 2012 19:32:21 +0200 (EET) (envelope-from kostikbel@gmail.com) X-DKIM: OpenDKIM Filter v2.5.2 kib.kiev.ua qA8HWLIc017972 Received: (from kostik@localhost) by tom.home (8.14.5/8.14.5/Submit) id qA8HWKnn017971; Thu, 8 Nov 2012 19:32:20 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 8 Nov 2012 19:32:20 +0200 From: Konstantin Belousov To: Joel Dahl Subject: Re: Reboot during startup with recent head Message-ID: <20121108173220.GW73505@kib.kiev.ua> References: <20121108084523.GW1092@jd.benders.se> <509B8F9E.9040502@FreeBSD.org> <20121108122313.GB91783@jd.benders.se> <20121108143320.GV73505@kib.kiev.ua> <20121108163353.GC91783@jd.benders.se> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JCIJwDXlZmsNNBnR" Content-Disposition: inline In-Reply-To: <20121108163353.GC91783@jd.benders.se> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=0.2 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: current@freebsd.org, Andriy Gapon X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2012 17:32:35 -0000 --JCIJwDXlZmsNNBnR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 08, 2012 at 05:33:53PM +0100, Joel Dahl wrote: > On 08-11-2012 16:33, Konstantin Belousov wrote: > > On Thu, Nov 08, 2012 at 01:23:13PM +0100, Joel Dahl wrote: > > > On 08-11-2012 12:55, Andriy Gapon wrote: > > > > on 08/11/2012 10:45 Joel Dahl said the following: > > > > > Hi, > > > > >=20 > > > > > I rebuilt head (r242605) in a VMware virtual machine a couple of = days ago, and > > > > > now it won't boot anymore. The loader menu appears, the countdown= starts, and boom, > > > > > reboot. I tried a fresh head (r242700) but the problem remains. > > > > >=20 > > > > > Going back to r242205 solves the problem, so this was introduced = somewhere > > > > > between r242205 and r242605. > > > > >=20 > > > > > I managed to record the entire thing with my phone before I had t= o leave for > > > > > work today. You can see it here: > > > > >=20 > > > > > http://mirror.vnode.se/upload/head-reboots.mov > > > > >=20 > > > > > Any ideas? Any specific revision I should try to back out? > > > > >=20 > > > >=20 > > > > Rather wild guess - try to back out the recent SMEP commit. > > >=20 > > > Well, it was a good guess. :-) I backed out revision 242433, rebuilt = the kernel, > > > and now it boots again. > >=20 > > The following patch should allow you to boot. Please show me the verbos= e dmesg > > of the boot with the patch applied. >=20 > With this patch the machine is back to a non-booting state again. :-( >=20 > Anything else I should try? Yes, please try the patch below. If it boots, I need a verbose dmesg. My theory is that hypervisor is not aware of the extended features, and do not filter it out from CPUID output. But, despite CPU announcing the features, hypervisor does not support corresponding bits toggle in %cr4. The attempt of the guest to enable e.g. FSGSBASE results in #gf during the early stage of the boot, resulting in reset. I just disabled extensions which need %cr4 configuration, when run in VM. diff --git a/sys/amd64/amd64/identcpu.c b/sys/amd64/amd64/identcpu.c index 465316a..c0ea3ee 100644 --- a/sys/amd64/amd64/identcpu.c +++ b/sys/amd64/amd64/identcpu.c @@ -134,7 +134,7 @@ static struct { void printcpuinfo(void) { - u_int regs[4], i; + u_int regs[4], i, cpu_stdext_disable; char *brand; =20 cpu_class =3D amd64_cpus[cpu].cpu_class; @@ -385,15 +385,36 @@ printcpuinfo(void) } =20 if (cpu_stdext_feature !=3D 0) { - printf("\n Standard Extended Features=3D0x%b", - cpu_stdext_feature, + static const char stdext_b[] =3D "\020" "\001GSFSBASE" "\002TSCADJ" "\010SMEP" "\012ENHMOVSB" - "\013INVPCID" - ); + "\013INVPCID"; + printf("\n Standard Extended Features=3D0x%b", + cpu_stdext_feature, stdext_b); + + /* + * Some hypervisors fail to filter out + * unsupported extended features. For + * now, disable the extensions, + * activation of which requires + * setting a bit in CR4, and which VM + * monitors do not support. + */ + if (cpu_feature2 & CPUID2_HV) { + cpu_stdext_disable =3D + CPUID_STDEXT_FSGSBASE | + CPUID_STDEXT_SMEP; + } + TUNABLE_INT_FETCH("hw.cpu_stdext_disable", + &cpu_stdext_disable); + cpu_stdext_feature &=3D ~cpu_stdext_disable; + if (cpu_stdext_disable !=3D 0) { + printf(" (Not disabled=3D0x%b)", + cpu_stdext_feature, stdext_b); + } } =20 if (via_feature_rng !=3D 0 || via_feature_xcrypt !=3D 0) --JCIJwDXlZmsNNBnR Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlCb7KQACgkQC3+MBN1Mb4jN3wCfS386lhjczhm6Q73juvEekLG4 MFwAoLWlcGy2G2N+Qs9g1VgcYkZd9vh3 =6M7/ -----END PGP SIGNATURE----- --JCIJwDXlZmsNNBnR--