From 71518294bb57d3d9c8252704b21a549d58bd8f46 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 15 Oct 2025 22:07:13 -0400 Subject: kern/amd64: trap: Copy trapframe on syscall entry Ensure that the trapframe in the PCB is the latest, upon kernel entry we copy it so it isn't stale. Signed-off-by: Ian Moffett --- src/sys/arch/amd64/cpu/trap.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/sys/arch/amd64/cpu/trap.c b/src/sys/arch/amd64/cpu/trap.c index 921a036..ae3a0cc 100644 --- a/src/sys/arch/amd64/cpu/trap.c +++ b/src/sys/arch/amd64/cpu/trap.c @@ -39,6 +39,7 @@ #include #include #include +#include /* * Trap type to type string conversion table @@ -154,6 +155,7 @@ trap_syscall(struct trapframe *tf) struct syscall_domain *scdp; struct syscall_win *scwp; struct proc *self; + struct md_pcb *pcbp; struct syscall_args scargs = { .arg[0] = tf->rdi, .arg[1] = tf->rsi, @@ -179,6 +181,9 @@ trap_syscall(struct trapframe *tf) return; } + pcbp = &self->pcb; + memcpy(&pcbp->tf, tf, sizeof(pcbp->tf)); + if (tf->rax < scwp->nimpl && tf->rax > 0) { tf->rax = scwp->sctab[tf->rax](&scargs); } -- cgit v1.2.3