Skip to content

Commit

Permalink
arch,usermode: fix user stack handling in enter_usermode()
Browse files Browse the repository at this point in the history
We need to preserve user stack address on percpu first, to use allow
simple stack switching.

We need to switch to user pagetables before putting IRET frame onto
user stack.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Aug 28, 2023
1 parent 740626e commit 27f2e11
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions arch/x86/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ ENTRY(enter_usermode)
PUSHF

/* Save stack pointer onto per-cpu */
mov %_ASM_SP, %gs:usermode_private
mov %_ASM_DX, %gs:(usermode_private)

/* Move to user stack */
mov %_ASM_DX, %_ASM_SP
syscall_to_usermode

/* SS + SP */
push $__USER_DS
Expand All @@ -162,8 +161,6 @@ ENTRY(enter_usermode)
/* CS + IP */
push $__USER_CS
push $usermode_stub

enter_to_usermode
IRET
END_FUNC(enter_usermode)

Expand Down

0 comments on commit 27f2e11

Please sign in to comment.