aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPipat Methavanitpong <pipat.methavanitpong@linaro.org>2020-02-03 15:42:09 +0900
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2020-04-29 12:07:58 +0300
commit1184cfabe0f79c358c51d727c580e32ad5e604f4 (patch)
treea141e55ecdda02ab9479c29a94a295168593e490
parent7672d1b17f97fff1a2d70bded4c5bc11d928ccd3 (diff)
core: allow Secure Partition TAs to access frequency timersstmm_upstream_03_clean
Standalone MM, a Secure Partition TA, requires access to a timer. This makes SPM disabling frequency timer access trap on entering SP TA. Signed-off-by: Pipat Methavanitpong <pipat.methavanitpong@linaro.org>
-rw-r--r--core/arch/arm/kernel/secure_partition.c4
-rw-r--r--core/arch/arm/kernel/thread_a64.S8
-rw-r--r--core/arch/arm/kernel/thread_private.h6
3 files changed, 18 insertions, 0 deletions
diff --git a/core/arch/arm/kernel/secure_partition.c b/core/arch/arm/kernel/secure_partition.c
index 9d097667..084a49c3 100644
--- a/core/arch/arm/kernel/secure_partition.c
+++ b/core/arch/arm/kernel/secure_partition.c
@@ -72,9 +72,13 @@ static TEE_Result sec_part_enter_user_mode(struct sec_part_ctx *spc)
uint32_t exceptions = 0;
uint32_t panic_code = 0;
uint32_t panicked = 0;
+ uint64_t cntkctl;
exceptions = thread_mask_exceptions(THREAD_EXCP_ALL);
+ cntkctl = thread_get_cntkctl_el1();
+ thread_set_cntkctl_el1(cntkctl | 0x3);
__thread_enter_user_mode(&spc->regs, &panicked, &panic_code);
+ thread_set_cntkctl_el1(cntkctl);
thread_unmask_exceptions(exceptions);
clear_vfp_state(spc);
diff --git a/core/arch/arm/kernel/thread_a64.S b/core/arch/arm/kernel/thread_a64.S
index f1570693..bdedda9e 100644
--- a/core/arch/arm/kernel/thread_a64.S
+++ b/core/arch/arm/kernel/thread_a64.S
@@ -69,6 +69,14 @@ FUNC thread_init_vbar , :
END_FUNC thread_init_vbar
KEEP_PAGER thread_init_vbar
+FUNC thread_get_cntkctl_el1 , :
+ mrs x0, CNTKCTL_EL1
+ ret
+
+FUNC thread_set_cntkctl_el1 , :
+ msr CNTKCTL_EL1, x0
+ ret
+
/*
* uint32_t __thread_enter_user_mode(struct thread_ctx_regs *regs,
* uint32_t *exit_status0,
diff --git a/core/arch/arm/kernel/thread_private.h b/core/arch/arm/kernel/thread_private.h
index ed35e6e7..c409eb01 100644
--- a/core/arch/arm/kernel/thread_private.h
+++ b/core/arch/arm/kernel/thread_private.h
@@ -176,6 +176,12 @@ void thread_set_irq_sp(vaddr_t sp);
void thread_set_fiq_sp(vaddr_t sp);
#endif /*ARM32*/
+/* Returns EL0 timer access permission */
+uint64_t thread_get_cntkctl_el1(void);
+
+/* Sets EL0 timer access permission */
+void thread_set_cntkctl_el1(uint64_t val);
+
/* Checks stack canaries */
void thread_check_canaries(void);