aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-11-12 22:47:49 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2022-11-12 22:47:49 +0200
commit845cf97e1faee613e3e73900f5f93bfcedc831f1 (patch)
tree17d754897f1b7bcaa8f465d917b30296e5abc3e2 /common
parent605ccff557d031aa83c79087f419769756aa0953 (diff)
downloadkmi-845cf97e1faee613e3e73900f5f93bfcedc831f1.tar.gz
kmi-845cf97e1faee613e3e73900f5f93bfcedc831f1.zip
release mode, ~600k requests
Diffstat (limited to 'common')
-rw-r--r--common/tcb.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/common/tcb.c b/common/tcb.c
index daaae4d..478bd05 100644
--- a/common/tcb.c
+++ b/common/tcb.c
@@ -407,6 +407,12 @@ static void mark_rpc_accessible(struct tcb *t, vm_t start, vm_t end)
set_vpage_flags(t->rpc.vmem, start + pages * page_size, VM_U);
}
+struct call_ctx {
+ vm_t exec;
+ vm_t rpc_stack;
+ id_t eid, pid;
+};
+
void save_context(struct tcb *t)
{
vm_t rpc_stack = t->rpc_stack;
@@ -414,11 +420,15 @@ void save_context(struct tcb *t)
/** @todo what if user uses their own stack? */
rpc_stack = align_down(get_stack(t), BASE_PAGE_SIZE);
- struct tcb *copy = (struct tcb *)(rpc_stack - sizeof(struct tcb));
- memcpy(copy, t, sizeof(struct tcb));
- clone_regs(copy, t);
-
rpc_stack -= BASE_PAGE_SIZE;
+
+ struct call_ctx *ctx = (struct call_ctx *)rpc_stack;
+ ctx->exec = t->exec;
+ ctx->pid = t->pid;
+ ctx->eid = t->eid;
+ ctx->rpc_stack = rpc_stack + BASE_PAGE_SIZE;
+ save_regs(t, ctx + 1);
+
mark_rpc_inaccessible(t, rpc_stack, t->rpc_stack);
t->rpc_stack = rpc_stack;
}
@@ -426,10 +436,11 @@ void save_context(struct tcb *t)
void load_context(struct tcb *t)
{
vm_t rpc_stack = t->rpc_stack;
- struct tcb *copy =
- (struct tcb *)(rpc_stack + BASE_PAGE_SIZE - sizeof(struct tcb));
- memcpy(t, copy, sizeof(struct tcb));
- clone_regs(t, copy);
-
- mark_rpc_accessible(t, rpc_stack, t->rpc_stack);
+ struct call_ctx *ctx = (struct call_ctx *)rpc_stack;
+ set_return(t, ctx->exec);
+ mark_rpc_accessible(t, t->rpc_stack, ctx->rpc_stack);
+ load_regs(ctx + 1, t);
+ t->rpc_stack = ctx->rpc_stack;
+ t->pid = ctx->pid;
+ t->eid = ctx->eid;
}