From: Marc Dietrich Date: Fri, 29 Mar 2013 12:31:13 +0100 Subject: [U-Boot] [PATCH] disk: add -mno-unaligned-access to CFLAGS In-Reply-To: <20130329080054.095a29ec@lilith> References: <1515022.qtqTyrluE4@ax5200p> <20130329080054.095a29ec@lilith> Message-ID: <1377544.0Jckjif7rZ@ax5200p> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Albert, On Friday 29 March 2013 08:00:54 Albert ARIBAUD wrote: > On Thu, 28 Mar 2013 23:35 +0100, Marc Dietrich wrote: > > [ ... ] > > On Thursday 28 March 2013 21:42:13 Albert ARIBAUD wrote: > > > Which fields, which structures, which files are affected by the > > > unalignment issue? > > > > in my test case, it is the start sector of a partition (check > > include/part_efi.h). disk/part_efi.c reads the legacy mbr (to an aligned > > buffer) which has a partition structure on offset 440+4+2 (<- not aligned > > to 4 byte boundary) and inside this a 32 bit field start_sect (aligned to > > 4 byte boundary). Reading this field (and also the next, nr_sects) will > > cause an exception. Same is for part_dos, but there we still use > > le32_to_int which reads byte by byte. I didn't checked others. > > Thanks for clarifying. > > Considering this is about a very small number of reads, I strongly > prefer that these reads be done through the get_unaligned(&field) macro > defined in e.g. arch/arm/include/asm/unaligned.h, even at the slightly > added cost of decomposing the reads into 8-bit accesses. ok, this is what I was actually looking for :-) I've sent a new patch. Marc