Is it possible to disable software interrupts?

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
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Is it possible to disable software interrupts?

Post 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 :)
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Is it possible to disable software interrupts?

Post 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.
User avatar
thepowersgang
Member
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?

Post 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)
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

Re: Is it possible to disable software interrupts?

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