Subject: Re: tf_pc value
To: Ben Harris <bjh21@netbsd.org>
From: Chris Gilbert <chris@paradox.demon.co.uk>
List: port-arm32
Date: 03/05/2001 23:07:38
On Monday 05 March 2001  9:47 pm, Ben Harris wrote:
> There seems to be some disagreement between arm26 and arm32 over the value
> of the tf_pc field in a trapframe, which contains the value of the
> user program counter after an exception.
>
> In arm26, I deliberately made sure that it was always the address of the
> faulting instruction, so as to avoid confusing myself.  In arm32, it's the
> address of the faulting instruction for address and data aborts, and the
> address of the next instruction for SWIs and undefined instructions.

Sounds like it's how the value is to be used, eg after a SWI you branch back, 
if you emulate the undef instr then you branch back, if you get an address of 
data abort you want to know where?

Checking the ARM ARM, the lr gets set to:
undef instr: addr of next instr
SWI: addr of next instr
prefetch abort: addr of aborted instr + 4
data abort: addr of aborted instr + 8
IRQ + FIQ: addr of next instr + 4

So we certainly manipulate the values at some point.  I'd prefer that the SWI 
stays as is, seems little point in adding 4 just to take it away later. 
(chris in the we'll save 1 instr if it kills us 8)

> What do other people think behaviour in this area should be?  I'm inclined
> to go the arm26 way (surprise!) because it seems consistent to me, but I'm
> open to persuasion.

I'm not sure either way, however part of me sees the current logic as being 
this is how we use this value so we'll have it make sense, however it could 
make sense to have it as you say as well :)

Chris