From a5cfead3bd0761ba22a07a4e168670dfb7c9fb84 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 10 Jan 2024 17:45:09 +0200 Subject: some kmx alleviations --- arch/riscv64/kernel/proc.c | 17 +++++++++++------ arch/riscv64/kernel/vmem.c | 11 ++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'arch') diff --git a/arch/riscv64/kernel/proc.c b/arch/riscv64/kernel/proc.c index a7721e2..4e4d7ec 100644 --- a/arch/riscv64/kernel/proc.c +++ b/arch/riscv64/kernel/proc.c @@ -15,9 +15,9 @@ #include "regs.h" #include "csr.h" -void run_init(struct tcb *t, void *fdt) +void run_init(struct tcb *t, void *fdt, void *initrd) { - /** \todo actually map fdt into the target address space */ + /** \todo actually map fdt and initrd into the target address space */ csr_write(CSR_SSCRATCH, t); csr_write(CSR_SEPC, t->exec); /* gcc gives a warning 'the value of the stack pointer after an asm @@ -27,10 +27,15 @@ void run_init(struct tcb *t, void *fdt) * Could be fixed with a separate pure asm run_init, but I guess this * works for now. */ - __asm__ volatile ("mv sp, %0\n" : : "r" (t->thread_stack_top) : "memory"); - __asm__ volatile ("mv a0, %0\n" : : "r" (t->tid) : "a0"); - __asm__ volatile ("mv a1, %0\n" : : "r" (fdt) : "a1"); - __asm__ volatile ("sret\n" ::: "memory"); + __asm__ volatile ("mv sp, %0\n" + "mv a0, %1\n" + "mv a1, %2\n" + "mv a2, %3\n" + "sret\n" + : + : "r" (t->thread_stack_top), "r" (t->tid), "r" (fdt), + "r" (initrd) + : "memory"); /* we should never reach this */ unreachable(); } diff --git a/arch/riscv64/kernel/vmem.c b/arch/riscv64/kernel/vmem.c index 37b9040..bc984e4 100644 --- a/arch/riscv64/kernel/vmem.c +++ b/arch/riscv64/kernel/vmem.c @@ -493,12 +493,12 @@ void setup_rpc_stack(struct tcb *t) for (size_t i = 0; i < pages; ++i) { pm_t page = alloc_page(BASE_PAGE); map_vpage(t->rpc.vmem, page, - RPC_STACK_BASE + BASE_PAGE_SIZE * i, - flags, BASE_PAGE); + RPC_STACK_BASE + BASE_PAGE_SIZE * i, + flags, BASE_PAGE); map_vpage(t->proc.vmem, page, - RPC_STACK_BASE + BASE_PAGE_SIZE * i, - flags, BASE_PAGE); + RPC_STACK_BASE + BASE_PAGE_SIZE * i, + flags, BASE_PAGE); } /* we allocated a second order page for rpc stack usage */ @@ -506,7 +506,8 @@ void setup_rpc_stack(struct tcb *t) /* slightly hacky maybe but we know the first pte is at RPC_STACK_BASE, * which means that it must also be the leaf */ t->arch.rpc_leaf = (struct vmem *)__find_vmem(t->rpc.vmem, - RPC_STACK_BASE, BASE_PAGE); + RPC_STACK_BASE, + BASE_PAGE); /* 'reserve' top page of stack for kernel use */ t->arch.rpc_idx = 511; } -- cgit v1.3