arch/risc-v: Set Supervisor User Memory (access) for idle process too

This has been a long issue for me as it results in random crashes when
asynchronous events occur when the idle process is active.

The problem is that the kernel cannot access user memory, because the CPU
status prevents it.
This commit is contained in:
Ville Juven 2023-03-28 13:57:08 +03:00 committed by Alan Carvalho de Assis
parent 01b0305ab5
commit fc44cbdbdb
3 changed files with 14 additions and 0 deletions

View File

@ -70,3 +70,12 @@ uintptr_t riscv_get_newintctx(void)
#endif
);
}
void riscv_set_idleintctx(void)
{
/* Set SUM for idle process if needed */
#ifdef CONFIG_ARCH_USE_MMU
SET_CSR(CSR_STATUS, STATUS_SUM);
#endif
}

View File

@ -78,6 +78,10 @@ void up_initial_state(struct tcb_s *tcb)
riscv_stack_color(tcb->stack_alloc_ptr, 0);
#endif /* CONFIG_STACK_COLORATION */
/* Set idle process' initial interrupt context */
riscv_set_idleintctx();
return;
}

View File

@ -200,6 +200,7 @@ void riscv_copystate(uintptr_t *dest, uintptr_t *src);
void riscv_sigdeliver(void);
int riscv_swint(int irq, void *context, void *arg);
uintptr_t riscv_get_newintctx(void);
void riscv_set_idleintctx(void);
void riscv_exception_attach(void);
#ifdef CONFIG_ARCH_FPU