Page 1 of 1

What Ring for IDT Handlers?

Posted: Sat Nov 09, 2002 6:05 am
by PlayOS
Hi all,

Just wondering what your thoughts on what ring to run interrupt handlers. I guess it really depends on who uses them the most ring0 or ring3, or maybe even a mixture.

Anyway, what are your thoughts?

thanks.

Re:What Ring for IDT Handlers?

Posted: Sat Nov 09, 2002 6:23 am
by Curufir
Personally speaking unless there's an absolutely overwhelming need for something to be operating in ring 0 it gets dumped as far down the protection rings as possible (Generally into ring 3). I do that because I'm bound to slip up writing the code somewhere along the line (If not already :)), and if I do I'd prefer buggy code to be limited to user space.

Curufir

Re:What Ring for IDT Handlers?

Posted: Sun Nov 10, 2002 7:45 am
by PlayOS
OK, so I have been reading the manuals and they say that I cannot be in kernel mode (ring0) and exectue interrupt or exception handlers in user mode (ring3), so how do I run my IDT handlers while I am in kernel mode?

thanks.

Re:What Ring for IDT Handlers?

Posted: Mon Nov 11, 2002 6:49 am
by Tim
You put your IDT handlers in ring 0.

I generally agree with Curufir on this, that system services should be in the lowest ring necessary (for stability, security, etc.). But I think that interrupt handlers should definitely be in ring 0, although there's no reason why those ring 0 handlers can't pass the interrupts to ring 3 if necessary.

Re:What Ring for IDT Handlers?

Posted: Mon Nov 11, 2002 6:59 am
by PlayOS
Thanks Tim and Curufir,

So how would I pass the interrupts onto to Ring 3, say for instance the user program has requested to handle an interrupt, how do I pass it to the program after the system has done what it needs to do with it?

Is it just a matter of calling the handler? (However this seems to easy, considering the would need to be a priviledge change)

If this question takes alot to explain just leave it and I will work it out from the manuals, even though your experience would be very beneficial and appreciated.

thanks again.

Re:What Ring for IDT Handlers?

Posted: Mon Nov 11, 2002 11:39 am
by Tim
Well, that depends on your design, but it's not as easy as calling ring 3 from ring 0: if you did that, then you'd be running the ring 3 code from ring 0.

You'll generally need to implement some inter-process communication system which will allow the kernel to notify whichever user-mode process that asked to be notified about a particular interrupt. See the OpenBLT sources for details.