summaryrefslogtreecommitdiffstats
path: root/arch/x86_64/syscall
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86_64/syscall')
-rw-r--r--arch/x86_64/syscall/invoke-mapping.c11
-rw-r--r--arch/x86_64/syscall/syscall.c24
2 files changed, 29 insertions, 6 deletions
diff --git a/arch/x86_64/syscall/invoke-mapping.c b/arch/x86_64/syscall/invoke-mapping.c
index 186b420..e470034 100644
--- a/arch/x86_64/syscall/invoke-mapping.c
+++ b/arch/x86_64/syscall/invoke-mapping.c
@@ -1,5 +1,5 @@
#include "arch/x86_64/syscall/wrappers.h"
-#include "arch/x86_64/syscall.h"
+#include "arch/x86_64/api/syscall.h"
#include "arch/x86_64/page.h"
#include <stddef.h>
#include "api/error.h"
@@ -20,7 +20,9 @@ s_handle_invoke_mapping_exists(
pmle_t *target_pml;
uint8_t target_depth;
SYSCALL_PAYLOAD_TAKEPML(payload, payload_at, pml4, target_depth, target_pml);
- if(target_pml == NULL || !target_pml->p) return KE_DNE;
+ if(target_pml == NULL || !target_pml->p) {
+ return KE_DNE;
+ }
#ifdef DBG_SYSCALL
klogf("pml d%i %p from %p exists\n", target_depth, target_pml, pml4);
@@ -46,7 +48,9 @@ s_handle_invoke_mapping_map(
objdir_entry_t *untyped_entry;
SYSCALL_PAYLOAD_TAKEOBJ(payload, payload_at, untyped_pathw, untyped_entry);
- if(untyped_entry->type != KO_MEMORY_UNTYPED) return KE_BADOBJ;
+ if(untyped_entry->type != KO_MEMORY_UNTYPED) {
+ return KE_BADOBJ;
+ }
mtx_acquire(&untyped_entry->lock);
if((untyped_entry->data & 0xFFF) != 0) {
@@ -69,6 +73,7 @@ s_handle_invoke_mapping_map(
memset(untyped, 0, 0x1000);
}
untyped_entry->type = KO_NONE;
+ untyped_entry->data = 0;
#ifdef DBG_SYSCALL
klogf("map %p[%i] to %p[%i]\n", untyped_phys, target_depth, target_pml, ((uintptr_t)target_pml & 0xFFF) / 8);
#endif
diff --git a/arch/x86_64/syscall/syscall.c b/arch/x86_64/syscall/syscall.c
index 7ddd179..1ed991d 100644
--- a/arch/x86_64/syscall/syscall.c
+++ b/arch/x86_64/syscall/syscall.c
@@ -35,18 +35,36 @@ __attribute__((naked))
void _syscall_entry(void)
{
__asm__ volatile(" \
- pushq %%r11; \
- pushq %%rcx; \
swapgs; \
movq %%gs:%c[tcb], %%rax; \
movq %%rsp, %c[sp](%%rax); \
movq %c[ksp](%%rax), %%rsp; \
pushq %c[sp](%%rax); \
+ pushq %%r11; \
+ pushq %%rcx; \
+ pushq %%rbx; \
+ pushq %%rbp; \
+ pushq %%r12; \
+ pushq %%r13; \
+ pushq %%r14; \
+ pushq %%r15; \
callq _syscall_handler; \
swapgs; \
- popq %%rsp; \
+ popq %%r15; \
+ popq %%r14; \
+ popq %%r13; \
+ popq %%r12; \
+ popq %%rbp; \
+ popq %%rbx; \
+ xorq %%rdx, %%rdx; \
+ xorq %%rsi, %%rsi; \
+ xorq %%rdi, %%rdi; \
+ xorq %%r8, %%r8; \
+ xorq %%r9, %%r9; \
+ xorq %%r10, %%r10; \
popq %%rcx; \
popq %%r11; \
+ popq %%rsp; \
sysretq;"
::
[tcb] "i"(offsetof(processor_t, tcb)),