Re:Stack Swap
Posted: Sun Sep 25, 2005 12:00 pm
I'm quite sure that linux does not use usermode exception handlers, and if you want to determine if the exception was caused by kernel or usermode, you should not check in which mode you are currently running (this was what you asked before, wasn't it?).
The fastest way I could think of by now is to check the code selector that the cpu pushed onto the stack when it entered the interrupt. Then, you just do a compare (when you only have one kernelmode and one usermode code segment), or you could use Brendan's hint (even better): check the lowest 2 bits, they indicate the PL. This way you know which PL caused the exception.
cheers Joe
The fastest way I could think of by now is to check the code selector that the cpu pushed onto the stack when it entered the interrupt. Then, you just do a compare (when you only have one kernelmode and one usermode code segment), or you could use Brendan's hint (even better): check the lowest 2 bits, they indicate the PL. This way you know which PL caused the exception.
cheers Joe