summaryrefslogtreecommitdiff
path: root/src/sys/arch/amd64/cpu/trap.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-09-17 21:20:29 -0400
committerIan Moffett <ian@osmora.org>2025-09-17 21:27:49 -0400
commit79822e485edb7b447ab8cb17fdc0f572b598d829 (patch)
treeee142dcadb3488b7e64766d933826520a11ed43d /src/sys/arch/amd64/cpu/trap.c
parent8e268df60bde6b5548b849cc9b83a224a74b3e43 (diff)
kern/amd64: Implement syscall domains and windows
A syscall domain in the L5 kernel is a fixed list of "syscall windows", each syscall window represents a specific platform and/or syscall model. A platform latch within each domain determines which window / platform should be visible. Since syscall domains are per-process, these changes are local to their respective processes. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/arch/amd64/cpu/trap.c')
-rw-r--r--src/sys/arch/amd64/cpu/trap.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/sys/arch/amd64/cpu/trap.c b/src/sys/arch/amd64/cpu/trap.c
index 6ddc079..d023923 100644
--- a/src/sys/arch/amd64/cpu/trap.c
+++ b/src/sys/arch/amd64/cpu/trap.c
@@ -35,6 +35,7 @@
#include <sys/param.h>
#include <sys/cdefs.h>
#include <sys/panic.h>
+#include <sys/cpuvar.h>
#include <sys/syslog.h>
#include <sys/syscall.h>
#include <machine/trap.h>
@@ -149,6 +150,10 @@ trapframe_dump(struct trapframe *tf)
void
trap_syscall(struct trapframe *tf)
{
+ struct pcore *pcore = this_core();
+ struct syscall_domain *scdp;
+ struct syscall_win *scwp;
+ struct proc *self;
struct syscall_args scargs = {
.arg[0] = tf->rdi,
.arg[1] = tf->rsi,
@@ -159,8 +164,23 @@ trap_syscall(struct trapframe *tf)
.tf = tf
};
- if (tf->rax < MAX_SYSCALLS && tf->rax > 0) {
- tf->rax = g_sctab[tf->rax](&scargs);
+ /* Sanity check */
+ if (__unlikely(pcore == NULL)) {
+ printf("trap_syscall: pcore is NULL\n");
+ return;
+ }
+
+ /* Get the current window */
+ self = pcore->curproc;
+ scdp = &self->scdom;
+ scwp = &scdp->slots[0];
+ if (scwp->sctab == NULL && scwp->p == 0) {
+ printf("trap_syscall: no sctab (platch=%x)\n", scdp->platch);
+ return;
+ }
+
+ if (tf->rax < scwp->nimpl && tf->rax > 0) {
+ tf->rax = scwp->sctab[tf->rax](&scargs);
}
}