mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 22:48:21 +00:00
x86_64 context: fix gs not being swapped properly
This commit is contained in:
@@ -3,19 +3,11 @@ arch_switchcontext:
|
|||||||
mov rsp,rdi
|
mov rsp,rdi
|
||||||
add rsp, 24 ; cr2 gs fs
|
add rsp, 24 ; cr2 gs fs
|
||||||
|
|
||||||
mov rbx,es
|
|
||||||
pop rax
|
pop rax
|
||||||
cmp rax,rbx
|
mov es,rax
|
||||||
jne .segswap
|
|
||||||
add rsp,8 ; ds
|
|
||||||
jmp .genreg
|
|
||||||
.segswap:
|
|
||||||
swapgs
|
|
||||||
mov es,rax
|
|
||||||
pop rax
|
pop rax
|
||||||
mov ds,rax
|
mov ds,rax
|
||||||
|
|
||||||
.genreg:
|
|
||||||
pop rax
|
pop rax
|
||||||
pop rbx
|
pop rbx
|
||||||
pop rcx
|
pop rcx
|
||||||
@@ -33,4 +25,11 @@ arch_switchcontext:
|
|||||||
pop rbp
|
pop rbp
|
||||||
add rsp,8 ; remove error code
|
add rsp,8 ; remove error code
|
||||||
|
|
||||||
|
cmp qword [rsp+8], 0x3b ; user cs
|
||||||
|
jne .noswap
|
||||||
|
|
||||||
|
swapgs
|
||||||
|
|
||||||
|
.noswap:
|
||||||
|
|
||||||
iretq
|
iretq
|
||||||
|
|||||||
Reference in New Issue
Block a user