Skip to content

Commit

Permalink
Disable IRQ and FIQ in IRQ/ABT/SVC/UND thread handlers for arm32
Browse files Browse the repository at this point in the history
Disable native and foreign interrupts in thread handlers for arm32.
The tee handlers can decide when the native interrupts can be enabled.

Signed-off-by: David Wang <david.wang@arm.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
  • Loading branch information
David Wang committed Aug 25, 2017
1 parent 2fcf4ea commit cc1a3f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/arch/arm/kernel/thread_a32.S
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ LOCAL_FUNC thread_abort_handler , :
thread_und_handler:
UNWIND( .fnstart)
UNWIND( .cantunwind)
/*
* Disable both foreign and native interrupts in the thread handlers.
* The tee handlers can decide when the native interrupts should
* be enabled.
*/
cpsid f /* IRQ is already masked by the hardware */
strd r0, r1, [sp, #THREAD_CORE_LOCAL_R0]
mrs r1, spsr
tst r1, #CPSR_T
Expand All @@ -671,12 +677,24 @@ UNWIND( .cantunwind)
b .thread_abort_generic

thread_dabort_handler:
/*
* Disable both foreign and native interrupts in the thread handlers.
* The tee handlers can decide when the native interrupts should
* be enabled.
*/
cpsid f /* IRQ is already masked by the hardware */
strd r0, r1, [sp, #THREAD_CORE_LOCAL_R0]
sub lr, lr, #8
mov r0, #ABORT_TYPE_DATA
b .thread_abort_generic

thread_pabort_handler:
/*
* Disable both foreign and native interrupts in the thread handlers.
* The tee handlers can decide when the native interrupts should
* be enabled.
*/
cpsid f /* IRQ is already masked by the hardware */
strd r0, r1, [sp, #THREAD_CORE_LOCAL_R0]
sub lr, lr, #4
mov r0, #ABORT_TYPE_PREFETCH
Expand Down Expand Up @@ -771,6 +789,12 @@ END_FUNC thread_abort_handler
LOCAL_FUNC thread_svc_handler , :
UNWIND( .fnstart)
UNWIND( .cantunwind)
/*
* Disable both foreign and native interrupts in the thread handlers.
* The tee handlers can decide when the native interrupts should
* be enabled.
*/
cpsid f /* IRQ is already masked by the hardware */
push {r0-r7, lr}
mrs r0, spsr
push {r0}
Expand Down
5 changes: 5 additions & 0 deletions core/arch/arm/tee/arch_svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,15 @@ void __weak tee_svc_handler(struct thread_svc_regs *regs)
size_t scn;
size_t max_args;
syscall_t scf;
uint32_t state;

COMPILE_TIME_ASSERT(ARRAY_SIZE(tee_svc_syscall_table) ==
(TEE_SCN_MAX + 1));

/* Enable native interupts */
state = thread_get_exceptions();
thread_unmask_exceptions(state & ~THREAD_EXCP_NATIVE_INTR);

thread_user_save_vfp();

/* TA has just entered kernel mode */
Expand Down

0 comments on commit cc1a3f8

Please sign in to comment.