aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-07-17 00:24:32 -0400
committerIan Moffett <ian@osmora.org>2024-07-17 00:24:32 -0400
commit2be1c778a4dfe2c6ebb371b457c1e1dc9e89c98d (patch)
tree2dbf33a0a4d774b6b9694dc45f876c7d1ce87d35 /sys/kern
parentb1e73a96d935260f913410d66f77a52c4daf3f48 (diff)
kernel: exec: Save program state within thread
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/exec_elf64.c1
-rw-r--r--sys/kern/kern_exec.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/sys/kern/exec_elf64.c b/sys/kern/exec_elf64.c
index b207fbb..d9a3bb9 100644
--- a/sys/kern/exec_elf64.c
+++ b/sys/kern/exec_elf64.c
@@ -31,6 +31,7 @@
#include <sys/exec.h>
#include <sys/param.h>
#include <sys/namei.h>
+#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/errno.h>
#include <vm/pmap.h>
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 1466159..ceb08f6 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -36,6 +36,7 @@
#include <vm/map.h>
#include <vm/physmem.h>
#include <machine/pcb.h>
+#include <string.h>
/*
* Release the memory of the old stack
@@ -84,6 +85,9 @@ execve(struct proc *td, const struct execve_args *args)
if (td->stack_base != 0)
release_stack(td);
+ /* Save program state */
+ memcpy(&td->exec, &prog, sizeof(td->exec));
+
/* Set new stack and map it to userspace */
td->stack_base = stack;
vm_map(pcbp->addrsp, td->stack_base, td->stack_base,