From mboxrd@z Thu Jan 1 00:00:00 1970 From: Albert ARIBAUD Date: Mon, 17 Feb 2014 16:55:03 +0100 Subject: [U-Boot] [PATCH v2] arm: Switch to -mno-unaligned-access when supported by the compiler In-Reply-To: <20140217154535.GA5653@bill-the-cat> References: <20140210212630.GB7049@bill-the-cat> <20140210221723.B3DFB380603@gemini.denx.de> <20140210222819.GE7049@bill-the-cat> <20140211081909.BAAED380314@gemini.denx.de> <20140211144349.CBF9938032B@gemini.denx.de> <20140211173755.1ddfecfc@lilith> <20140212143555.GB15819@bill-the-cat> <20140212171915.57e9c715@lilith> <20140217154535.GA5653@bill-the-cat> Message-ID: <20140217165503.6edd88f2@lilith> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Tom, On Mon, 17 Feb 2014 10:45:35 -0500, Tom Rini wrote: > On Wed, Feb 12, 2014 at 05:19:15PM +0100, Albert ARIBAUD wrote: > > Hi Tom, > > > > On Wed, 12 Feb 2014 09:35:55 -0500, Tom Rini wrote: > > > > > On Tue, Feb 11, 2014 at 05:37:55PM +0100, Albert ARIBAUD wrote: > > > > Hi M?ns, > > > > > > > > On Tue, 11 Feb 2014 15:33:09 +0000, M?ns Rullg?rd > > > > wrote: > > > > > > > > > The problem is that the current settings do > > > > > the exact opposite. By using -munaligned-access by default, you are > > > > > asking the compiler to go ahead and do whatever it thinks is best, which > > > > > is sometimes to perform an intentional unaligned access. Exactly when > > > > > this will happen is largely impossible to predict. > > > > > > > > The -munaligned-access option does *not* "[ask] the compiler to go > > > > ahead and do whatever it thinks is best", it tells it to use direct > > > > native accesses when unaligned accesses are required, as opposed to > > > > splitting unaligned accesses into smaller but aligned aligned native > > > > accesses, which is what you get with -mno-unaligned-access. > > > > > > Incorrect, and gets to the heart of our problem. It says that native > > > unaligned accesses are valid and make use of this as appropriate. So > > > our goal of "make the compiler use native unaligned accesses so we can > > > find bad code" is invalid. It's making properly written code fail > > > instead and improperly written code will still be just as improper. > > > > Code which translates into uncontrolled unaligned accesses is not > > properly written. > > It's not. A problem we now have is that when we want to do unaligned > accesses for valid reasons the compiler generates valid code for what we > told it to do, but then fails at run time because we lied to the > compiler. If we have a valid reason to perform an unaligned access, then we must make it explicit that we want it, by including and using put_unaligned() or get_unaligned() or variants thereof. Amicalement, -- Albert.