diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-29 21:17:31 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-29 21:17:31 +0200 |
| commit | 5976ad390a15726c3ddfacf8c8b282c8350f9554 (patch) | |
| tree | 24a55fcd7e6f28d048ac074da59f428b54a81cb0 /arch/riscv64/kernel/proc.c | |
| parent | 314bca3dc19a864c76153bfcd5a58be8c40000f9 (diff) | |
| download | kmi-5976ad390a15726c3ddfacf8c8b282c8350f9554.tar.gz kmi-5976ad390a15726c3ddfacf8c8b282c8350f9554.zip | |
start moving towards threads always being in rpc
Diffstat (limited to 'arch/riscv64/kernel/proc.c')
| -rw-r--r-- | arch/riscv64/kernel/proc.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index d3896c1..f012b20 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -42,15 +42,14 @@ void run_init(struct tcb *t, vm_t fdt, vm_t initrd) { csr_write(CSR_SSCRATCH, t); csr_write(CSR_SEPC, t->callback); - /* gcc gives a warning 'the value of the stack pointer after an asm - * statement must be the same as it was before the statement', so this - * is technically speaking undefined behavior, I think. - * - * Could be fixed with a separate pure asm run_init, but I guess this - * works for now. - */ - vm_t stack_top = t->thread_stack + t->thread_stack_size; - info("jumping to %lx\n", (long)t->callback); + + /* reference main virtual memory */ + struct tcb *r = get_rproc(t); + clone_uvmem(r->proc.vmem, t->rpc.vmem); + flush_tlb_all(); + + vm_t stack_top = t->rpc_stack - BASE_PAGE_SIZE; + info("jumping to %lx with sp = %lx\n", (long)t->callback, stack_top); bkl_unlock(); riscv_run_init(0, t->tid, SYS_USER_SPAWNED, fdt, initrd, 1, stack_top); |
