From f9479885ba26c07cb8711bc40daae39bca9aceac Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sat, 19 Nov 2022 14:59:34 +0800 Subject: [PATCH] arch/arm64: Move group_addrenv to arm64_syscall_switch Signed-off-by: Xiang Xiao --- arch/arm64/src/common/arm64_blocktask.c | 9 --------- arch/arm64/src/common/arm64_exit.c | 10 ---------- arch/arm64/src/common/arm64_releasepending.c | 9 --------- arch/arm64/src/common/arm64_reprioritizertr.c | 9 --------- arch/arm64/src/common/arm64_syscall.c | 14 ++++++++++++-- arch/arm64/src/common/arm64_unblocktask.c | 9 --------- 6 files changed, 12 insertions(+), 48 deletions(-) diff --git a/arch/arm64/src/common/arm64_blocktask.c b/arch/arm64/src/common/arm64_blocktask.c index ab38103ac4..f8b79a77c2 100644 --- a/arch/arm64/src/common/arm64_blocktask.c +++ b/arch/arm64/src/common/arm64_blocktask.c @@ -133,15 +133,6 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { struct tcb_s *nexttcb = this_task(); -#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. - */ - - group_addrenv(nexttcb); -#endif /* Reset scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm64/src/common/arm64_exit.c b/arch/arm64/src/common/arm64_exit.c index ea16db416c..a25b8946c5 100644 --- a/arch/arm64/src/common/arm64_exit.c +++ b/arch/arm64/src/common/arm64_exit.c @@ -142,16 +142,6 @@ void up_exit(int status) nxsched_resume_scheduler(tcb); -#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. - */ - - group_addrenv(tcb); -#endif - /* Then switch contexts */ arm64_fullcontextrestore(tcb->xcp.regs); diff --git a/arch/arm64/src/common/arm64_releasepending.c b/arch/arm64/src/common/arm64_releasepending.c index 45e6057826..9c8062a691 100644 --- a/arch/arm64/src/common/arm64_releasepending.c +++ b/arch/arm64/src/common/arm64_releasepending.c @@ -96,15 +96,6 @@ void up_release_pending(void) { struct tcb_s *nexttcb = this_task(); -#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. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm64/src/common/arm64_reprioritizertr.c b/arch/arm64/src/common/arm64_reprioritizertr.c index 983882c836..8cefcf86e5 100644 --- a/arch/arm64/src/common/arm64_reprioritizertr.c +++ b/arch/arm64/src/common/arm64_reprioritizertr.c @@ -151,15 +151,6 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) { struct tcb_s *nexttcb = this_task(); -#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. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb); diff --git a/arch/arm64/src/common/arm64_syscall.c b/arch/arm64/src/common/arm64_syscall.c index 29944e23bf..4f97c2cf1f 100644 --- a/arch/arm64/src/common/arm64_syscall.c +++ b/arch/arm64/src/common/arm64_syscall.c @@ -202,10 +202,20 @@ uint64_t *arm64_syscall_switch(uint64_t * regs) break; } - /* Restore the cpu lock */ - if ((uint64_t *)f_regs != ret_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. + */ + + group_addrenv(NULL); +#endif + + /* Restore the cpu lock */ + restore_critical_section(); } diff --git a/arch/arm64/src/common/arm64_unblocktask.c b/arch/arm64/src/common/arm64_unblocktask.c index a3a4b0c324..68fc5d88cb 100644 --- a/arch/arm64/src/common/arm64_unblocktask.c +++ b/arch/arm64/src/common/arm64_unblocktask.c @@ -115,15 +115,6 @@ void up_unblock_task(struct tcb_s *tcb) { struct tcb_s *nexttcb = this_task(); -#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. - */ - - group_addrenv(nexttcb); -#endif /* Update scheduler parameters */ nxsched_resume_scheduler(nexttcb);