Skip to content

Commit

Permalink
core: allow Secure Partition TAs to access frequency timers
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
FulcronZ authored and apalos committed Jul 15, 2020
1 parent 305a152 commit e16252a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/arch/arm/kernel/secure_partition.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,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);
Expand Down
8 changes: 8 additions & 0 deletions core/arch/arm/kernel/thread_a64.S
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ FUNC thread_init_vbar , :
END_FUNC thread_init_vbar
DECLARE_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,
Expand Down
6 changes: 6 additions & 0 deletions core/arch/arm/kernel/thread_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit e16252a

Please sign in to comment.