Skip to content

Commit

Permalink
usermode: move sysenter save/restore registers
Browse files Browse the repository at this point in the history
Have the sysenter callee-saved registers saved and restored by the
callee instead of by the caller, like syscall does.

Signed-off-by: Johannes Wikner <[email protected]>
  • Loading branch information
sktt committed Aug 28, 2023
1 parent 65ee0d1 commit ca6b946
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions arch/x86/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ END_FUNC(syscall_handler_entry)
ENTRY(sysenter_handler_entry)
push %_ASM_CX
push %_ASM_DX
SAVE_CALLEE_SAVED_REGS
syscall_from_usermode

cmp $SYSCALL_EXIT, %_ASM_AX
Expand All @@ -236,6 +237,7 @@ ENTRY(sysenter_handler_entry)
call syscall_handler

syscall_to_usermode
RESTORE_CALLEE_SAVED_REGS
pop %_ASM_DX
pop %_ASM_CX

Expand Down
3 changes: 1 addition & 2 deletions common/usermode.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,10 @@ static inline long __user_text _sysenter(long syscall_nr, long arg1, long arg2,

/* clang-format off */
asm volatile (
SAVE_CALLEE_SAVED_REGS()
"mov %%" STR(_ASM_SP) ", %%" STR(_ASM_CX) "\n"
"lea 1f(%%"STR(_ASM_IP)"), %%" STR(_ASM_DX) "\n"
"sysenter\n"
"1: " RESTORE_CALLEE_SAVED_REGS()
"1: "
: "=a"(return_code)
: "0"(syscall_nr), "S"(arg1), "D" (arg2), "r" (_arg3), "r"(_arg4), "r"(_arg5)
: STR(_ASM_CX), STR(_ASM_DX)
Expand Down

0 comments on commit ca6b946

Please sign in to comment.