Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xen+hafnium fixes #7246

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 8 additions & 3 deletions core/arch/arm/kernel/thread_spmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ static SLIST_HEAD(mem_frag_state_head, mem_frag_state) frag_state_head =
SLIST_HEAD_INITIALIZER(&frag_state_head);

#else
static uint8_t __rx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE);
static uint8_t __tx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE);
static struct ffa_rxtx my_rxtx = {
static uint8_t __rx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE) __nex_bss;
static uint8_t __tx_buf[SMALL_PAGE_SIZE] __aligned(SMALL_PAGE_SIZE) __nex_bss;
static struct ffa_rxtx my_rxtx __nex_data = {
.rx = __rx_buf,
.tx = __tx_buf,
.size = sizeof(__rx_buf),
Expand Down Expand Up @@ -2620,6 +2620,11 @@ static TEE_Result spmc_init(void)
uint32_t my_vers = 0;
uint32_t vers = 0;

if (IS_ENABLED(CFG_NS_VIRTUALIZATION) &&
virt_add_guest_spec_data(&notif_vm_bitmap_id,
sizeof(struct notif_vm_bitmap), NULL))
panic("virt_add_guest_spec_data");

my_vers = get_ffa_version_from_manifest(get_manifest_dt());
if (my_vers < FFA_VERSION_1_0 || my_vers > FFA_VERSION_1_2) {
EMSG("Unsupported version %"PRIu32".%"PRIu32" from manifest",
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
8 changes: 4 additions & 4 deletions core/include/initcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct initcall {
* +-------------------------------+-----------------------------------+
* | 1. call_preinitcalls() | In the nexus, final calls |
* | 2. call_initcalls() +-----------------------------------+
* | 3. call_finalcalls() | 1. boot_final() / nex_*init*() |
* | 3. call_finalcalls() | 1. nex_*init*() / boot_final() |
* +-------------------------------+-----------------------------------+
* | "Primary CPU switching to normal world boot" is printed |
* +-------------------------------+-----------------------------------+
Expand Down Expand Up @@ -112,8 +112,6 @@ struct initcall {
#define driver_init_late(fn) __define_initcall(driver_init, 2, fn)
#define release_init_resource(fn) __define_initcall(driver_init, 3, fn)

#define boot_final(fn) __define_initcall(final, 1, fn)

/*
* These nex_* init-calls are provided for drivers and services that reside
* in the nexus in case of virtualization. The init-calls are performed
Expand All @@ -122,7 +120,7 @@ struct initcall {
* final calls, while otherwise are the same as the non-nex counterpart.
*/
#ifdef CFG_NS_VIRTUALIZATION
#define nex_early_init(fn) boot_final(fn)
#define nex_early_init(fn) __define_initcall(final, 1, fn)
#define nex_early_init_late(fn) __define_initcall(final, 2, fn)
#define nex_service_init(fn) __define_initcall(final, 3, fn)
#define nex_service_init_late(fn) __define_initcall(final, 4, fn)
Expand All @@ -139,6 +137,8 @@ struct initcall {
#define nex_release_init_resource(fn) release_init_resource(fn)
#endif

#define boot_final(fn) __define_initcall(final, 8, fn)
Copy link
Contributor

@etienne-lms etienne-lms Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe swap order in inline comment at line 83:
s/boot_final() / nex_*init*()/nex_*ini / boot_final()/

I think there should be oter some updates in the inline description because some sentences are wrong or not accurate, e.g.:
"preinit_() are always called before functions registered with _init()."
"boot_final() functions are called first before exiting to normal world the first"
(edited) can be addressed later in a dedicated P-R

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll swap boot_final() / nex_init() in the comment above.
I'll propose an update in a later PR for the description.


void call_preinitcalls(void);
void call_early_initcalls(void);
void call_service_initcalls(void);
Expand Down