aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/kernel')
-rw-r--r--arch/riscv/kernel/main.c10
-rw-r--r--arch/riscv/kernel/vmem.c5
2 files changed, 12 insertions, 3 deletions
diff --git a/arch/riscv/kernel/main.c b/arch/riscv/kernel/main.c
index 40f0eb6..6c504f8 100644
--- a/arch/riscv/kernel/main.c
+++ b/arch/riscv/kernel/main.c
@@ -259,15 +259,17 @@ static void init_proc(void *fdt, struct vm_branch_t *b)
t->pid = 0;
t->tid = 0;
threads_insert(t);
- sp_mem_init(&t->sp_r, uvmem_size());
+ sp_mem_init(&t->sp_r, -uvmem_size(), uvmem_size() - 1);
/* binary itself */
size_t sz = align_up(get_init_size(fdt), BASE_PAGE_SIZE);
- t->bin = alloc_uvmem(t, sz, VM_V | VM_X);
+ t->bin = alloc_uvmem(t, sz, VM_V | VM_X | VM_R | VM_W | VM_U);
/* stack */
- t->stack = alloc_uvmem(t, SZ_2M, VM_V | VM_R | VM_W);
+ t->stack = alloc_uvmem(t, SZ_2M, VM_V | VM_R | VM_W | VM_U);
/* if it needs heap, it'll ask for it */
+ __asm__ ("sfence.vma" : : : "memory");
+
move_init(fdt, (void *)t->bin);
jump_to_userspace(t, 0, 0);
}
@@ -277,6 +279,8 @@ void __main main(void *fdt)
init_dbg(fdt);
dbg_fdt(fdt);
+ /* allow supervisor code to touch user data */
+ csr_set(CSR_SSTATUS, SSTATUS_SUM);
struct vm_branch_t *b = init_vmem(fdt);
init_mem_blocks();
init_irq(fdt);
diff --git a/arch/riscv/kernel/vmem.c b/arch/riscv/kernel/vmem.c
index ffe8731..4cb84a6 100644
--- a/arch/riscv/kernel/vmem.c
+++ b/arch/riscv/kernel/vmem.c
@@ -11,6 +11,11 @@
#define pte_addr(pte) (pnum_to_paddr(pte_ppn(pte)))
#define vm_to_index(a, o) (pm_to_index(a, o))
+void mod_vmem(struct vm_branch_t *branch, vm_t vaddr, uint8_t flags, enum mm_order_t order)
+{
+ /* todo */
+}
+
void map_vmem(struct vm_branch_t *branch,
pm_t paddr, vm_t vaddr, uint8_t flags, enum mm_order_t order)
{