From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 29 Mar 2013 09:57:05 -0600 Subject: [U-Boot] [PATCH] disk: fix unaligned access in efi partitions In-Reply-To: <1620255.73TLX5Us40@ax5200p> References: <6ff0548717babcbc52d225394549106e659cc303.1364556523.git.marvin24@gmx.de> <20130329133226.3483be02@lilith> <1620255.73TLX5Us40@ax5200p> Message-ID: <5155B9D1.80407@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 03/29/2013 09:13 AM, Marc Dietrich wrote: > On Friday 29 March 2013 13:32:26 Albert ARIBAUD wrote: >> On Fri, 29 Mar 2013 12:28:58 +0100, Marc Dietrich wrote: >>> start_sect is not aligned to a 4 byte boundary thus causing exceptions >>> on ARM platforms. Access this field via the get_unaligned macro. >>> - le32_to_cpu(part->start_sect) == 1UL) { >>> + le32_to_cpu(get_unaligned(&part->start_sect)) == 1UL) { >> Also, beside the asm/unaligned.h file I gave as an example, other header >> files in include/linux/unaligned/ exist that provide alignment-related >> macros, notably with _le and _be versions. Maybe you can find one that >> combines the effects of both le32_to_cpu() and get_unaligned()? > > I looks like get_unaligned does the job for us already, so we can leave the > le32_to_cpu out. But I cannot test it here because of missing big endian > machine with efi and my two brain halfs are already swapped until confusion > (start_sect is defined as _le32). > > Albert, I like to get a fix for this into 2013.04 if possible. Maybe someone > with more endian experience can look at it quickly. Looking at include/linux/unaligned/generic.h, I think you can just use: __get_unaligned_le(&part->start_sect) == 1UL I don't believe the __le32 marking of the start_sect field will have any effect, since the implementation of __get_unaligned_le accesses the variable byte-by-byte.