tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Use of the PC value in interrupt/exception handlers

On Aug 2, 2013, at 4:43 AM, Martin Husemann <> 

> On Fri, Aug 02, 2013 at 10:46:31AM +0000, Piyus Kedia wrote:
>> Dear all,
>> We are working on developing a dynamic binary translator for the kernel.
>> Towards this, we wanted to confirm if the interrupted PC value pushed on
>> stack by an interrupt/exception is used by the interrupt/exception handlers?
> You are assuming some special architecture here, aren't you?
> This is all very much machine dependend, and can not be answered for NetBSD
> in general, please give a bit more details. It might be better to ask
> on arch specific mailing lists, if you only care about a certain arch.

In general, interrupt do not care about the PC unless they are returning back
to usermode and an "ast" has been requested. This will causes all the registers
to be saved and a context switch to happen.  The clock handler cares about the 
PC to do profiling.

The code checking for interrupting a RAS handler in cpu_switchto will modify 
the PC back to the start of the RAS if the PC was in the middle of a RAS.

For copying faults, NetBSD uses pcb_onfault whose implementation varies by
architecture but involves saving the PC (and maybe other registers) and 
using the onfault information to return/react to fault by restoring the 
registers saved but this is only applicable to kernel PC addresses.

Home | Main Index | Thread Index | Old Index