Getting rid of alignment faults in userspace
Arnaud Patard (Rtp)
arnaud.patard at rtp-net.org
Sat Jun 18 10:33:36 UTC 2011
Dave Martin <dave.martin at linaro.org> writes:
> Hi all,
> I've recently become aware that a few packages are causing alignment
> faults on ARM, and are relying on the alignment fixup emulation code in
> the kernel in order to work.
> Such faults are very expensive in terms of CPU cycles, and can generally
> only result from wrong code (for example, C/C++ code which violates the
> relevant language standards, assembler which makes invalid assumptions,
> or functions called with misaligned pointers due to other bugs).
> Currently, on a natty Ubuntu desktop image I observe no faults except
> from firefox and mono-based apps (see below).
> As part of the general effort to make open source on ARM better, I think
> it would be great if we can disable the alignment fixups (or at least
> enable logging) and work with upstreams to get the affected packages
> For release images we might want to be more forgiving, but for development
> we have the option of being more aggressive.
> The number of affected packages and bugs appears small enough for the
> fixing effort to be feasible, without temporarily breaking whole
> For ARM, we can achieve the goal by augmenting the default kernel command-
> line options: either
> Fix up each alingment fault, but also log the faulting address
> and name of the offending process to dmesg.
> Pass each alignment fault to the user process as SIGBUS (fatal
> by default) and log the faulting address and name of the
> offending process to dmesg.
iirc, someone sent some months/years ago a patch to change the default
but it has been rejected because there are (was ?) some libc including
glibc doing some unaligned access , and this can happen early in the
boot process. In this kind of case, things like getting a sigbus would
Also, as noted by someone else in the thread, you do want to test on
something like armv5* or v4* because there are high chances than the
trap used by the alignment fix won't be triggered at all on >= armv6.
 See commit log of commit d944d549aa86e08cba080396513234cf048fee1f.
More information about the ubuntu-devel