fix(spmd): prevent SIMD context loss

When SPMD_SPM_AT_SEL2 is enabled, saving and restoring the SIMD context
is not needed because the SPMC handles it. The function
spmd_secure_interrupt_handler incorrectly restores the SWD SIMD context
before entering the SPMC without saving the NWD SIMD context, leading to
its loss. Furthermore, the SWD SIMD context is saved after returning
from the SPMC which is unnecessary.

This commit prevents the restoration of the SWD SIMD context before SPMC
entry and the saving of the SWD SIMD context after returning from the
SPMC when SPMD_SPM_AT_SEL2 is enabled. This ensures the preservation of
the NWD SIMD context.

Change-Id: I16a3e698e61da7019b3a670475e542d1690a5dd9
Signed-off-by: Rakshit Goyal <rakshit.goyal@arm.com>
This commit is contained in:
Rakshit Goyal 2025-02-06 11:58:53 +00:00
parent 8b68a617bc
commit 8f60d99f44

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2020-2025, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -222,6 +222,7 @@ static uint64_t spmd_secure_interrupt_handler(uint32_t id,
* in this scenario where execution was trapped to EL3 due to FIQ.
*/
simd_ctx_save(NON_SECURE, false);
simd_ctx_restore(SECURE);
#endif
#endif
@ -238,14 +239,8 @@ static uint64_t spmd_secure_interrupt_handler(uint32_t id,
/* Mark current core as handling a secure interrupt. */
ctx->secure_interrupt_ongoing = true;
#if CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS
simd_ctx_restore(SECURE);
#endif
rc = spmd_spm_core_sync_entry(ctx);
#if CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS
simd_ctx_save(SECURE, false);
#endif
if (rc != 0ULL) {
ERROR("%s failed (%" PRId64 ") on CPU%u\n", __func__, rc, plat_my_core_pos());
}
@ -258,6 +253,7 @@ static uint64_t spmd_secure_interrupt_handler(uint32_t id,
cm_el1_sysregs_context_restore(NON_SECURE);
#if CTX_INCLUDE_FPREGS || CTX_INCLUDE_SVE_REGS
simd_ctx_save(SECURE, false);
simd_ctx_restore(NON_SECURE);
#endif
#endif