From a6b3643c2a1a95146e93c8b6f07c2e491a1230d6 Mon Sep 17 00:00:00 2001 From: Chris Kay Date: Tue, 6 Feb 2024 15:43:40 +0000 Subject: [PATCH] fix(cm): hide `cm_init_context_by_index` from BL1 BL1 requires the context management library but does not use or implement `cm_init_context_by_index`. This change ensures that is not compiled into BL1, as linking with LTO enabled causes an undefined reference for this function. Change-Id: I4a4602843bd75bc4f47b3e0c4c5a6efce1514ef6 Signed-off-by: Chris Kay --- include/lib/el3_runtime/context_mgmt.h | 9 ++++++--- lib/el3_runtime/aarch32/context_mgmt.c | 4 +++- lib/el3_runtime/aarch64/context_mgmt.c | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/lib/el3_runtime/context_mgmt.h b/include/lib/el3_runtime/context_mgmt.h index f631125f0..7451b8580 100644 --- a/include/lib/el3_runtime/context_mgmt.h +++ b/include/lib/el3_runtime/context_mgmt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -30,12 +30,15 @@ void cm_set_context_by_index(unsigned int cpu_idx, void *cm_get_context(uint32_t security_state); void cm_set_context(void *context, uint32_t security_state); void cm_init_my_context(const struct entry_point_info *ep); -void cm_init_context_by_index(unsigned int cpu_idx, - const struct entry_point_info *ep); void cm_setup_context(cpu_context_t *ctx, const struct entry_point_info *ep); void cm_prepare_el3_exit(uint32_t security_state); void cm_prepare_el3_exit_ns(void); +#if !IMAGE_BL1 +void cm_init_context_by_index(unsigned int cpu_idx, + const struct entry_point_info *ep); +#endif /* !IMAGE_BL1 */ + #ifdef __aarch64__ #if IMAGE_BL31 void cm_manage_extensions_el3(void); diff --git a/lib/el3_runtime/aarch32/context_mgmt.c b/lib/el3_runtime/aarch32/context_mgmt.c index b60b8e0f0..e96156d16 100644 --- a/lib/el3_runtime/aarch32/context_mgmt.c +++ b/lib/el3_runtime/aarch32/context_mgmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -157,6 +157,7 @@ static void enable_extensions_nonsecure(bool el2_unused) #endif /* IMAGE_BL32 */ } +#if !IMAGE_BL1 /******************************************************************************* * The following function initializes the cpu_context for a CPU specified by * its `cpu_idx` for first use, and sets the initial entrypoint state as @@ -169,6 +170,7 @@ void cm_init_context_by_index(unsigned int cpu_idx, ctx = cm_get_context_by_index(cpu_idx, GET_SECURITY_STATE(ep->h.attr)); cm_setup_context(ctx, ep); } +#endif /* !IMAGE_BL1 */ /******************************************************************************* * The following function initializes the cpu_context for the current CPU diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c index 39f39476f..6d9886040 100644 --- a/lib/el3_runtime/aarch64/context_mgmt.c +++ b/lib/el3_runtime/aarch64/context_mgmt.c @@ -809,6 +809,7 @@ static void manage_extensions_secure(cpu_context_t *ctx) #endif /* IMAGE_BL31 */ } +#if !IMAGE_BL1 /******************************************************************************* * The following function initializes the cpu_context for a CPU specified by * its `cpu_idx` for first use, and sets the initial entrypoint state as @@ -821,6 +822,7 @@ void cm_init_context_by_index(unsigned int cpu_idx, ctx = cm_get_context_by_index(cpu_idx, GET_SECURITY_STATE(ep->h.attr)); cm_setup_context(ctx, ep); } +#endif /* !IMAGE_BL1 */ /******************************************************************************* * The following function initializes the cpu_context for the current CPU