Fix user CPU context saving
All checks were successful
Build documentation / build-and-deploy (push) Successful in 31s

This commit is contained in:
2026-01-25 17:39:34 +01:00
parent 95f590fb3b
commit 8650010992
9 changed files with 27 additions and 29 deletions

View File

@@ -14,26 +14,26 @@
extern void amd64_syscall_entry (void);
int amd64_syscall_dispatch (void* stack_ptr) {
spin_lock_ctx_t ctxcpu;
spin_lock (&thiscpu->lock, &ctxcpu);
spin_lock_ctx_t ctxcpu, ctxpr;
amd64_load_kernel_cr3 ();
struct saved_regs* regs = stack_ptr;
memcpy (&thiscpu->regs, regs, sizeof (struct saved_regs));
spin_lock (&thiscpu->lock, &ctxcpu);
struct proc* caller = thiscpu->proc_current;
spin_lock (&caller->lock, &ctxpr);
memcpy (&caller->pdata.regs, regs, sizeof (struct saved_regs));
spin_unlock (&caller->lock, &ctxpr);
spin_unlock (&thiscpu->lock, &ctxcpu);
int syscall_num = regs->rax;
syscall_handler_func_t func = syscall_find_handler (syscall_num);
if (func == NULL) {
spin_unlock (&thiscpu->lock, &ctxcpu);
return -ST_SYSCALL_NOT_FOUND;
}
struct proc* caller = thiscpu->proc_current;
spin_unlock (&thiscpu->lock, &ctxcpu);
int result = func (caller, regs, regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9);
return result;