Browse Source

fix(spmd): skip NS EL1 context save & restore operations

NS EL1 context save and restore is taken by SPMC upon entering and
exiting S-EL2

BREAKING CHANGE: Corresponding support is needed in Hafnium SPMC

Change-Id: I8524f1229b3e13c2df4e4b5be3f12436289c30c7
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
pull/2000/merge
Madhukar Pappireddy 9 months ago
parent
commit
2d960a1160
  1. 14
      services/std_svc/spmd/spmd_logical_sp.c
  2. 15
      services/std_svc/spmd/spmd_main.c

14
services/std_svc/spmd/spmd_logical_sp.c

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2023-2024, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -528,9 +528,10 @@ bool spmd_el3_invoke_partition_info_get(
}
/* Save the non-secure context before entering SPMC */
cm_el1_sysregs_context_save(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_save(NON_SECURE);
#else
cm_el1_sysregs_context_save(NON_SECURE);
#endif
spmd_build_ffa_info_get_regs(ctx, target_uuid, start_index, tag);
@ -548,9 +549,10 @@ bool spmd_el3_invoke_partition_info_get(
assert(is_ffa_error(retval) || is_ffa_success(retval));
cm_el1_sysregs_context_restore(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_restore(NON_SECURE);
#else
cm_el1_sysregs_context_restore(NON_SECURE);
#endif
cm_set_next_eret_context(NON_SECURE);
return true;
@ -667,9 +669,10 @@ bool spmd_el3_ffa_msg_direct_req(uint64_t x1,
}
/* Save the non-secure context before entering SPMC */
cm_el1_sysregs_context_save(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_save(NON_SECURE);
#else
cm_el1_sysregs_context_save(NON_SECURE);
#endif
/*
@ -707,9 +710,10 @@ bool spmd_el3_ffa_msg_direct_req(uint64_t x1,
ffa_endpoint_destination(x1)));
}
cm_el1_sysregs_context_restore(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_restore(NON_SECURE);
#else
cm_el1_sysregs_context_restore(NON_SECURE);
#endif
cm_set_next_eret_context(NON_SECURE);

15
services/std_svc/spmd/spmd_main.c

@ -227,9 +227,10 @@ static uint64_t spmd_secure_interrupt_handler(uint32_t id,
assert(handle == cm_get_context(NON_SECURE));
/* Save the non-secure context before entering SPMC */
cm_el1_sysregs_context_save(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_save(NON_SECURE);
#else
cm_el1_sysregs_context_save(NON_SECURE);
#endif
/* Convey the event to the SPMC through the FFA_INTERRUPT interface. */
@ -252,9 +253,10 @@ static uint64_t spmd_secure_interrupt_handler(uint32_t id,
ctx->secure_interrupt_ongoing = false;
cm_el1_sysregs_context_restore(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_restore(NON_SECURE);
#else
cm_el1_sysregs_context_restore(NON_SECURE);
#endif
cm_set_next_eret_context(NON_SECURE);
@ -688,9 +690,6 @@ uint64_t spmd_smc_switch_state(uint32_t smc_fid,
/* Save incoming security state */
#if SPMD_SPM_AT_SEL2
if (secure_state_in == NON_SECURE) {
cm_el1_sysregs_context_save(secure_state_in);
}
cm_el2_sysregs_context_save(secure_state_in);
#else
cm_el1_sysregs_context_save(secure_state_in);
@ -698,9 +697,6 @@ uint64_t spmd_smc_switch_state(uint32_t smc_fid,
/* Restore outgoing security state */
#if SPMD_SPM_AT_SEL2
if (secure_state_out == NON_SECURE) {
cm_el1_sysregs_context_restore(secure_state_out);
}
cm_el2_sysregs_context_restore(secure_state_out);
#else
cm_el1_sysregs_context_restore(secure_state_out);
@ -951,9 +947,10 @@ uint64_t spmd_smc_handler(uint32_t smc_fid,
break;
}
/* Save non-secure system registers context */
cm_el1_sysregs_context_save(NON_SECURE);
#if SPMD_SPM_AT_SEL2
cm_el2_sysregs_context_save(NON_SECURE);
#else
cm_el1_sysregs_context_save(NON_SECURE);
#endif
/*

Loading…
Cancel
Save