Subject: Re: Data Abort Exceptions
To: Jay Monkman <jtm@smoothsmoothie.com>
From: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
List: port-arm
Date: 07/22/2002 22:14:13
> On Mon, Jul 22, 2002 at 05:48:56PM +0100, Richard Earnshaw wrote:
> > Current releases of NetBSD are configured not to abort the above, but to
> > use a load-and-rotate type of operation, so in the above func2 would print
> > the value contained by loading (*p & ~3) rotated by 8 bits.
>
> How do you make the compiler generate code to do that? I've looked
> through GCC's documentation, and haven't found it, nor have I found
> the where it's set up in NetBSD.
The compiler doesn't really do anything specifically to make it happen.
It's a natural consequence of the way the way that the LDR instruction is
specified in the architecture. The compiler takes advantage of this to
reduce the number of load instructions when manipulating shorts. However,
it is no longer recommended that this be done, since modern ARM processors
(v4 or later) have a ldrh instruction to load a halfword. Consequently
the ELF ABI that we have forbids its use (though we don't actually fault
it yet).
>
> > On ELF builds we've outlawed this, and on processors that support faulting
> > unaligned accesses we will probably make the CPU abort the access (though
> > I don't believe we do so yet).
>
> On ELF, will you have an exception handler that looks at the aborted
> instrcution, basically interprets it? I believe that's how Linux does
> it, although I didn't look closely. Or will you just kill the process
> that does it?
No, we will probably fault it, at least for now; since it could well be
code written to the old behaviour that expected a rotation to happen.
Besides, expecting the kernel to fix up poorly written code is not
something that I'd like to endorse.
R.