From owner-freebsd-amd64@freebsd.org Mon Feb 13 20:24:18 2017 Return-Path: Delivered-To: freebsd-amd64@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0D18CDDF2F; Mon, 13 Feb 2017 20:24:18 +0000 (UTC) (envelope-from eric@metricspace.net) Received: from mail.metricspace.net (207-172-209-83.c3-0.arl-ubr1.sbo-arl.ma.static.cable.rcn.com [207.172.209.83]) by mx1.freebsd.org (Postfix) with ESMTP id C93A21814; Mon, 13 Feb 2017 20:24:18 +0000 (UTC) (envelope-from eric@metricspace.net) Received: from [IPv6:2001:470:1f11:617:3210:b3ff:fe77:ca3f] (unknown [IPv6:2001:470:1f11:617:3210:b3ff:fe77:ca3f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: eric) by mail.metricspace.net (Postfix) with ESMTPSA id AAB9B1D5A; Mon, 13 Feb 2017 20:24:16 +0000 (UTC) To: freebsd-hackers@FreeBSD.org Cc: freebsd-amd64@freebsd.org, Allan Jude From: Eric McCorkle Subject: GELI BIOS weirdness Message-ID: <6874308d-8892-2f03-d125-418949fd472c@metricspace.net> Date: Mon, 13 Feb 2017 15:24:13 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r4IX03A8AEMamVkTv0I1hnsQjQwkID24j" X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2017 20:24:19 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --r4IX03A8AEMamVkTv0I1hnsQjQwkID24j Content-Type: multipart/mixed; boundary="7StHMtTjFo29XVR1XxTd1TwwNJTgx2Aps"; protected-headers="v1" From: Eric McCorkle To: freebsd-hackers@FreeBSD.org Cc: freebsd-amd64@freebsd.org, Allan Jude Message-ID: <6874308d-8892-2f03-d125-418949fd472c@metricspace.net> Subject: GELI BIOS weirdness --7StHMtTjFo29XVR1XxTd1TwwNJTgx2Aps Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello everyone, I ran into an apparent bug while trying to test a patch related to some GELI boot work. This particular patch involves *BIOS* GELI-on-root (not EFI). I created an image for qemu with a single gpt disk having a freebsd-boot and freebsd-ufs partition, with the freebsd-ufs partition actually having a GELI volume. The gptboot phase crashes with an illegal instruction. I tracked this down to eli_metadata_softc (defined in sys/geom/eli/g_eli.h), specifically to the mod operation near the end. Code here: > if (!(sc->sc_flags & G_ELI_FLAG_AUTH)) > sc->sc_mediasize -=3D (sc->sc_mediasize % sc->sc_sectorsize); > else { This crash also occurs on a build from master. The crash dump shows eip pointing to the following code: 66 0f 38 f6 f0 31 c6 8b - 4d 14 89 cf c1 ff 1f 8b The the first 5 bytes of this looks like it's supposed to be an extended DIV instruction, which is what I would expect, except the opcode is wrong (it's adc instead), which doesn't end up corresponding to any valid form of an extended instruction (the 66 prefix). Examination of the disassembly confirms this, and the surrounding instructions match what you would expect from the C code. Unless I'm missing something, this would seem to indicate a compiler bug. More importantly, it would seem to indicate that anyone building GELI-enabled gptboot from master will end up with a nonfunctional binary.= Can someone else please confirm this, and if so, I think it's probably time to file a bug report. --7StHMtTjFo29XVR1XxTd1TwwNJTgx2Aps-- --r4IX03A8AEMamVkTv0I1hnsQjQwkID24j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRELMWN3SgpoYkrmidWwohAqoAEjQUCWKIV7QAKCRBWwohAqoAE jQxYAPwJRJ+ETq5kIJ7ka9T5AdtHYvi/u6vom6PXkELFc34rswD+JApVKiXNP54N tXY/yRTlQCi8kNSkF31eBrc0xdZOQww= =YAfm -----END PGP SIGNATURE----- --r4IX03A8AEMamVkTv0I1hnsQjQwkID24j--