Skip to content

Commit

Permalink
core: arm: virt-aware FF-A thread_foreign_intr_exit()
Browse files Browse the repository at this point in the history
thread_foreign_intr_exit() is called after the thread state has been
saved and the thread is suspended. With virtualization enabled
(CFG_NS_VIRTUALIZATION=y) the virt_unset_guest() is also called. After
this, the guests thread contexts aren't available any longer. For FF-A
thread_foreign_intr_exit() needs a few fields from the suspend threads
context so extract those before suspending the thread and pass them as
parameters for thread_foreign_intr_exit().

Signed-off-by: Jens Wiklander <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
  • Loading branch information
jenswi-linaro committed Feb 6, 2025
1 parent 6da451b commit 74e9674
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 13 additions & 0 deletions core/arch/arm/kernel/thread_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,15 @@ END_FUNC el0_sync_abort
write_apiakeylo x2
isb
#endif

#ifdef CFG_CORE_FFA
/* x0 is still pointing to the current thread_ctx */
/* load curr_thread_ctx->tsd.rpc_target_info into w19 */
ldr w19, [x0, #THREAD_CTX_TSD_RPC_TARGET_INFO]
/* load curr_thread_ctx->flags into w19 */
ldr w20, [x0, #THREAD_CTX_FLAGS]
#endif

/* load tmp_stack_va_end */
ldr x1, [sp, #THREAD_CORE_LOCAL_TMP_STACK_VA_END]
/* Switch to SP_EL0 */
Expand Down Expand Up @@ -1193,6 +1202,10 @@ END_FUNC el0_sync_abort
*/

/* Passing thread index in w0 */
#ifdef CFG_CORE_FFA
mov w1, w19 /* rpc_target_info */
mov w2, w20 /* flags */
#endif
b thread_foreign_intr_exit
.endm

Expand Down
10 changes: 2 additions & 8 deletions core/arch/arm/kernel/thread_spmc_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ FUNC thread_rpc_spsr , :
END_FUNC thread_rpc_spsr

/*
* void thread_foreign_intr_exit(uint32_t thread_index)
* void thread_foreign_intr_exit(uint32_t thread_index,
* uint32_t rpc_target_info, uint32_t flags);
*
* This function is jumped to at the end of macro foreign_intr_handler().
* The current thread as indicated by @thread_index has just been
Expand All @@ -209,14 +210,7 @@ END_FUNC thread_rpc_spsr
* in threads[w0].flags. This is only set for the thread which handles SPs.
*/
FUNC thread_foreign_intr_exit , :
/* load threads[w0].tsd.rpc_target_info into w1 */
mov x1, #THREAD_CTX_SIZE
adr_l x2, threads
madd x2, x1, x0, x2
ldr w1, [x2, #THREAD_CTX_TSD_RPC_TARGET_INFO]
#ifdef CFG_SECURE_PARTITION
/* load threads[w0].flags into w2 */
ldr w2, [x2, #THREAD_CTX_FLAGS]
and w2, w2, #THREAD_FLAGS_FFA_ONLY
cbnz w2, thread_ffa_interrupt
#endif /* CFG_SECURE_PARTITION */
Expand Down

0 comments on commit 74e9674

Please sign in to comment.