aboutsummaryrefslogtreecommitdiff
path: root/src/core/scheduler_asm.S
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2021-05-04 15:30:24 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2021-05-04 15:30:24 +0200
commit1530a85d5aefcf6497ff2129023e9a0b002603dd (patch)
treeea6098d0dcafabba0ffc2f28ea5c136f731996b9 /src/core/scheduler_asm.S
parent64a17f3e0683a0a492a3fed9c4c17a4335d1f421 (diff)
Solving many issues: Aligning kernel stack, improve syscall mechanism,
DISABLING RED-ZONE !!!!
Diffstat (limited to 'src/core/scheduler_asm.S')
-rw-r--r--src/core/scheduler_asm.S33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/core/scheduler_asm.S b/src/core/scheduler_asm.S
index 0c9d5ba..24eaa8d 100644
--- a/src/core/scheduler_asm.S
+++ b/src/core/scheduler_asm.S
@@ -1,22 +1,35 @@
.globl switch
-
switch:
# Load task page table
mov (%rdi), %rax
mov %rax, %cr3
+ # ds
+ mov 96(%rdi), %rax
+ mov %ax, %ds
+ # es
+ mov 104(%rdi), %rax
+ mov %ax, %es
+ # fs
+ mov 112(%rdi), %rax
+ mov %ax, %fs
+ # gs
+ mov 120(%rdi), %rax
+ mov %ax, %gs
+
# First load the task stack
mov 64(%rdi), %rsp
# Prepare for iret
- push 96(%rdi) # ds
+ push 56(%rdi) # ss
push 64(%rdi) # rsp
push 128(%rdi) # Flags
pop %rax
- or $0x200, %rax # Enable interrupt
- mov $0xffffffffbfff, %rbx # NT flag
- and %rbx, %rax
+ bts $9, %rax # Enable interrupt
+ not %rax
+ bts $14, %rax # NT flag
+ not %rax
push %rax # Apply flags changes
push 40(%rdi) # cs
push 48(%rdi) # rip
@@ -32,19 +45,12 @@ switch:
push 144(%rdi) # r8
push 152(%rdi) # r9
push 160(%rdi) # r10
- push 160(%rdi) # r11
+ push 168(%rdi) # r11
push 176(%rdi) # r12
push 184(%rdi) # r13
push 192(%rdi) # r14
push 200(%rdi) # r15
- # ds
- mov 96(%rdi), %ax
- mov %ax, %ds
- mov %ax, %gs
- mov %ax, %fs
- mov %ax, %es
-
# Restore general registers
pop %r15
pop %r14
@@ -61,7 +67,6 @@ switch:
pop %rcx
pop %rbx
pop %rax
-
# Perform task switching
iretq