Seems like the problem with syscall/IF is fixed

This commit is contained in:
Mark
2019-10-01 17:28:27 +03:00
parent 24ff3737d4
commit dff06deb0f
7 changed files with 27 additions and 11 deletions
BIN
View File
Binary file not shown.
+10 -4
View File
@@ -1,10 +1,16 @@
.section .text
.global _start
_start:
movq $100, %rcx
0:
movq $1, %rdi
movq $2, %rsi
movq $3, %rdx
movq $4, %r10
movq $5, %r8
movq $6, %r9
syscall
movq $10000000, %rcx
1:
dec %rcx
jnz 1b
// XXX: Syscall fucks up kstack?
//syscall
jmp _start
jmp 0b
+4 -3
View File
@@ -41,11 +41,12 @@
popq %rax
mov %rax, %ds
popq %rax
//mov %rax, %es
mov %rax, %es
popq %rax
//mov %rax, %fs
popq %rax
//mov %rax, %gs
xor %rax, %rax
mov %rax, %fs
mov %rax, %gs
// cr3
popq %rax
+4
View File
@@ -2,4 +2,8 @@
#include "sys/debug.h"
void amd64_syscall(uint64_t a0, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5) {
switch (a0) {
default:
return;
}
}
+6 -4
View File
@@ -28,7 +28,7 @@ amd64_setup_syscall:
movl $AMD64_MSR_LSTAR, %ecx
wrmsr
movl $0x0, %eax
movl $0x0200, %eax
movl $0x0, %edx
movl $AMD64_MSR_SFMASK, %ecx
wrmsr
@@ -42,7 +42,6 @@ amd64_setup_syscall:
retq
amd64_syscall_entry:
cli
// R11 = RFLAGS
// RCX = userRIP
// RSP = userRSP
@@ -54,8 +53,8 @@ amd64_syscall_entry:
// 1. Load kernRSP from amd64_thread_current->kstack_ptr,
// userRSP is stored in %rax before being pushed
movq %rsp, %rax
movq sched_current(%rip), %rsi
movq (%rsi), %rsp
movq sched_current(%rip), %rsp
movq (%rsp), %rsp
// syscall handlers may mess up this in SysV amd64 ABI, store
// these on stack
@@ -63,6 +62,9 @@ amd64_syscall_entry:
pushq %r11
pushq %rcx
// Move arguments
movq %r10, %rcx
call amd64_syscall
popq %rcx
+2
View File
@@ -31,9 +31,11 @@ int thread_init(thread_t *t,
panic("Failed to allocate thread kstack\n");
}
}
t->kstack_base = kstack_base;
t->kstack_size = kstack_size;
t->kstack_ptr = t->kstack_base + t->kstack_size - sizeof(amd64_thread_context_t);
kdebug("KSTACK %p\n", t->kstack_ptr);
// If we're not kernel, additionally set the ustack
if (!(flags & THREAD_KERNEL)) {
+1
View File
@@ -44,6 +44,7 @@ int sched(void) {
if (to == from) {
return -1;
}
sched_current = to;
return 0;
}