From owner-freebsd-arm@FreeBSD.ORG Sun Feb 2 20:00:12 2014 Return-Path: Delivered-To: freebsd-arm@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 460821E8 for ; Sun, 2 Feb 2014 20:00:12 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 999D718E9 for ; Sun, 2 Feb 2014 20:00:11 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1WA3D6-00048R-Po; Sun, 02 Feb 2014 20:00:09 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id s12K047r062327; Sun, 2 Feb 2014 13:00:04 -0700 (MST) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18OIrQGJ1nbdEBMFS8lyUcy Subject: wandboard / imx6 / exynos4 / cortex-a9 "wrong-endian bug" fixed From: Ian Lepore To: freebsd-arm Content-Type: text/plain; charset="us-ascii" Date: Sun, 02 Feb 2014 13:00:04 -0700 Message-ID: <1391371204.13026.43.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: Bernd Walter X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Feb 2014 20:00:12 -0000 As some of you know from previous email or irc conversations, I've been chasing a strange bug for months that affects some cortex-a9 chips, which I've been calling the "wrong-endian bug", where some registers get restored with wrong-endian values on return from an interrupt, leading to a panic or crash during boot. I finally tracked the cause down to our gnu assembler (gas), which apparently thinks that when you say "msr spsr_all, r0" what you meant by "_all" was "only restore 16 of the 32 bits". It's not a bug per se, it's just how the gas authors think the assembler should behave. So, when the chip powers on there may be some garbage bits in the spsr register, and they would never get cleared out because only some of the bits would get restored, and if the big-endian bit was among them Bad Things Happened. I'm not sure why this only affected some cortex-a9 chips such as imx6, but maybe some chips set those registers to zero and some don't at power-on. I fixed the problem by updating our source code to use the newer arm instruction syntax for msr and msr instructions, which ensures all 32 bits get restored. That change happened in r261393, but because of other changes and churn in the tree the first really stable revision that includes the fix is r261410. So if you're working with wandboard or another imx6-based system, please make sure to update to this rev. -- Ian