From 9c9d589ea310f1290e4d6d2019fc8b51d9a86e42 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 9 Oct 2023 14:57:18 +0300 Subject: 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. --- common/tcb.c | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) (limited to 'common/tcb.c') diff --git a/common/tcb.c b/common/tcb.c index d6194e8..e69f2f0 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -83,42 +83,6 @@ static id_t __alloc_tid(struct tcb *t) return ERR_NF; } -/** - * 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. * @@ -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; -- cgit v1.3