riscv/addrenv: Move addrenv_switch() to correct place after FPU change
The new address environment must be instantiated prior to restoring FPU state as the CPU status register is in tcb->regs, which is user stack.
This commit is contained in:
parent
5ce169f047
commit
da319bbd85
@ -83,25 +83,9 @@ uintptr_t *riscv_doirq(int irq, uintptr_t *regs)
|
||||
irq_dispatch(irq, regs);
|
||||
|
||||
/* Check for a context switch. If a context switch occurred, then
|
||||
* CURRENT_REGS will have a different value than it did on entry. If an
|
||||
* interrupt level context switch has occurred, then restore the floating
|
||||
* point state and the establish the correct address environment before
|
||||
* returning from the interrupt.
|
||||
* CURRENT_REGS will have a different value than it did on entry.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
if (regs != CURRENT_REGS)
|
||||
{
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
addrenv_switch(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (regs != CURRENT_REGS)
|
||||
{
|
||||
/* Restore the cpu lock */
|
||||
|
@ -229,6 +229,16 @@ static inline void riscv_restorecontext(struct tcb_s *tcb)
|
||||
{
|
||||
CURRENT_REGS = (uintptr_t *)tcb->xcp.regs;
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
addrenv_switch(tcb);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ARCH_FPU
|
||||
/* Restore FPU after the new address environment is instantiated */
|
||||
|
||||
|
@ -44,19 +44,6 @@ void *riscv_perform_syscall(uintptr_t *regs)
|
||||
|
||||
riscv_swint(0, regs, NULL);
|
||||
|
||||
#ifdef CONFIG_ARCH_ADDRENV
|
||||
if (regs != CURRENT_REGS)
|
||||
{
|
||||
/* Make sure that the address environment for the previously
|
||||
* running task is closed down gracefully (data caches dump,
|
||||
* MMU flushed) and set up the address environment for the new
|
||||
* thread at the head of the ready-to-run list.
|
||||
*/
|
||||
|
||||
addrenv_switch(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (regs != CURRENT_REGS)
|
||||
{
|
||||
/* Restore the cpu lock */
|
||||
|
Loading…
Reference in New Issue
Block a user