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
Is it possible to disable software interrupts?
Re: Is it possible to disable software interrupts?
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.madanra wrote:your OS needs to be able to distinguish between interrupt source anyway.
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
Re: Is it possible to disable software interrupts?
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)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Re: Is it possible to disable software interrupts?
Thank you - that was exactly what I was thinking of.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)