summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-09-26 22:07:16 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-09-26 22:07:16 -0400
commit8de23ca36173cfdb3c609074496115ebd9045887 (patch)
treec70fe6c0ce229b7b87365a4b0f058e58d901c130
parent5f813d49a08cf3c3f8cf6c422cfb6587df575f62 (diff)
downloadjove-kernel-8de23ca36173cfdb3c609074496115ebd9045887.tar.gz
jove-kernel-8de23ca36173cfdb3c609074496115ebd9045887.tar.bz2
jove-kernel-8de23ca36173cfdb3c609074496115ebd9045887.zip
x86_64: make syscall_entry compliant to SYSTEM-V ABI
-rw-r--r--arch/x86_64/hal/smp.c2
-rw-r--r--arch/x86_64/sys/syscall.c15
-rw-r--r--arch/x86_64/sys/syscall.h2
-rw-r--r--boot/limine/memorymap.c2
-rw-r--r--sys/syscall.c4
-rw-r--r--sys/syscall_objdir.c1
6 files changed, 12 insertions, 14 deletions
diff --git a/arch/x86_64/hal/smp.c b/arch/x86_64/hal/smp.c
index 473786d..f67ce0b 100644
--- a/arch/x86_64/hal/smp.c
+++ b/arch/x86_64/hal/smp.c
@@ -54,7 +54,7 @@ smp_init_bsp(void)
obj_release(processor_objdir_obj);
}
- idt_init();
+ //idt_init();
paging_pml4_init();
}
diff --git a/arch/x86_64/sys/syscall.c b/arch/x86_64/sys/syscall.c
index a694674..7c5727f 100644
--- a/arch/x86_64/sys/syscall.c
+++ b/arch/x86_64/sys/syscall.c
@@ -26,35 +26,28 @@ _syscall_handle_arch(syscall_context_t *ctx)
__attribute__((naked))
void _syscall_entry(void)
{
- __asm__ volatile(" \
+ asm volatile(" \
swapgs; \
movq %%gs:%c[pcb], %%rax; \
movq %%rsp, %%rdx; \
movq %c[ksp](%%rax), %%rsp; \
- pushq %%rcx; \
pushq %%rdx; \
pushq %%r11; \
+ pushq %%rcx; \
pushq %%rbp; \
callq syscall_handler; \
swapgs; \
- xorq %%r15, %%r15; \
- xorq %%r14, %%r14; \
- xorq %%r13, %%r13; \
- xorq %%r12, %%r12; \
xorq %%r10, %%r10; \
xorq %%r9, %%r9; \
xorq %%r8, %%r8; \
xorq %%rsi, %%rsi; \
xorq %%rdi, %%rdi; \
- xorq %%rbp, %%rbp; \
xorq %%rdx, %%rdx; \
- xorq %%rcx, %%rcx; \
- xorq %%rbx, %%rbx; \
popq %%rbp; \
+ popq %%rcx; \
popq %%r11; \
popq %%rsp; \
- popq %%rcx; \
- sysretq;"
+ sysretq"
::
[pcb] "i"(offsetof(processor_t, pcb)),
[ksp] "i"(offsetof(pcb_t, ksp)));
diff --git a/arch/x86_64/sys/syscall.h b/arch/x86_64/sys/syscall.h
index 34f6a2a..32bf787 100644
--- a/arch/x86_64/sys/syscall.h
+++ b/arch/x86_64/sys/syscall.h
@@ -5,6 +5,6 @@
int _syscall_handle_serial(syscall_context_t *ctx);
-#define SYSCALL_SERIAL_COM_WRITE 0
+#define SYSCALL_SERIAL_COM_WRITE 1
#endif
diff --git a/boot/limine/memorymap.c b/boot/limine/memorymap.c
index a8841e2..98405fd 100644
--- a/boot/limine/memorymap.c
+++ b/boot/limine/memorymap.c
@@ -86,7 +86,7 @@ mem_setup_untyped(void)
}
size_t pages = hw_pages > 4095 ? 4095 : hw_pages;
- klogf("%p : %p RESERVED\n", base, ((pages + 1) << 12));
+ //klogf("%p : %p RESERVED\n", base, ((pages + 1) << 12));
jove_owned_obj_t *hwmem_obj = obj_take(&s_hwmemory_objdir.entries[hwmem_i++]);
obj_settype(hwmem_obj, JOVE_OBJ_SHMEMORY);
diff --git a/sys/syscall.c b/sys/syscall.c
index 0da3475..31f9078 100644
--- a/sys/syscall.c
+++ b/sys/syscall.c
@@ -50,6 +50,10 @@ int
_syscall_handle_switch(syscall_context_t *ctx)
{
uint8_t target_type = obj_gettype(ctx->target.obj);
+ if(target_type == JOVE_OBJ_NONE) {
+ klogf("Tried to call syscall on NULL object %P\n", ctx->header->path, ctx->header->pathlen);
+ return -EBADOBJ;
+ }
if(target_type > 0x7F) {
return _syscall_handle_arch(ctx);
}
diff --git a/sys/syscall_objdir.c b/sys/syscall_objdir.c
index 5a6786d..b4d3800 100644
--- a/sys/syscall_objdir.c
+++ b/sys/syscall_objdir.c
@@ -15,6 +15,7 @@ s_syscall_objdir_objtype(
CHECK_TOOSMALL(bytes_needed, payload_size, "Message is too small for payload.");
uint16_t local_idx = *((uint16_t*)payload_data);
+
if(local_idx > JOVE_OBJDIR_ENTRIES) {
kprintf("%s: Object index is out of bounds (>= 512)\n", __func__);
return EOOB;