Some confusion about interrupt redirection

Programming, for all ages and all languages.
Post Reply
16bitPM
Member
Member
Posts: 28
Joined: Wed Sep 05, 2012 3:53 pm

Some confusion about interrupt redirection

Post by 16bitPM »

Hello,

I'm sure it's practically a trivial question, but I'm still a bit confused.
The wiki says (right here):

Code: Select all

   uint16_t selector; // a code segment selector in GDT or LDT
Does this mean that interrupt redirection can be done in partial by the CPU? I mean, suppose you wanted your programs to have access to the BOUND exception, could I just set up the IDT to make it point to a fixed LDT entry (which, of course, should be present in all LDT's). So every time a task switch occurs, the BOUND (INT5) vector would potentially point to another piece of code, let's say set up by a user-callable kernel function. This would also mean the LDT selector could be set up to point to CPL=3 code, avoiding privilege switching.

And yet, if I recall correctly, most OSes do the redirection by hand. Why?

So ehrm, comments are welcome.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Some confusion about interrupt redirection

Post by bluemoon »

Note that, "The processor does not permit transfer of execution to an exception- or interrupt-handler procedure in a less privileged code segment (numerically greater privilege level) than the CPL."

So if your exception handler are with CPL=3, things can be messly for kernel exceptions.
16bitPM
Member
Member
Posts: 28
Joined: Wed Sep 05, 2012 3:53 pm

Re: Some confusion about interrupt redirection

Post by 16bitPM »

bluemoon wrote:Note that, "The processor does not permit transfer of execution to an exception- or interrupt-handler procedure in a less privileged code segment (numerically greater privilege level) than the CPL."

So if your exception handler are with CPL=3, things can be messly for kernel exceptions.
Yes, you are right of course. But I still could make it point to the LDT :-)
Post Reply