Page 1 of 1

Is it possible to disable software interrupts?

Posted: Sun Mar 30, 2014 5:12 am
by madanra
If you're only using syscall/sysret for system calls, user mode programs have no valid reason to trigger a software interrupt. This got me thinking: is there any way to disable software interrupts, so that if a user mode program reaches an int instruction, it throws #UD or some other exception?

I realise that there's not much point to this - your OS needs to be able to distinguish between interrupt source anyway. But it would be interesting to know :)

Re: Is it possible to disable software interrupts?

Posted: Sun Mar 30, 2014 5:38 am
by alexfru
madanra wrote:your OS needs to be able to distinguish between interrupt source anyway.
That's the answer to your question. The int instruction in user code typically results in a #GP (if we're talking about protected mode and if we don't set up IDT entries in special ways (you could configure ISRs to be callable from user code (read up on CPL, DPL and conforming segments))) and so you have the distinction already. And whatever interrupt it is, you have to handle it somehow in the kernel. You can't just magically turn all int instructions into nops.

Re: Is it possible to disable software interrupts?

Posted: Sun Mar 30, 2014 5:41 am
by thepowersgang
The DPL field in the IDT entry determines what level is required to invoke that interrupt via 'INT', by setting it to 0, the user cannot invoke 'INT' (they'll probably get a GPF if they try)

Re: Is it possible to disable software interrupts?

Posted: Sun Mar 30, 2014 6:29 am
by madanra
thepowersgang wrote:The DPL field in the IDT entry determines what level is required to invoke that interrupt via 'INT', by setting it to 0, the user cannot invoke 'INT' (they'll probably get a GPF if they try)
Thank you - that was exactly what I was thinking of.