mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
syscall: do not use cr2 as a scratch register
This commit is contained in:
@@ -225,10 +225,7 @@ global arch_syscall_entry
|
||||
; rax has return value
|
||||
arch_syscall_entry:
|
||||
swapgs
|
||||
; saving the syscall number on cr2 is cursed but we need this extra register
|
||||
; and taking a page fault here would result in a triple fault anyways
|
||||
; because it's still using the user stack
|
||||
mov cr2, rax
|
||||
mov [gs:40], rax ; save syscall number
|
||||
; rax can be used just fine now
|
||||
mov rax, [gs:0] ; thread pointer
|
||||
mov rax, [rax] ; kernel stack top
|
||||
@@ -237,7 +234,7 @@ arch_syscall_entry:
|
||||
; push context
|
||||
push qword 0x1b ; user SS
|
||||
push qword rax ; user RSP
|
||||
mov rax, cr2 ; restore syscall number
|
||||
mov rax, [gs:40] ; restore syscall number
|
||||
push r11 ; rflags is stored in r11
|
||||
push qword 0x23 ; user CS
|
||||
push qword rcx ; save return RIP
|
||||
@@ -266,8 +263,7 @@ arch_syscall_entry:
|
||||
push rbx
|
||||
mov rbx, gs
|
||||
push rbx
|
||||
mov rbx, cr2
|
||||
push rbx
|
||||
sub rsp, 8 ; cr2
|
||||
|
||||
mov rbx, 0x10
|
||||
mov es, rbx
|
||||
|
||||
@@ -28,6 +28,8 @@ typedef struct cpu_t {
|
||||
long hardware_id; // expected to be here by other code
|
||||
long internal_id; // expected to be here by other code
|
||||
|
||||
uint64_t scratch; // expected to be here by other code
|
||||
|
||||
timekeeper_source_t *timekeeper_source;
|
||||
timekeeper_source_info_t *timekeeper_source_info;
|
||||
time_t timekeeper_source_base_ticks;
|
||||
|
||||
Reference in New Issue
Block a user