diff --git a/bl31/bl31.mk b/bl31/bl31.mk index 25c7964a1..7d83e3cb3 100644 --- a/bl31/bl31.mk +++ b/bl31/bl31.mk @@ -18,7 +18,8 @@ ifeq (${SPM_MM},1) $(error EL3_EXCEPTION_HANDLING must be 1 for SPM-MM support) else $(info Including SPM Management Mode (MM) makefile) - include services/std_svc/spm_mm/spm_mm.mk + include services/std_svc/spm/common/spm.mk + include services/std_svc/spm/spm_mm/spm_mm.mk endif endif @@ -40,6 +41,7 @@ BL31_SOURCES += bl31/bl31_main.c \ services/std_svc/std_svc_setup.c \ ${PSCI_LIB_SOURCES} \ ${SPMD_SOURCES} \ + ${SPM_MM_SOURCES} \ ${SPM_SOURCES} ifeq (${DISABLE_MTPMU},1) diff --git a/services/std_svc/spm_mm/aarch64/spm_mm_helpers.S b/services/std_svc/spm/common/aarch64/spm_helpers.S similarity index 96% rename from services/std_svc/spm_mm/aarch64/spm_mm_helpers.S rename to services/std_svc/spm/common/aarch64/spm_helpers.S index 2c3aaf7ae..95e69fb68 100644 --- a/services/std_svc/spm_mm/aarch64/spm_mm_helpers.S +++ b/services/std_svc/spm/common/aarch64/spm_helpers.S @@ -1,11 +1,11 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include -#include "../spm_mm_private.h" +#include "spm_common.h" .global spm_secure_partition_enter .global spm_secure_partition_exit diff --git a/services/std_svc/spm/common/include/spm_common.h b/services/std_svc/spm/common/include/spm_common.h new file mode 100644 index 000000000..68805fc4d --- /dev/null +++ b/services/std_svc/spm/common/include/spm_common.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SPM_COMMON_H +#define SPM_COMMON_H + +#include + +/******************************************************************************* + * Constants that allow assembler code to preserve callee-saved registers of the + * C runtime context while performing a security state switch. + ******************************************************************************/ +#define SP_C_RT_CTX_X19 0x0 +#define SP_C_RT_CTX_X20 0x8 +#define SP_C_RT_CTX_X21 0x10 +#define SP_C_RT_CTX_X22 0x18 +#define SP_C_RT_CTX_X23 0x20 +#define SP_C_RT_CTX_X24 0x28 +#define SP_C_RT_CTX_X25 0x30 +#define SP_C_RT_CTX_X26 0x38 +#define SP_C_RT_CTX_X27 0x40 +#define SP_C_RT_CTX_X28 0x48 +#define SP_C_RT_CTX_X29 0x50 +#define SP_C_RT_CTX_X30 0x58 + +#define SP_C_RT_CTX_SIZE 0x60 +#define SP_C_RT_CTX_ENTRIES (SP_C_RT_CTX_SIZE >> DWORD_SHIFT) + +#ifndef __ASSEMBLER__ + +#include + +/* Assembly helpers */ +uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx); +void __dead2 spm_secure_partition_exit(uint64_t c_rt_ctx, uint64_t ret); + +#endif /* __ASSEMBLER__ */ + +#endif /* SPM_COMMON_H */ diff --git a/services/std_svc/spm/common/spm.mk b/services/std_svc/spm/common/spm.mk new file mode 100644 index 000000000..9aa96be3f --- /dev/null +++ b/services/std_svc/spm/common/spm.mk @@ -0,0 +1,17 @@ +# +# Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +ifneq (${ARCH},aarch64) + $(error "Error: SPM is only supported on aarch64.") +endif + +INCLUDES += -Iservices/std_svc/spm/common/include + +SPM_SOURCES := $(addprefix services/std_svc/spm/common/,\ + ${ARCH}/spm_helpers.S) + +# Let the top-level Makefile know that we intend to include a BL32 image +NEED_BL32 := yes diff --git a/services/std_svc/spm_mm/aarch64/spm_mm_shim_exceptions.S b/services/std_svc/spm/spm_mm/aarch64/spm_mm_shim_exceptions.S similarity index 97% rename from services/std_svc/spm_mm/aarch64/spm_mm_shim_exceptions.S rename to services/std_svc/spm/spm_mm/aarch64/spm_mm_shim_exceptions.S index be4084cfb..836f75c8d 100644 --- a/services/std_svc/spm_mm/aarch64/spm_mm_shim_exceptions.S +++ b/services/std_svc/spm/spm_mm/aarch64/spm_mm_shim_exceptions.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/services/std_svc/spm_mm/spm_mm.mk b/services/std_svc/spm/spm_mm/spm_mm.mk similarity index 78% rename from services/std_svc/spm_mm/spm_mm.mk rename to services/std_svc/spm/spm_mm/spm_mm.mk index a87bdd878..78ef0c9fb 100644 --- a/services/std_svc/spm_mm/spm_mm.mk +++ b/services/std_svc/spm/spm_mm/spm_mm.mk @@ -1,5 +1,5 @@ # -# Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -17,11 +17,10 @@ ifeq (${ENABLE_SME_FOR_NS},1) $(error "Error: SPM_MM is not compatible with ENABLE_SME_FOR_NS") endif -SPM_SOURCES := $(addprefix services/std_svc/spm_mm/, \ - ${ARCH}/spm_mm_helpers.S \ +SPM_MM_SOURCES := $(addprefix services/std_svc/spm/spm_mm/, \ ${ARCH}/spm_mm_shim_exceptions.S \ - spm_mm_main.c \ - spm_mm_setup.c \ + spm_mm_main.c \ + spm_mm_setup.c \ spm_mm_xlat.c) diff --git a/services/std_svc/spm_mm/spm_mm_main.c b/services/std_svc/spm/spm_mm/spm_mm_main.c similarity index 99% rename from services/std_svc/spm_mm/spm_mm_main.c rename to services/std_svc/spm/spm_mm/spm_mm_main.c index 14c0038ba..e71e65b18 100644 --- a/services/std_svc/spm_mm/spm_mm_main.c +++ b/services/std_svc/spm/spm_mm/spm_mm_main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -22,6 +22,7 @@ #include #include +#include "spm_common.h" #include "spm_mm_private.h" /******************************************************************************* diff --git a/services/std_svc/spm_mm/spm_mm_private.h b/services/std_svc/spm/spm_mm/spm_mm_private.h similarity index 88% rename from services/std_svc/spm_mm/spm_mm_private.h rename to services/std_svc/spm/spm_mm/spm_mm_private.h index 45b4789ad..0eff1c071 100644 --- a/services/std_svc/spm_mm/spm_mm_private.h +++ b/services/std_svc/spm/spm_mm/spm_mm_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,6 +8,7 @@ #define SPM_MM_PRIVATE_H #include +#include "spm_common.h" /******************************************************************************* * Constants that allow assembler code to preserve callee-saved registers of the @@ -51,9 +52,6 @@ typedef struct sp_context { spinlock_t state_lock; } sp_context_t; -/* Assembly helpers */ -uint64_t spm_secure_partition_enter(uint64_t *c_rt_ctx); -void __dead2 spm_secure_partition_exit(uint64_t c_rt_ctx, uint64_t ret); void spm_sp_setup(sp_context_t *sp_ctx); diff --git a/services/std_svc/spm_mm/spm_mm_setup.c b/services/std_svc/spm/spm_mm/spm_mm_setup.c similarity index 98% rename from services/std_svc/spm_mm/spm_mm_setup.c rename to services/std_svc/spm/spm_mm/spm_mm_setup.c index 9d681c2da..04dc21291 100644 --- a/services/std_svc/spm_mm/spm_mm_setup.c +++ b/services/std_svc/spm/spm_mm/spm_mm_setup.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2021, NVIDIA Corporation. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -19,6 +19,7 @@ #include #include +#include "spm_common.h" #include "spm_mm_private.h" #include "spm_mm_shim_private.h" diff --git a/services/std_svc/spm_mm/spm_mm_shim_private.h b/services/std_svc/spm/spm_mm/spm_mm_shim_private.h similarity index 90% rename from services/std_svc/spm_mm/spm_mm_shim_private.h rename to services/std_svc/spm/spm_mm/spm_mm_shim_private.h index 0c8d894f1..f69c748ad 100644 --- a/services/std_svc/spm_mm/spm_mm_shim_private.h +++ b/services/std_svc/spm/spm_mm/spm_mm_shim_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ diff --git a/services/std_svc/spm_mm/spm_mm_xlat.c b/services/std_svc/spm/spm_mm/spm_mm_xlat.c similarity index 98% rename from services/std_svc/spm_mm/spm_mm_xlat.c rename to services/std_svc/spm/spm_mm/spm_mm_xlat.c index eae597cab..6261016f7 100644 --- a/services/std_svc/spm_mm/spm_mm_xlat.c +++ b/services/std_svc/spm/spm_mm/spm_mm_xlat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */