How to prevent user processes accessing I/O ports directly?

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
angwer
Posts: 15
Joined: Tue Dec 16, 2014 8:02 pm
Location: China

How to prevent user processes accessing I/O ports directly?

Post by angwer »

Just as the title, how to prevent user processes accessing I/O ports directly? I know on some archs I/O ports are mapped to memory. So I can prevent user processes accessing the given memory range. But how about isolated I/O? Is there any way to prevent the user process, for example, directly using in and out instructions to manipulate hardwares? I want to force them to use system calls.
Techel
Member
Member
Posts: 215
Joined: Fri Jan 30, 2015 4:57 pm
Location: Germany
Contact:

Re: How to prevent user processes accessing I/O ports direct

Post by Techel »

When the CPU encounters an in or out, it checks weather the IOPL is greater or equal to the CPL. If not, it checks the IOMAP in the TSS. If the corresponding entry is 1, the task has no access to the port and a GPF is triggered.
angwer
Posts: 15
Joined: Tue Dec 16, 2014 8:02 pm
Location: China

Re: How to prevent user processes accessing I/O ports direct

Post by angwer »

Thanks!!!!!
Post Reply