From 0560efb93eeba9cf16dc837893a07430e638dcc5 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Sat, 29 Dec 2018 19:43:21 +0100 Subject: services/spm_deprecated: update ARM platform specific asserts Update some asserts that refer to #defines that only occur in ARM platforms, preventing this code to be used on other platforms. Instead, use a platform agnostic name, and update all the existing users. Signed-off-by: Ard Biesheuvel --- services/std_svc/spm_deprecated/spm_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/std_svc/spm_deprecated/spm_setup.c b/services/std_svc/spm_deprecated/spm_setup.c index d458f4a6..e78a42c7 100644 --- a/services/std_svc/spm_deprecated/spm_setup.c +++ b/services/std_svc/spm_deprecated/spm_setup.c @@ -84,10 +84,10 @@ void spm_sp_setup(sp_context_t *sp_ctx) unsigned int max_granule_mask = max_granule - 1U; /* Base must be aligned to the max granularity */ - assert((ARM_SP_IMAGE_NS_BUF_BASE & max_granule_mask) == 0); + assert((PLAT_SP_IMAGE_NS_BUF_BASE & max_granule_mask) == 0); /* Size must be a multiple of the max granularity */ - assert((ARM_SP_IMAGE_NS_BUF_SIZE & max_granule_mask) == 0); + assert((PLAT_SP_IMAGE_NS_BUF_SIZE & max_granule_mask) == 0); #endif /* ENABLE_ASSERTIONS */ -- cgit v1.2.3 From c024ea6cd2b18487629dfc38707615bedd42901c Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 1 Jan 2019 11:01:41 +0100 Subject: services/spm_deprecated: permit timer sysreg access at S-EL0 Expose the timer registers that are accessible at EL0 per the architecture to the SPM payload running in secure EL0. Note that this requires NS_TIMER_SWITCH to be enable for all users of this code. Signed-off-by: Ard Biesheuvel --- services/std_svc/spm_deprecated/spm.mk | 3 +++ services/std_svc/spm_deprecated/spm_setup.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'services') diff --git a/services/std_svc/spm_deprecated/spm.mk b/services/std_svc/spm_deprecated/spm.mk index ed36812f..35030206 100644 --- a/services/std_svc/spm_deprecated/spm.mk +++ b/services/std_svc/spm_deprecated/spm.mk @@ -21,3 +21,6 @@ SPM_SOURCES := $(addprefix services/std_svc/spm_deprecated/, \ # Let the top-level Makefile know that we intend to include a BL32 image NEED_BL32 := yes + +# required so that SPM code executing at S-EL0 can access the timer registers +NS_TIMER_SWITCH := 1 diff --git a/services/std_svc/spm_deprecated/spm_setup.c b/services/std_svc/spm_deprecated/spm_setup.c index e78a42c7..beaff946 100644 --- a/services/std_svc/spm_deprecated/spm_setup.c +++ b/services/std_svc/spm_deprecated/spm_setup.c @@ -168,6 +168,9 @@ void spm_sp_setup(sp_context_t *sp_ctx) write_ctx_reg(get_sysregs_ctx(ctx), CTX_VBAR_EL1, SPM_SHIM_EXCEPTIONS_PTR); + write_ctx_reg(get_sysregs_ctx(ctx), CTX_CNTKCTL_EL1, + EL0PTEN_BIT | EL0VTEN_BIT | EL0PCTEN_BIT | EL0VCTEN_BIT); + /* * FPEN: Allow the Secure Partition to access FP/SIMD registers. * Note that SPM will not do any saving/restoring of these registers on -- cgit v1.2.3 From 021318dffb551a0222c0eb5fc23f2d04b8e601ac Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 3 Jan 2019 12:03:49 +0100 Subject: services/spm_deprecated: disable alignment checking for S-EL0 Permit unaligned accesses while executing the secure partition payload, so that we don't have to modify existing code that we will host there. (The UEFI spec explicitly permits unaligned accesses) Signed-off-by: Ard Biesheuvel --- services/std_svc/spm_deprecated/spm_setup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'services') diff --git a/services/std_svc/spm_deprecated/spm_setup.c b/services/std_svc/spm_deprecated/spm_setup.c index beaff946..aae6cd5e 100644 --- a/services/std_svc/spm_deprecated/spm_setup.c +++ b/services/std_svc/spm_deprecated/spm_setup.c @@ -144,8 +144,6 @@ void spm_sp_setup(sp_context_t *sp_ctx) SCTLR_SA0_BIT | /* Allow cacheable data and instr. accesses to normal memory. */ SCTLR_C_BIT | SCTLR_I_BIT | - /* Alignment fault checking enabled when at EL1 and EL0. */ - SCTLR_A_BIT | /* Enable MMU. */ SCTLR_M_BIT ; @@ -153,6 +151,11 @@ void spm_sp_setup(sp_context_t *sp_ctx) sctlr_el1 &= ~( /* Explicit data accesses at EL0 are little-endian. */ SCTLR_E0E_BIT | + /* + * Alignment fault checking disabled when at EL1 and EL0 as + * the UEFI spec permits unaligned accesses. + */ + SCTLR_A_BIT | /* Accesses to DAIF from EL0 are trapped to EL1. */ SCTLR_UMA_BIT ); -- cgit v1.2.3 From 0e4f761bc44346d0c08a8b272f148899198be825 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 1 Jan 2019 11:03:08 +0100 Subject: services/spm_deprecated: fix return code polarity of spm_init() Registered init handlers return a boolean int, not a return code, so convert the result from the SPM init call before returning it. Signed-off-by: Ard Biesheuvel --- services/std_svc/spm_deprecated/spm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'services') diff --git a/services/std_svc/spm_deprecated/spm_main.c b/services/std_svc/spm_deprecated/spm_main.c index 540f257b..7525763b 100644 --- a/services/std_svc/spm_deprecated/spm_main.c +++ b/services/std_svc/spm_deprecated/spm_main.c @@ -151,7 +151,7 @@ static int32_t spm_init(void) INFO("Secure Partition initialized.\n"); - return rc; + return !rc; } /******************************************************************************* -- cgit v1.2.3