From 79822e485edb7b447ab8cb17fdc0f572b598d829 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 17 Sep 2025 21:20:29 -0400 Subject: 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 --- src/sys/arch/amd64/cpu/trap.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/sys/arch/amd64') 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 #include #include +#include #include #include #include @@ -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); } } -- cgit v1.2.3