kernel/x86: set initial user thread IOPL to zero

User threads aren't supposed to be able to adjust the interrupt flag (IF). A few
apps for instance DOSBox would just use the popf instruction and disable the
flag, expecting the change to be ignored.

Quote from the Intel manual:
"The interrupt flag (IF) is altered only when executing at a level at least as
privileged as the IOPL. If a POPF/POPFD instruction is executed with
insufficient privilege, an exception does not occur, but the privileged bits
do not change."

fix #14711

Change-Id: I0519312c1151a1dd76541f60283c6c210a5b21a6
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4046
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Jérôme Duval
2021-06-04 15:56:33 +00:00
committed by waddlesplash
parent b4763972bd
commit bc5570ae60
2 changed files with 2 additions and 4 deletions
+1 -2
View File
@@ -251,8 +251,7 @@ arch_thread_enter_userspace(Thread* thread, addr_t entry, void* args1,
frame.ds = USER_DATA_SELECTOR;
frame.ip = entry;
frame.cs = USER_CODE_SELECTOR;
frame.flags = X86_EFLAGS_RESERVED1 | X86_EFLAGS_INTERRUPT
| (3 << X86_EFLAGS_IO_PRIVILEG_LEVEL_SHIFT);
frame.flags = X86_EFLAGS_RESERVED1 | X86_EFLAGS_INTERRUPT;
frame.user_sp = stackTop;
frame.user_ss = USER_DATA_SELECTOR;
+1 -2
View File
@@ -265,8 +265,7 @@ arch_thread_enter_userspace(Thread* thread, addr_t entry, void* args1,
frame.di = (uint64)args1;
frame.ip = entry;
frame.cs = USER_CODE_SELECTOR;
frame.flags = X86_EFLAGS_RESERVED1 | X86_EFLAGS_INTERRUPT
| (3 << X86_EFLAGS_IO_PRIVILEG_LEVEL_SHIFT);
frame.flags = X86_EFLAGS_RESERVED1 | X86_EFLAGS_INTERRUPT;
frame.sp = stackTop;
frame.ss = USER_DATA_SELECTOR;