kernel: archctl syscall

This commit is contained in:
Matheus
2023-05-10 21:20:31 -03:00
parent eb6edee82f
commit 0b0184de76
3 changed files with 60 additions and 7 deletions
+28
View File
@@ -0,0 +1,28 @@
#include <kernel/syscalls.h>
#include <arch/msr.h>
#include <errno.h>
#define ARCH_CTL_GSBASE 0
#define ARCH_CTL_FSBASE 1
syscallret_t syscall_archctl(context_t *context, int func, void *arg) {
syscallret_t ret = {
.errno = 0,
.ret = 0
};
switch (func) {
case ARCH_CTL_GSBASE:
// kernelgsbase because it will be switched out to user
wrmsr(MSR_KERNELGSBASE, (uint64_t)arg);
break;
case ARCH_CTL_FSBASE:
wrmsr(MSR_FSBASE, (uint64_t)arg);
break;
default:
ret.errno = EINVAL;
break;
}
return ret;
}
+3 -1
View File
@@ -5,6 +5,7 @@ extern syscall_openat
extern syscall_read
extern syscall_seek
extern syscall_close
extern syscall_archctl
syscalltab:
dq syscall_print
dq syscall_mmap
@@ -12,7 +13,8 @@ dq syscall_openat
dq syscall_read
dq syscall_seek
dq syscall_close
syscallcount equ 6
dq syscall_archctl
syscallcount equ 7
section .text
global arch_syscall_entry
; on entry: