1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 00:37:34 +00:00

Kernel: Simplify x86 IOPL sanity check

Move this architecture-specific sanity check (IOPL must be 0) out of
Scheduler and into the x86 enter_thread_context(). Also do this for
every thread and not just userspace ones.
This commit is contained in:
Andreas Kling 2022-01-30 14:17:46 +01:00
parent 684d5eed19
commit a6b5065d94
2 changed files with 4 additions and 10 deletions

View file

@ -1312,6 +1312,10 @@ extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread)
auto& from_regs = from_thread->regs();
auto& to_regs = to_thread->regs();
// NOTE: IOPL should never be non-zero in any situation, so let's panic immediately
// instead of carrying on with elevated I/O privileges.
VERIFY(get_iopl_from_eflags(to_regs.flags()) == 0);
if (has_fxsr)
asm volatile("fxsave %0"
: "=m"(from_thread->fpu_state()));
@ -1358,8 +1362,6 @@ extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread)
asm volatile("fxrstor %0" ::"m"(to_thread->fpu_state()));
else
asm volatile("frstor %0" ::"m"(to_thread->fpu_state()));
// TODO: ioperm?
}
extern "C" FlatPtr do_init_context(Thread* thread, u32 flags)