[−][src]Static sunrise_kernel::i386::gdt::MAIN_TASK
pub static MAIN_TASK: SpinLock<MainTask>
Main TSS
Because Sunrise does not make use of Hardware Task Switching, we only allocate a single TSS that will be used by every process, we update it at every software task switch.
We mostly set the esp0
field, updating which stack the cpu will jump to when handling an
exception/syscall.
IOPB
Right after the TssStruct, the MAIN_TASK holds a bitarray indicating io-space permissions for the current process, one bit for every port:
0
: this port is addressable.1
: this port is not addressable.
This array is checked by the cpu every time a port is accessed by userspace, and we use it to enforce io-space policies. This array is updated at every task switch.
The kernel bypasses this protection by having the IOPL
set to 0b00
in EFLAGS
,
making the kernel able to access all ports at all times.
Double fault
The only exception to this is double faulting, which does use Hardware Task Switching, and for which we allocate a second TSS, see DOUBLE_FAULT_TASK.