aboutsummaryrefslogtreecommitdiff
path: root/common/tcb.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2023-10-09 14:57:18 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2023-10-09 16:15:06 +0300
commit9c9d589ea310f1290e4d6d2019fc8b51d9a86e42 (patch)
tree81694631f4e848728774c22256baf6cded4f910d /common/tcb.c
parentb2f0f82e18665cb754b93d9795a6f1fb9dfc7c93 (diff)
downloadkmi-9c9d589ea310f1290e4d6d2019fc8b51d9a86e42.tar.gz
kmi-9c9d589ea310f1290e4d6d2019fc8b51d9a86e42.zip
move rpc stack handling to arch-specific code
+ Fairly considerable speedup, as we don't have to look up the rpc pte every time separately, instead cacheing them. Adds an architecture specific limitation to total rpc stack size, though.
Diffstat (limited to 'common/tcb.c')
-rw-r--r--common/tcb.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/common/tcb.c b/common/tcb.c
index d6194e8..e69f2f0 100644
--- a/common/tcb.c
+++ b/common/tcb.c
@@ -84,42 +84,6 @@ static id_t __alloc_tid(struct tcb *t)
}
/**
- * Setup RPC stack.
- *
- * RPC stack is local to each thread, and should not be visible to other threads
- * in the same process. Currently maps the RPC stack in BASE_PAGE increments, to
- * hopefully allow us to later quickly disallow access to programs lower down in
- * the RPC call chain by turning off all stack pages lower than the current
- * stack pointer. We shall see if this actually works or not.
- *
- * @param t Thread to setup RPC stack for.
- * @param bytes Minimum size of RPC stack.
- * @return Base of allocated RPC stack.
- *
- * \todo add error checking */
-static vm_t __setup_rpc_stack(struct tcb *t, size_t bytes)
-{
- pm_t offset = 0;
- size_t pages = __pages(bytes);
- vmflags_t flags = VM_V | VM_R | VM_W | VM_U;
- for (size_t i = 1; i <= pages; ++i) {
- offset = alloc_page(BASE_PAGE);
- map_vpage(t->rpc.vmem, offset,
- RPC_STACK_TOP - BASE_PAGE_SIZE * i,
- flags, BASE_PAGE);
-
- /* map stack into both process and rpc vmem since we want to
- * optimistically write data into it during initialization of an
- * rpc. */
- map_vpage(t->proc.vmem, offset,
- RPC_STACK_TOP - BASE_PAGE_SIZE * i,
- flags, BASE_PAGE);
- }
- t->rpc_stack = RPC_STACK_TOP;
- return RPC_STACK_TOP - BASE_PAGE_SIZE * pages;
-}
-
-/**
* Setup thread stack.
*
* @param t Thread to setup stack for.
@@ -179,7 +143,7 @@ struct tcb *create_thread(struct tcb *p)
t->eid = t->pid;
t->rid = p->rid;
t->rpc.vmem = create_vmem();
- __setup_rpc_stack(t, __call_stack_size);
+ setup_rpc_stack(t);
t->regs = (vm_t)t;