aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 18:58:13 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2024-11-02 18:58:13 +0200
commit5890df7bf838a5a912465a1bba02e5d8cf34e33c (patch)
tree48c17acfc5ed2b44bff817b00123288098273ecc /src
parent5531e2eaaa2fd1dd282dba2fb5bc10e09dfec5e0 (diff)
downloadkmi-5890df7bf838a5a912465a1bba02e5d8cf34e33c.tar.gz
kmi-5890df7bf838a5a912465a1bba02e5d8cf34e33c.zip
allow skipping some cache flushes in proc
Diffstat (limited to 'src')
-rw-r--r--src/elf.c5
-rw-r--r--src/uapi/ipc.c6
-rw-r--r--src/uapi/proc.c13
3 files changed, 5 insertions, 19 deletions
diff --git a/src/elf.c b/src/elf.c
index 85b4b2e..f643d41 100644
--- a/src/elf.c
+++ b/src/elf.c
@@ -93,10 +93,9 @@ static stat_t __map_exec(struct tcb *t,
/* create empty vmem so we don't have to worry about possible overlaps */
struct vmem *new_vmem = create_vmem();
- if (!new_vmem) {
- use_vmem(t->rpc.vmem);
+ if (!new_vmem)
return ERR_OOMEM;
- }
+
struct vmem *old_vmem = t->proc.vmem;
t->proc.vmem = new_vmem;
diff --git a/src/uapi/ipc.c b/src/uapi/ipc.c
index 3f94e63..e323478 100644
--- a/src/uapi/ipc.c
+++ b/src/uapi/ipc.c
@@ -61,7 +61,7 @@ static __inline void enter_rpc(struct tcb *t, struct tcb *r, struct sys_ret a,
/* try to get rid of args as fast as possible to free up registers for
* later use */
- set_ret(t, 6, a);
+ set_ret_fast(t, a);
if (!is_set(flags, IPC_TAIL)) {
ctx->rpc_stack = t->rpc_stack;
@@ -79,7 +79,7 @@ static __inline void enter_rpc(struct tcb *t, struct tcb *r, struct sys_ret a,
}
- set_stack(t, rpc_stack - BASE_PAGE_SIZE);
+ set_stack_fast(t, rpc_stack - BASE_PAGE_SIZE);
clone_uvmem(r->proc.vmem, t->rpc.vmem);
flush_tlb_full();
@@ -203,7 +203,7 @@ static void leave_rpc(struct tcb *t, struct sys_ret a)
/* again, get rid of args as fast as possible */
if (!ctx->notify)
- set_ret(t, 6, a);
+ set_ret_fast(t, a);
struct tcb *r = get_tcb(ctx->pid);
while (!r || !is_proc(r) || zombie(r)) {
diff --git a/src/uapi/proc.c b/src/uapi/proc.c
index 4b6865c..52511f9 100644
--- a/src/uapi/proc.c
+++ b/src/uapi/proc.c
@@ -46,18 +46,12 @@ SYSCALL_DEFINE5(create)(struct tcb *t, sys_arg_t func,
if (!n)
return_args1(t, ERR_OOMEM);
- /* temporarily jump into new thread memory to set arguments */
- use_vmem(n->rpc.vmem);
-
/* this visit is likely not the cheapest thing in the universe, are
* there ways to speed up thread creation? */
set_thread(n);
set_ret5(n, n->tid, d0, d1, d2, d3);
set_return(n, func);
- /* return back */
- use_vmem(t->rpc.vmem);
-
n->notify_id = t->notify_id;
return_args1(t, n->tid);
}
@@ -91,13 +85,9 @@ SYSCALL_DEFINE0(fork)(struct tcb *t)
if (!n)
return_args1(t, ERR_OOMEM);
- /* again, probably not fantastic that we're jumping between address
- * spaces like this */
- use_vmem(n->rpc.vmem);
/* prepare args for when we eventually swap to the new proc, giving
* parent ID as third return value */
set_args2(n, 0, get_eproc(t)->pid);
- use_vmem(t->rpc.vmem);
n->notify_id = c->notify_id;
return_args1(t, n->pid);
@@ -180,12 +170,9 @@ SYSCALL_DEFINE2(spawn)(struct tcb *t, sys_arg_t bin, sys_arg_t interp)
/** @todo should permissions be transferred? Probably, not but now there
* is a slightly annoying asymmetry between fork+exec vs spawn... */
- /* temporarily switch to new thread to manipulate stack */
- use_vmem(n->rpc.vmem);
set_thread(n);
set_return(n, n->callback);
set_ret4(n, 0, n->tid, SYS_USER_SPAWNED, n->pid);
- use_vmem(t->rpc.vmem);
return_args1(t, n->pid);
}