[U-Boot] [PATCH] Make the generic unaligned access code safe for unaligned access

Remy Bohmer linux at bohmer.net
Thu Oct 29 12:24:54 CET 2009


Hi,

2009/10/29 Stefan Roese <sr at denx.de>:
> Hi Remy,
>
> On Wednesday 28 October 2009 22:13:38 Remy Bohmer wrote:
>> The current generic code for handling unaligned access assumes that
>> the processor can properly handle unaligned accesses itself.
>> This is at least not the case for ARM, which results in runtime
>> errors.
>>
>> Rewrite it such that it works for ARM as well.
>
> I introduced this header some time ago for UBIFS support (for PowerPC).
> As you may have noticed, it's a copy from the Linux version. And I

Yep, I noticed that.

> would like to keep it this way if possible.

I understand that, but still the code in there is not _generic_, it
might work on Linux since the data-abort trapcode is handling this
exception that occurs on unaligned accesses...

> Looking at the Linux ARM
> version, the basic difference seems to be the header
> "include/asm-arm/unaligned.h" which includes this file. The Linux
> version of "unaligned.h" does *not* include "access_ok.h" at all. It
> includes "le_byteshift.h" and "be_byteshift.h" instead. And I would
> really like to keep this in sync with Linux if possible.

> So why not do it this way (totally untested):
> From 3e9aa23a66041f05b94f94b1326941331248a487 Mon Sep 17 00:00:00 2001
> From: Stefan Roese <sr at denx.de>
> Date: Thu, 29 Oct 2009 05:57:53 +0100
> Subject: [PATCH] arm: Use Linux version for unaligned access code
>
> Signed-off-by: Stefan Roese <sr at denx.de>
> ---
>  include/asm-arm/unaligned.h            |    3 +-
>  include/linux/unaligned/be_byteshift.h |   70 ++++++++++++++++++++++++++++++++
>  include/linux/unaligned/le_byteshift.h |   70 ++++++++++++++++++++++++++++++++
>  3 files changed, 142 insertions(+), 1 deletions(-)
>  create mode 100644 include/linux/unaligned/be_byteshift.h
>  create mode 100644 include/linux/unaligned/le_byteshift.h

Indeed, this looks cleaner for ARM and it works as well... (hmm, looks
more like the old code I was using which I removed from my
USB-CDC-tree since the unaligned.h code was added to mainline...)

> Please give it a try and feel free to submit this patch
> with a better commit text if it works for you.
>
> Cheers,
> Stefan

I will clean it up and repost that patch. This patch can be ignored.

Kind Regards,

Remy


More information about the U-Boot mailing list