From c925867ec1be039abb72a7d65bff1b6a85b3d67a Mon Sep 17 00:00:00 2001 From: Olivier Deprez Date: Mon, 31 Oct 2022 12:38:17 +0100 Subject: [PATCH 1/2] feat(spmd): pass SMCCCv1.3 SVE hint to lower EL A normal world caller can emit an SMC with the SVE hint bit set such that the callee can perform an optimization by omitting to save/restore the SVE context. Update the SPMD to pass this information to the SPMC when set by the caller in the SMC flags parameter. For now, restrict this behavior to the SPMC living at S-EL2. Signed-off-by: Olivier Deprez Change-Id: Icf46eb8a391dd3ddd2ee6aff8581a2f1c8a1c274 --- include/services/spmd_svc.h | 3 ++- services/std_svc/spm/el3_spmc/spmc_main.c | 6 ++++-- services/std_svc/spmd/spmd_main.c | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/services/spmd_svc.h b/include/services/spmd_svc.h index 29dfdad34..95f070753 100644 --- a/include/services/spmd_svc.h +++ b/include/services/spmd_svc.h @@ -34,7 +34,8 @@ uint64_t spmd_smc_switch_state(uint32_t smc_fid, uint64_t x2, uint64_t x3, uint64_t x4, - void *handle); + void *handle, + uint64_t flags); #endif /* __ASSEMBLER__ */ #endif /* SPMD_SVC_H */ diff --git a/services/std_svc/spm/el3_spmc/spmc_main.c b/services/std_svc/spm/el3_spmc/spmc_main.c index 9cfcd87ea..247e2c817 100644 --- a/services/std_svc/spm/el3_spmc/spmc_main.c +++ b/services/std_svc/spm/el3_spmc/spmc_main.c @@ -234,7 +234,7 @@ static uint64_t spmc_smc_return(uint32_t smc_fid, /* If we originated in the normal world then switch contexts. */ else if (!secure_origin && ffa_is_secure_world_id(dst_id)) { return spmd_smc_switch_state(smc_fid, secure_origin, x1, x2, - x3, x4, handle); + x3, x4, handle, flags); } else { /* Unknown State. */ panic(); @@ -2490,9 +2490,11 @@ static uint64_t spmc_sp_interrupt_handler(uint32_t id, /* * Forward the interrupt to the S-EL1 SP. The interrupt ID is not * populated as the SP can determine this by itself. + * The flags field is forced to 0 mainly to pass the SVE hint bit + * cleared for consumption by the lower EL. */ return spmd_smc_switch_state(FFA_INTERRUPT, false, FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ, FFA_PARAM_MBZ, - handle); + handle, 0ULL); } diff --git a/services/std_svc/spmd/spmd_main.c b/services/std_svc/spmd/spmd_main.c index 5d19868a2..49d70581d 100644 --- a/services/std_svc/spmd/spmd_main.c +++ b/services/std_svc/spmd/spmd_main.c @@ -667,11 +667,22 @@ uint64_t spmd_smc_switch_state(uint32_t smc_fid, uint64_t x2, uint64_t x3, uint64_t x4, - void *handle) + void *handle, + uint64_t flags) { unsigned int secure_state_in = (secure_origin) ? SECURE : NON_SECURE; unsigned int secure_state_out = (!secure_origin) ? SECURE : NON_SECURE; +#if SPMD_SPM_AT_SEL2 + if ((secure_state_out == SECURE) && (is_sve_hint_set(flags) == true)) { + /* + * Set the SVE hint bit in x0 and pass to the lower secure EL, + * if it was set by the caller. + */ + smc_fid |= (FUNCID_SVE_HINT_MASK << FUNCID_SVE_HINT_SHIFT); + } +#endif + /* Save incoming security state */ #if SPMD_SPM_AT_SEL2 if (secure_state_in == NON_SECURE) { @@ -746,8 +757,9 @@ static uint64_t spmd_smc_forward(uint32_t smc_fid, return spmc_smc_handler(smc_fid, secure_origin, x1, x2, x3, x4, cookie, handle, flags); } + return spmd_smc_switch_state(smc_fid, secure_origin, x1, x2, x3, x4, - handle); + handle, flags); } From 0b0fd0b47616b706e2f07c6da548cdc913fecd17 Mon Sep 17 00:00:00 2001 From: Olivier Deprez Date: Wed, 3 May 2023 14:33:09 +0200 Subject: [PATCH 2/2] fix(fvp): permit enabling SME for SPD=spmd Essentially revert [1] to permit specifying SME support along with SPD=spmd on FVP platform. [1] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/20764 Signed-off-by: Olivier Deprez Change-Id: Iab15d5a4c966b9f5b265ccde6711765e242abeaa --- plat/arm/board/fvp/platform.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk index 3641c2b9b..7501bc445 100644 --- a/plat/arm/board/fvp/platform.mk +++ b/plat/arm/board/fvp/platform.mk @@ -57,7 +57,6 @@ ifneq (${SPD}, tspd) ENABLE_FEAT_TWED := 2 ENABLE_FEAT_GCS := 2 ifeq (${ARCH}, aarch64) -ifneq (${SPD}, spmd) ifeq (${SPM_MM}, 0) ifeq (${CTX_INCLUDE_FPREGS}, 0) ENABLE_SME_FOR_NS := 2 @@ -66,7 +65,6 @@ endif endif endif endif -endif # enable unconditionally for all builds ifeq (${ARCH}, aarch64)