Skip to content

Commit

Permalink
irq,usermode: mask usermode flags on irq
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Aug 28, 2023
1 parent c5929cc commit c369d80
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 8 additions & 0 deletions arch/x86/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,18 @@ ENTRY(entry_\sym)
END_FUNC(entry_\sym)
.endm

.macro MASK_USER_FLAGS
PUSHF
andl $~(USERMODE_FLAGS_MASK), (%_ASM_SP)
POPF
.endm

.macro interrupt_handler sym func
ENTRY(asm_interrupt_handler_\sym)
enter_from_usermode

MASK_USER_FLAGS

cld
SAVE_ALL_REGS
call \func
Expand Down
6 changes: 1 addition & 5 deletions common/usermode.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ static void init_syscall(void) {
/* FIXME: Add compat support */
wrmsr(MSR_CSTAR, _ul(NULL));

wrmsr(MSR_FMASK, X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF |
X86_EFLAGS_SF | X86_EFLAGS_TF | X86_EFLAGS_IF | X86_EFLAGS_DF |
X86_EFLAGS_OF | X86_EFLAGS_ID | X86_EFLAGS_NT | X86_EFLAGS_RF |
X86_EFLAGS_AC | X86_EFLAGS_IOPL);

wrmsr(MSR_FMASK, USERMODE_FLAGS_MASK);
wrmsr(MSR_EFER, rdmsr(MSR_EFER) | EFER_SCE);
}

Expand Down
5 changes: 5 additions & 0 deletions include/usermode.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
#define SYSCALL_MMAP 2
#define SYSCALL_MUNMAP 3

#define USERMODE_FLAGS_MASK \
(X86_EFLAGS_CF | X86_EFLAGS_PF | X86_EFLAGS_AF | X86_EFLAGS_ZF | X86_EFLAGS_SF | \
X86_EFLAGS_TF | X86_EFLAGS_IF | X86_EFLAGS_DF | X86_EFLAGS_OF | X86_EFLAGS_ID | \
X86_EFLAGS_NT | X86_EFLAGS_RF | X86_EFLAGS_AC | X86_EFLAGS_IOPL)

#ifndef __ASSEMBLY__
#include <percpu.h>
#include <sched.h>
Expand Down

0 comments on commit c369d80

Please sign in to comment.