What Ring for IDT Handlers?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
PlayOS

What Ring for IDT Handlers?

Post 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.
Curufir

Re:What Ring for IDT Handlers?

Post 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
PlayOS

Re:What Ring for IDT Handlers?

Post 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.
Tim

Re:What Ring for IDT Handlers?

Post 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.
PlayOS

Re:What Ring for IDT Handlers?

Post 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.
Tim

Re:What Ring for IDT Handlers?

Post 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.
Post Reply