aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/riscv64/kernel/vmem.c11
-rw-r--r--src/proc.c3
-rw-r--r--src/tcb.c1
3 files changed, 7 insertions, 8 deletions
diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c
index a1ca54e..fa3c1c2 100644
--- a/arch/riscv64/kernel/vmem.c
+++ b/arch/riscv64/kernel/vmem.c
@@ -599,8 +599,8 @@ stat_t setup_rpc_stack(struct tcb *t)
{
/* by default rpc stack is marked inaccessible to generate segfaults on
* access so as to ease stack usage tracking */
- vmflags_t flags = VM_V | VM_R |
- VM_W /*| VM_U note how this is missing */;
+ vmflags_t flags = VM_V | VM_R | VM_W;
+ /* note how VM_U is missing, userspace messing about will be done later */
for (size_t i = 0; i < rpc_pages; ++i) {
pm_t page = alloc_page(BASE_PAGE);
@@ -611,7 +611,6 @@ stat_t setup_rpc_stack(struct tcb *t)
RPC_STACK_BASE + BASE_PAGE_SIZE * i,
flags, BASE_PAGE))
return ERR_OOMEM;
-
}
/* we allocated a second order page for rpc stack usage */
@@ -625,9 +624,9 @@ stat_t setup_rpc_stack(struct tcb *t)
/* we count downward in base pages, the top page is *always* reserved */
t->arch.rpc_idx = rpc_pages - 1;
- /* mark our stack region inaccessible to userspace */
- vm_t stack_top = t->rpc_stack - BASE_PAGE_SIZE;
- set_stack(t, stack_top);
+
+ /* point registers to stack */
+ t->regs = t->rpc_stack - sizeof(struct call_ctx);
return OK;
}
diff --git a/src/proc.c b/src/proc.c
index 62b3e42..b1682bf 100644
--- a/src/proc.c
+++ b/src/proc.c
@@ -56,6 +56,8 @@ stat_t init_proc(void *fdt, vm_t *proc_fdt, vm_t *proc_initrd)
* save them here before we switch */
use_tcb(t);
+ set_stack(t, t->rpc_stack - BASE_PAGE_SIZE);
+
/* allocate stacks etc after ELF file to make sure nothing of importance
* clashes */
stat_t ret = prepare_proc(t, get_init_base(fdt), 0);
@@ -72,7 +74,6 @@ stat_t init_proc(void *fdt, vm_t *proc_fdt, vm_t *proc_initrd)
*proc_initrd = map_shared_fixed_uvmem(t,
initrd, get_initrdsize(fdt),
VM_V | VM_R | VM_U);
-
info("mapped fdt at %lx\n", *proc_fdt);
info("mapped initrd at %lx\n", *proc_initrd);
return OK;
diff --git a/src/tcb.c b/src/tcb.c
index 818d4e7..ab93f77 100644
--- a/src/tcb.c
+++ b/src/tcb.c
@@ -119,7 +119,6 @@ static stat_t __init_free_thread(struct tcb *t)
return ERR_OOMEM;
}
- t->regs = t->rpc_stack - sizeof(struct call_ctx);
t->pid = t->tid;
t->eid = t->tid;
t->rid = t->tid;