summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Wang <david.wang@arm.com>2016-12-12 16:06:17 +0800
committerDavid Wang <david.wang@arm.com>2017-02-28 15:59:37 +0800
commit5acb1bc6e8ece254ffe7dbdc41605ad5613b6ab7 (patch)
tree0fb79682fc8744ef2f2a0e326c48e2deb2f83186
parent849b17bd15c53480b42dacedeb00fdfdf0854064 (diff)
Rename the secure and non-secure interrupts
Currently, the secure interrupts are named as FIQ and the non-secure interrupts are named as IRQ. In GICv3 mode, the FIQ and IRQ have different definitions. * Secure Group 0 interrupts: Handled by EL3 and triggered by FIQ when running at Secure EL0/1. * Secure Group 1 interrupts: Handled by optee_os and triggered by IRQ when running at Secure EL0/1. * Non-secure Group1 interrupts: Handled by the rich os and triggered by FIQ when running at Secure EL0/1. The "Secure Group 1" interrupts are the "native" interrupts handled by optee_os. They are same as the "secure" interrupts used in optee_os for now. But they are triggered by FIQ in GICv2 mode while by IRQ in GICv3 mode. The "Secure Group 0" and "Non-secure Group1" interrupts are the "foreign" interrupts that will cause the exiting of optee_os. (e.g. switch back to normal world) The "Non-secure Group1" interrupts are same as the "non-secure"interrupts used in optee_os for now. But they are triggered by IRQ in GICv2 mode while by FIQ in GICv3 mode. This patch renames these interrupts to the generic names - "Foreign interrupts" and "Native interrupts". For the support of GICv3 mode in the future, we can redefine the macros of "native interrupt" and "foreign interrupt" to IRQ and FIQ. Signed-off-by: David Wang <david.wang@arm.com> Reviewed-by: Joakim Bech <joakim.bech@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Tested-by: Etienne Carriere <etienne.carriere@linaro.org> (b2260)
-rw-r--r--core/arch/arm/include/kernel/spinlock.h6
-rw-r--r--core/arch/arm/include/kernel/thread.h64
-rw-r--r--core/arch/arm/include/kernel/thread_defs.h4
-rw-r--r--core/arch/arm/include/sm/optee_smc.h12
-rw-r--r--core/arch/arm/kernel/generic_boot.c6
-rw-r--r--core/arch/arm/kernel/spin_lock_debug.c5
-rw-r--r--core/arch/arm/kernel/thread.c91
-rw-r--r--core/arch/arm/kernel/thread_a32.S8
-rw-r--r--core/arch/arm/kernel/thread_a64.S14
-rw-r--r--core/arch/arm/mm/core_mmu.c2
-rw-r--r--core/arch/arm/plat-d02/main.c2
-rw-r--r--core/arch/arm/plat-hikey/main.c2
-rw-r--r--core/arch/arm/plat-imx/main.c2
-rw-r--r--core/arch/arm/plat-ls/main.c2
-rw-r--r--core/arch/arm/plat-mediatek/main.c2
-rw-r--r--core/arch/arm/plat-rcar/main.c2
-rw-r--r--core/arch/arm/plat-rpi3/main.c2
-rw-r--r--core/arch/arm/plat-sprd/main.c2
-rw-r--r--core/arch/arm/plat-stm/main.c2
-rw-r--r--core/arch/arm/plat-sunxi/main.c11
-rw-r--r--core/arch/arm/plat-ti/main.c2
-rw-r--r--core/arch/arm/plat-vexpress/main.c2
-rw-r--r--core/arch/arm/plat-zynq7k/main.c2
-rw-r--r--core/arch/arm/plat-zynqmp/main.c2
-rw-r--r--core/arch/arm/pta/interrupt_tests.c2
-rw-r--r--core/arch/arm/tee/arch_svc.c4
-rw-r--r--core/arch/arm/tee/entry_std.c3
-rw-r--r--documentation/interrupt_handling.md14
-rw-r--r--documentation/optee_design.md31
-rw-r--r--lib/libutils/isoc/bget_malloc.c3
30 files changed, 169 insertions, 137 deletions
diff --git a/core/arch/arm/include/kernel/spinlock.h b/core/arch/arm/include/kernel/spinlock.h
index c2486737..a19b764a 100644
--- a/core/arch/arm/include/kernel/spinlock.h
+++ b/core/arch/arm/include/kernel/spinlock.h
@@ -59,7 +59,7 @@ unsigned int __cpu_spin_trylock(unsigned int *lock);
static inline void cpu_spin_lock(unsigned int *lock)
{
- assert(thread_irq_disabled());
+ assert(thread_foreign_intr_disabled());
__cpu_spin_lock(lock);
spinlock_count_incr();
}
@@ -68,7 +68,7 @@ static inline bool cpu_spin_trylock(unsigned int *lock)
{
unsigned int rc;
- assert(thread_irq_disabled());
+ assert(thread_foreign_intr_disabled());
rc = __cpu_spin_trylock(lock);
if (!rc)
spinlock_count_incr();
@@ -77,7 +77,7 @@ static inline bool cpu_spin_trylock(unsigned int *lock)
static inline void cpu_spin_unlock(unsigned int *lock)
{
- assert(thread_irq_disabled());
+ assert(thread_foreign_intr_disabled());
__cpu_spin_unlock(lock);
spinlock_count_decr();
}
diff --git a/core/arch/arm/include/kernel/thread.h b/core/arch/arm/include/kernel/thread.h
index 175ba77f..831b5d68 100644
--- a/core/arch/arm/include/kernel/thread.h
+++ b/core/arch/arm/include/kernel/thread.h
@@ -30,6 +30,7 @@
#define KERNEL_THREAD_H
#ifndef ASM
+#include <arm.h>
#include <types_ext.h>
#include <compiler.h>
#include <optee_msg.h>
@@ -203,7 +204,7 @@ struct thread_svc_regs {
#ifndef ASM
typedef void (*thread_smc_handler_t)(struct thread_smc_args *args);
-typedef void (*thread_fiq_handler_t)(void);
+typedef void (*thread_nintr_handler_t)(void);
typedef unsigned long (*thread_pm_handler_t)(unsigned long a0,
unsigned long a1);
struct thread_handlers {
@@ -218,11 +219,12 @@ struct thread_handlers {
*
* fastcall handles fast calls which can't be preemted. This
* handler is executed with a limited stack. This handler must not
- * cause any aborts or reenenable FIQs which are temporarily masked
- * while executing this handler.
+ * cause any aborts or reenenable native interrupts which are
+ * temporarily masked while executing this handler.
*
- * TODO investigate if we should execute fastcalls and FIQs on
- * different stacks allowing FIQs to be enabled during a fastcall.
+ * TODO investigate if we should execute fastcalls and native interrupts
+ * on different stacks allowing native interrupts to be enabled during
+ * a fastcall.
*/
thread_smc_handler_t std_smc;
thread_smc_handler_t fast_smc;
@@ -231,12 +233,12 @@ struct thread_handlers {
* fiq is called as a regular function and normal ARM Calling
* Convention applies.
*
- * This handler handles FIQs which can't be preemted. This handler
- * is executed with a limited stack. This handler must not cause
- * any aborts or reenenable FIQs which are temporarily masked while
- * executing this handler.
+ * This handler handles native interrupts which can't be preemted. This
+ * handler is executed with a limited stack. This handler must not cause
+ * any aborts or reenenable native interrupts which are temporarily
+ * masked while executing this handler.
*/
- thread_fiq_handler_t fiq;
+ thread_nintr_handler_t nintr;
/*
* Power management handlers triggered from ARM Trusted Firmware.
@@ -285,28 +287,30 @@ int thread_get_id_may_fail(void);
struct thread_specific_data *thread_get_tsd(void);
/*
- * Sets IRQ status for current thread, must only be called from an
- * active thread context.
+ * Sets foreign interrupts status for current thread, must only be called
+ * from an active thread context.
*
- * enable == true -> enable IRQ
- * enable == false -> disable IRQ
+ * enable == true -> enable foreign interrupts
+ * enable == false -> disable foreign interrupts
*/
-void thread_set_irq(bool enable);
+void thread_set_foreign_intr(bool enable);
/*
- * Restores the IRQ status (in CPSR) for current thread, must only be called
- * from an active thread context.
+ * Restores the foreign interrupts status (in CPSR) for current thread, must
+ * only be called from an active thread context.
*/
-void thread_restore_irq(void);
+void thread_restore_foreign_intr(void);
/*
* Defines the bits for the exception mask used the the
* thread_*_exceptions() functions below.
+ * These definitions are compatible with both ARM32 and ARM64.
*/
-#define THREAD_EXCP_FIQ (1 << 0)
-#define THREAD_EXCP_IRQ (1 << 1)
-#define THREAD_EXCP_ABT (1 << 2)
-#define THREAD_EXCP_ALL (THREAD_EXCP_FIQ | THREAD_EXCP_IRQ | THREAD_EXCP_ABT)
+#define THREAD_EXCP_FOREIGN_INTR (ARM32_CPSR_I >> ARM32_CPSR_F_SHIFT)
+#define THREAD_EXCP_NATIVE_INTR (ARM32_CPSR_F >> ARM32_CPSR_F_SHIFT)
+#define THREAD_EXCP_ALL (THREAD_EXCP_FOREIGN_INTR \
+ | THREAD_EXCP_NATIVE_INTR \
+ | (ARM32_CPSR_A >> ARM32_CPSR_F_SHIFT))
/*
* thread_get_exceptions() - return current exception mask
@@ -337,18 +341,18 @@ uint32_t thread_mask_exceptions(uint32_t exceptions);
void thread_unmask_exceptions(uint32_t state);
-static inline bool thread_irq_disabled(void)
+static inline bool thread_foreign_intr_disabled(void)
{
- return !!(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ return !!(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
}
#ifdef CFG_WITH_VFP
/*
* thread_kernel_enable_vfp() - Temporarily enables usage of VFP
*
- * IRQ is masked while VFP is enabled. User space must not be entered before
- * thread_kernel_disable_vfp() has been called to disable VFP and restore the
- * IRQ status.
+ * Foreign interrupts are masked while VFP is enabled. User space must not be
+ * entered before thread_kernel_disable_vfp() has been called to disable VFP
+ * and restore the foreign interrupt status.
*
* This function may only be called from an active thread context and may
* not be called again before thread_kernel_disable_vfp() has been called.
@@ -364,7 +368,7 @@ uint32_t thread_kernel_enable_vfp(void);
* thread_kernel_disable_vfp() - Disables usage of VFP
* @state: state variable returned by thread_kernel_enable_vfp()
*
- * Disables usage of VFP and restores IRQ status after a call to
+ * Disables usage of VFP and restores foreign interrupt status after a call to
* thread_kernel_enable_vfp().
*
* This function may only be called after a call to
@@ -484,13 +488,13 @@ bool thread_addr_is_in_stack(vaddr_t va);
/*
* Adds a mutex to the list of held mutexes for current thread
- * Requires IRQs to be disabled.
+ * Requires foreign interrupts to be disabled.
*/
void thread_add_mutex(struct mutex *m);
/*
* Removes a mutex from the list of held mutexes for current thread
- * Requires IRQs to be disabled.
+ * Requires foreign interrupts to be disabled.
*/
void thread_rem_mutex(struct mutex *m);
diff --git a/core/arch/arm/include/kernel/thread_defs.h b/core/arch/arm/include/kernel/thread_defs.h
index 0f54569c..e0818952 100644
--- a/core/arch/arm/include/kernel/thread_defs.h
+++ b/core/arch/arm/include/kernel/thread_defs.h
@@ -29,7 +29,7 @@
#define KERNEL_THREAD_DEFS_H
#define THREAD_FLAGS_COPY_ARGS_ON_RETURN (1 << 0)
-#define THREAD_FLAGS_IRQ_ENABLE (1 << 1)
-#define THREAD_FLAGS_EXIT_ON_IRQ (1 << 2)
+#define THREAD_FLAGS_FOREIGN_INTR_ENABLE (1 << 1)
+#define THREAD_FLAGS_EXIT_ON_FOREIGN_INTR (1 << 2)
#endif /*KERNEL_THREAD_DEFS_H*/
diff --git a/core/arch/arm/include/sm/optee_smc.h b/core/arch/arm/include/sm/optee_smc.h
index b6fcd652..c3697083 100644
--- a/core/arch/arm/include/sm/optee_smc.h
+++ b/core/arch/arm/include/sm/optee_smc.h
@@ -385,7 +385,7 @@
OPTEE_SMC_FAST_CALL_VAL(OPTEE_SMC_FUNCID_BOOT_SECONDARY)
/*
- * Resume from RPC (for example after processing an IRQ)
+ * Resume from RPC (for example after processing a foreign interrupt)
*
* Call register usage:
* a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC
@@ -470,19 +470,19 @@
OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FREE)
/*
- * Deliver an IRQ in normal world.
+ * Deliver a foreign interrupt in normal world.
*
* "Call" register usage:
- * a0 OPTEE_SMC_RETURN_RPC_IRQ
+ * a0 OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
* a1-7 Resume information, must be preserved
*
* "Return" register usage:
* a0 SMC Function ID, OPTEE_SMC_CALL_RETURN_FROM_RPC.
* a1-7 Preserved
*/
-#define OPTEE_SMC_RPC_FUNC_IRQ 4
-#define OPTEE_SMC_RETURN_RPC_IRQ \
- OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_IRQ)
+#define OPTEE_SMC_RPC_FUNC_FOREIGN_INTR 4
+#define OPTEE_SMC_RETURN_RPC_FOREIGN_INTR \
+ OPTEE_SMC_RPC_VAL(OPTEE_SMC_RPC_FUNC_FOREIGN_INTR)
/*
* Do an RPC request. The supplied struct optee_msg_arg tells which
diff --git a/core/arch/arm/kernel/generic_boot.c b/core/arch/arm/kernel/generic_boot.c
index 8f13c36a..f2ae6015 100644
--- a/core/arch/arm/kernel/generic_boot.c
+++ b/core/arch/arm/kernel/generic_boot.c
@@ -607,7 +607,8 @@ static void init_primary_helper(unsigned long pageable_part,
* Mask asynchronous exceptions before switch to the thread vector
* as the thread handler requires those to be masked while
* executing with the temporary stack. The thread subsystem also
- * asserts that IRQ is blocked when using most if its functions.
+ * asserts that the foreign interrupts are blocked when using most of
+ * its functions.
*/
thread_set_exceptions(THREAD_EXCP_ALL);
init_vfp_sec();
@@ -634,7 +635,8 @@ static void init_secondary_helper(unsigned long nsec_entry)
* Mask asynchronous exceptions before switch to the thread vector
* as the thread handler requires those to be masked while
* executing with the temporary stack. The thread subsystem also
- * asserts that IRQ is blocked when using most if its functions.
+ * asserts that the foreign interrupts are blocked when using most of
+ * its functions.
*/
thread_set_exceptions(THREAD_EXCP_ALL);
diff --git a/core/arch/arm/kernel/spin_lock_debug.c b/core/arch/arm/kernel/spin_lock_debug.c
index 2a450a5f..00a2a004 100644
--- a/core/arch/arm/kernel/spin_lock_debug.c
+++ b/core/arch/arm/kernel/spin_lock_debug.c
@@ -49,10 +49,11 @@ bool have_spinlock(void)
{
struct thread_core_local *l;
- if (!thread_irq_disabled()) {
+ if (!thread_foreign_intr_disabled()) {
/*
* Normally we can't be holding a spinlock since doing so would
- * imply IRQ are disabled (or the spinlock logic is flawed).
+ * imply foreign interrupts are disabled (or the spinlock
+ * logic is flawed).
*/
return false;
}
diff --git a/core/arch/arm/kernel/thread.c b/core/arch/arm/kernel/thread.c
index c988b654..a13598c1 100644
--- a/core/arch/arm/kernel/thread.c
+++ b/core/arch/arm/kernel/thread.c
@@ -140,7 +140,7 @@ KEEP_PAGER(stack_tmp_offset);
thread_smc_handler_t thread_std_smc_handler_ptr;
static thread_smc_handler_t thread_fast_smc_handler_ptr;
-thread_fiq_handler_t thread_fiq_handler_ptr;
+thread_nintr_handler_t thread_nintr_handler_ptr;
thread_pm_handler_t thread_cpu_on_handler_ptr;
thread_pm_handler_t thread_cpu_off_handler_ptr;
thread_pm_handler_t thread_cpu_suspend_handler_ptr;
@@ -234,8 +234,8 @@ void thread_set_exceptions(uint32_t exceptions)
{
uint32_t cpsr = read_cpsr();
- /* IRQ must not be unmasked while holding a spinlock */
- if (!(exceptions & THREAD_EXCP_IRQ))
+ /* Foreign interrupts must not be unmasked while holding a spinlock */
+ if (!(exceptions & THREAD_EXCP_FOREIGN_INTR))
assert_have_no_spinlock();
cpsr &= ~(THREAD_EXCP_ALL << CPSR_F_SHIFT);
@@ -256,8 +256,8 @@ void thread_set_exceptions(uint32_t exceptions)
{
uint32_t daif = read_daif();
- /* IRQ must not be unmasked while holding a spinlock */
- if (!(exceptions & THREAD_EXCP_IRQ))
+ /* Foreign interrupts must not be unmasked while holding a spinlock */
+ if (!(exceptions & THREAD_EXCP_FOREIGN_INTR))
assert_have_no_spinlock();
daif &= ~(THREAD_EXCP_ALL << DAIF_F_SHIFT);
@@ -285,11 +285,11 @@ struct thread_core_local *thread_get_core_local(void)
uint32_t cpu_id = get_core_pos();
/*
- * IRQs must be disabled before playing with core_local since
- * we otherwise may be rescheduled to a different core in the
+ * Foreign interrupts must be disabled before playing with core_local
+ * since we otherwise may be rescheduled to a different core in the
* middle of this function.
*/
- assert(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
assert(cpu_id < CFG_TEE_CORE_NB_CORE);
return &thread_core_local[cpu_id];
@@ -338,11 +338,12 @@ static void init_regs(struct thread_ctx *thread,
thread->regs.pc = (uint32_t)thread_std_smc_entry;
/*
- * Stdcalls starts in SVC mode with masked IRQ, masked Asynchronous
- * abort and unmasked FIQ.
- */
+ * Stdcalls starts in SVC mode with masked foreign interrupts, masked
+ * Asynchronous abort and unmasked native interrupts.
+ */
thread->regs.cpsr = read_cpsr() & ARM32_CPSR_E;
- thread->regs.cpsr |= CPSR_MODE_SVC | CPSR_I | CPSR_A;
+ thread->regs.cpsr |= CPSR_MODE_SVC | CPSR_A |
+ (THREAD_EXCP_FOREIGN_INTR << ARM32_CPSR_F_SHIFT);
/* Enable thumb mode if it's a thumb instruction */
if (thread->regs.pc & 1)
thread->regs.cpsr |= CPSR_T;
@@ -371,11 +372,11 @@ static void init_regs(struct thread_ctx *thread,
thread->regs.pc = (uint64_t)thread_std_smc_entry;
/*
- * Stdcalls starts in SVC mode with masked IRQ, masked Asynchronous
- * abort and unmasked FIQ.
- */
+ * Stdcalls starts in SVC mode with masked foreign interrupts, masked
+ * Asynchronous abort and unmasked native interrupts.
+ */
thread->regs.cpsr = SPSR_64(SPSR_64_MODE_EL1, SPSR_64_MODE_SP_EL0,
- DAIFBIT_IRQ | DAIFBIT_ABT);
+ THREAD_EXCP_FOREIGN_INTR | DAIFBIT_ABT);
/* Reinitialize stack pointer */
thread->regs.sp = thread->stack_va_end;
@@ -556,7 +557,7 @@ static void thread_resume_from_rpc(struct thread_smc_args *args)
core_mmu_set_user_map(&threads[n].user_map);
/*
- * Return from RPC to request service of an IRQ must not
+ * Return from RPC to request service of a foreign interrupt must not
* get parameters from non-secure world.
*/
if (threads[n].flags & THREAD_FLAGS_COPY_ARGS_ON_RETURN) {
@@ -769,8 +770,10 @@ bool thread_init_stack(uint32_t thread_id, vaddr_t sp)
int thread_get_id_may_fail(void)
{
- /* thread_get_core_local() requires IRQs to be disabled */
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ /*
+ * thread_get_core_local() requires foreign interrupts to be disabled
+ */
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
struct thread_core_local *l = thread_get_core_local();
int ct = l->curr_thread;
@@ -790,7 +793,7 @@ static void init_handlers(const struct thread_handlers *handlers)
{
thread_std_smc_handler_ptr = handlers->std_smc;
thread_fast_smc_handler_ptr = handlers->fast_smc;
- thread_fiq_handler_ptr = handlers->fiq;
+ thread_nintr_handler_ptr = handlers->nintr;
thread_cpu_on_handler_ptr = handlers->cpu_on;
thread_cpu_off_handler_ptr = handlers->cpu_off;
thread_cpu_suspend_handler_ptr = handlers->cpu_suspend;
@@ -890,10 +893,10 @@ struct thread_ctx_regs *thread_get_ctx_regs(void)
return &threads[l->curr_thread].regs;
}
-void thread_set_irq(bool enable)
+void thread_set_foreign_intr(bool enable)
{
- /* thread_get_core_local() requires IRQs to be disabled */
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ /* thread_get_core_local() requires foreign interrupts to be disabled */
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
struct thread_core_local *l;
l = thread_get_core_local();
@@ -901,35 +904,37 @@ void thread_set_irq(bool enable)
assert(l->curr_thread != -1);
if (enable) {
- threads[l->curr_thread].flags |= THREAD_FLAGS_IRQ_ENABLE;
- thread_set_exceptions(exceptions & ~THREAD_EXCP_IRQ);
+ threads[l->curr_thread].flags |=
+ THREAD_FLAGS_FOREIGN_INTR_ENABLE;
+ thread_set_exceptions(exceptions & ~THREAD_EXCP_FOREIGN_INTR);
} else {
/*
- * No need to disable IRQ here since it's already disabled
- * above.
+ * No need to disable foreign interrupts here since they're
+ * already disabled above.
*/
- threads[l->curr_thread].flags &= ~THREAD_FLAGS_IRQ_ENABLE;
+ threads[l->curr_thread].flags &=
+ ~THREAD_FLAGS_FOREIGN_INTR_ENABLE;
}
}
-void thread_restore_irq(void)
+void thread_restore_foreign_intr(void)
{
- /* thread_get_core_local() requires IRQs to be disabled */
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ /* thread_get_core_local() requires foreign interrupts to be disabled */
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
struct thread_core_local *l;
l = thread_get_core_local();
assert(l->curr_thread != -1);
- if (threads[l->curr_thread].flags & THREAD_FLAGS_IRQ_ENABLE)
- thread_set_exceptions(exceptions & ~THREAD_EXCP_IRQ);
+ if (threads[l->curr_thread].flags & THREAD_FLAGS_FOREIGN_INTR_ENABLE)
+ thread_set_exceptions(exceptions & ~THREAD_EXCP_FOREIGN_INTR);
}
#ifdef CFG_WITH_VFP
uint32_t thread_kernel_enable_vfp(void)
{
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
struct thread_ctx *thr = threads + thread_get_id();
struct thread_user_vfp_state *tuv = thr->vfp_state.uvfp;
@@ -967,9 +972,9 @@ void thread_kernel_disable_vfp(uint32_t state)
vfp_disable();
exceptions = thread_get_exceptions();
- assert(exceptions & THREAD_EXCP_IRQ);
- exceptions &= ~THREAD_EXCP_IRQ;
- exceptions |= state & THREAD_EXCP_IRQ;
+ assert(exceptions & THREAD_EXCP_FOREIGN_INTR);
+ exceptions &= ~THREAD_EXCP_FOREIGN_INTR;
+ exceptions |= state & THREAD_EXCP_FOREIGN_INTR;
thread_set_exceptions(exceptions);
}
@@ -977,7 +982,7 @@ void thread_kernel_save_vfp(void)
{
struct thread_ctx *thr = threads + thread_get_id();
- assert(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
if (vfp_is_enabled()) {
vfp_lazy_save_state_init(&thr->vfp_state.sec);
thr->vfp_state.sec_lazy_saved = true;
@@ -988,7 +993,7 @@ void thread_kernel_restore_vfp(void)
{
struct thread_ctx *thr = threads + thread_get_id();
- assert(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
assert(!vfp_is_enabled());
if (thr->vfp_state.sec_lazy_saved) {
vfp_lazy_restore_state(&thr->vfp_state.sec,
@@ -1003,7 +1008,7 @@ void thread_user_enable_vfp(struct thread_user_vfp_state *uvfp)
struct thread_ctx *thr = threads + thread_get_id();
struct thread_user_vfp_state *tuv = thr->vfp_state.uvfp;
- assert(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
assert(!vfp_is_enabled());
if (!thr->vfp_state.ns_saved) {
@@ -1030,7 +1035,7 @@ void thread_user_save_vfp(void)
struct thread_ctx *thr = threads + thread_get_id();
struct thread_user_vfp_state *tuv = thr->vfp_state.uvfp;
- assert(thread_get_exceptions() & THREAD_EXCP_IRQ);
+ assert(thread_get_exceptions() & THREAD_EXCP_FOREIGN_INTR);
if (!vfp_is_enabled())
return;
@@ -1130,7 +1135,7 @@ bool thread_disable_prealloc_rpc_cache(uint64_t *cookie)
{
bool rv;
size_t n;
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
lock_global();
@@ -1163,7 +1168,7 @@ bool thread_enable_prealloc_rpc_cache(void)
{
bool rv;
size_t n;
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
lock_global();
diff --git a/core/arch/arm/kernel/thread_a32.S b/core/arch/arm/kernel/thread_a32.S
index 6d3ac35f..1a1c6962 100644
--- a/core/arch/arm/kernel/thread_a32.S
+++ b/core/arch/arm/kernel/thread_a32.S
@@ -75,7 +75,7 @@ UNWIND( .fnstart)
UNWIND( .cantunwind)
/* Secure Monitor received a FIQ and passed control to us. */
bl thread_check_canaries
- ldr lr, =thread_fiq_handler_ptr
+ ldr lr, =thread_nintr_handler_ptr
ldr lr, [lr]
blx lr
mov r1, r0
@@ -392,7 +392,7 @@ UNWIND( .cantunwind)
*/
push {r0-r3, r8-r12, lr}
bl thread_check_canaries
- ldr lr, =thread_fiq_handler_ptr
+ ldr lr, =thread_nintr_handler_ptr
ldr lr, [lr]
blx lr
pop {r0-r3, r8-r12, lr}
@@ -416,7 +416,7 @@ UNWIND( .cantunwind)
bl thread_save_state
- mov r0, #THREAD_FLAGS_EXIT_ON_IRQ
+ mov r0, #THREAD_FLAGS_EXIT_ON_FOREIGN_INTR
mrs r1, spsr
pop {r12}
pop {r2}
@@ -432,7 +432,7 @@ UNWIND( .cantunwind)
mov sp, r0
ldr r0, =TEESMC_OPTEED_RETURN_CALL_DONE
- ldr r1, =OPTEE_SMC_RETURN_RPC_IRQ
+ ldr r1, =OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
mov r2, #0
mov r3, #0
/* r4 is already filled in above */
diff --git a/core/arch/arm/kernel/thread_a64.S b/core/arch/arm/kernel/thread_a64.S
index abd482b1..241868a1 100644
--- a/core/arch/arm/kernel/thread_a64.S
+++ b/core/arch/arm/kernel/thread_a64.S
@@ -77,7 +77,7 @@ END_FUNC vector_fast_smc_entry
LOCAL_FUNC vector_fiq_entry , :
/* Secure Monitor received a FIQ and passed control to us. */
bl thread_check_canaries
- adr x16, thread_fiq_handler_ptr
+ adr x16, thread_nintr_handler_ptr
ldr x16, [x16]
blr x16
ldr x0, =TEESMC_OPTEED_RETURN_FIQ_DONE
@@ -487,9 +487,9 @@ LOCAL_FUNC el0_svc , :
mov x0, sp
/*
- * Unmask FIQ, Serror, and debug exceptions since we have nothing
- * left in sp_el1. Note that the SVC handler is excepted to
- * re-enable IRQs by itself.
+ * Unmask native interrupts, Serror, and debug exceptions since we have
+ * nothing left in sp_el1. Note that the SVC handler is excepted to
+ * re-enable foreign interrupts by itself.
*/
msr daifclr, #(DAIFBIT_FIQ | DAIFBIT_ABT | DAIFBIT_DBG)
@@ -713,7 +713,7 @@ LOCAL_FUNC elx_irq , :
/*
* Mark current thread as suspended
*/
- mov w0, #THREAD_FLAGS_EXIT_ON_IRQ
+ mov w0, #THREAD_FLAGS_EXIT_ON_FOREIGN_INTR
mrs x1, spsr_el1
mrs x2, elr_el1
bl thread_state_suspend
@@ -734,7 +734,7 @@ LOCAL_FUNC elx_irq , :
*/
ldr w0, =TEESMC_OPTEED_RETURN_CALL_DONE
- ldr w1, =OPTEE_SMC_RETURN_RPC_IRQ
+ ldr w1, =OPTEE_SMC_RETURN_RPC_FOREIGN_INTR
mov w2, #0
mov w3, #0
/* w4 is already filled in above */
@@ -787,7 +787,7 @@ LOCAL_FUNC elx_fiq , :
stp x30, x2, [sp, #ELX_FIQ_REC_LR]
bl thread_check_canaries
- adr x16, thread_fiq_handler_ptr
+ adr x16, thread_nintr_handler_ptr
ldr x16, [x16]
blr x16
diff --git a/core/arch/arm/mm/core_mmu.c b/core/arch/arm/mm/core_mmu.c
index 62dda739..36e811f1 100644
--- a/core/arch/arm/mm/core_mmu.c
+++ b/core/arch/arm/mm/core_mmu.c
@@ -693,7 +693,7 @@ unsigned int cache_maintenance_l1(int op, void *va, size_t len)
unsigned int cache_maintenance_l2(int op, paddr_t pa, size_t len)
{
unsigned int ret = TEE_SUCCESS;
- uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ uint32_t exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
tee_l2cc_mutex_lock();
switch (op) {
diff --git a/core/arch/arm/plat-d02/main.c b/core/arch/arm/plat-d02/main.c
index 95161d10..e5c798d8 100644
--- a/core/arch/arm/plat-d02/main.c
+++ b/core/arch/arm/plat-d02/main.c
@@ -42,7 +42,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-hikey/main.c b/core/arch/arm/plat-hikey/main.c
index 36789cef..be54a461 100644
--- a/core/arch/arm/plat-hikey/main.c
+++ b/core/arch/arm/plat-hikey/main.c
@@ -49,7 +49,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-imx/main.c b/core/arch/arm/plat-imx/main.c
index edfbc37d..5601765b 100644
--- a/core/arch/arm/plat-imx/main.c
+++ b/core/arch/arm/plat-imx/main.c
@@ -55,7 +55,7 @@ static struct gic_data gic_data;
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
diff --git a/core/arch/arm/plat-ls/main.c b/core/arch/arm/plat-ls/main.c
index 23ac0c63..9fceca52 100644
--- a/core/arch/arm/plat-ls/main.c
+++ b/core/arch/arm/plat-ls/main.c
@@ -48,7 +48,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
diff --git a/core/arch/arm/plat-mediatek/main.c b/core/arch/arm/plat-mediatek/main.c
index 77805912..619bf03c 100644
--- a/core/arch/arm/plat-mediatek/main.c
+++ b/core/arch/arm/plat-mediatek/main.c
@@ -41,7 +41,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-rcar/main.c b/core/arch/arm/plat-rcar/main.c
index 8f9482ea..bee5c3fb 100644
--- a/core/arch/arm/plat-rcar/main.c
+++ b/core/arch/arm/plat-rcar/main.c
@@ -46,7 +46,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-rpi3/main.c b/core/arch/arm/plat-rpi3/main.c
index 9270e192..134a649e 100644
--- a/core/arch/arm/plat-rpi3/main.c
+++ b/core/arch/arm/plat-rpi3/main.c
@@ -45,7 +45,7 @@ static void main_fiq(void)
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-sprd/main.c b/core/arch/arm/plat-sprd/main.c
index bf3a62d3..ea2c984a 100644
--- a/core/arch/arm/plat-sprd/main.c
+++ b/core/arch/arm/plat-sprd/main.c
@@ -40,7 +40,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
.cpu_suspend = pm_do_nothing,
diff --git a/core/arch/arm/plat-stm/main.c b/core/arch/arm/plat-stm/main.c
index e569e076..a9b3962e 100644
--- a/core/arch/arm/plat-stm/main.c
+++ b/core/arch/arm/plat-stm/main.c
@@ -75,7 +75,7 @@ static void stm_tee_entry_std(struct thread_smc_args *smc_args)
static const struct thread_handlers handlers = {
.std_smc = stm_tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
diff --git a/core/arch/arm/plat-sunxi/main.c b/core/arch/arm/plat-sunxi/main.c
index 3954d9db..fc3622bd 100644
--- a/core/arch/arm/plat-sunxi/main.c
+++ b/core/arch/arm/plat-sunxi/main.c
@@ -62,7 +62,7 @@ static void main_tee_entry_fast(struct thread_smc_args *args);
static const struct thread_handlers handlers = {
.std_smc = main_tee_entry_std,
.fast_smc = main_tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
@@ -78,12 +78,13 @@ void main_init(uint32_t nsec_entry)
size_t pos = get_core_pos();
/*
- * Mask IRQ and FIQ before switch to the thread vector as the
- * thread handler requires IRQ and FIQ to be masked while executing
+ * Mask the interrupts before switch to the thread vector as the
+ * thread handler requires the interrupts to be masked while executing
* with the temporary stack. The thread subsystem also asserts that
- * IRQ is blocked when using most if its functions.
+ * foreign interrupts are blocked when using most if its functions.
*/
- thread_mask_exceptions(THREAD_EXCP_FIQ | THREAD_EXCP_IRQ);
+ thread_mask_exceptions(
+ THREAD_EXCP_NATIVE_INTR | THREAD_EXCP_FOREIGN_INTR);
if (pos == 0) {
thread_init_primary(&handlers);
diff --git a/core/arch/arm/plat-ti/main.c b/core/arch/arm/plat-ti/main.c
index c8118627..9bb47f92 100644
--- a/core/arch/arm/plat-ti/main.c
+++ b/core/arch/arm/plat-ti/main.c
@@ -79,7 +79,7 @@ static void main_fiq(void)
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
diff --git a/core/arch/arm/plat-vexpress/main.c b/core/arch/arm/plat-vexpress/main.c
index 85ed9eec..4f6d4c92 100644
--- a/core/arch/arm/plat-vexpress/main.c
+++ b/core/arch/arm/plat-vexpress/main.c
@@ -55,7 +55,7 @@ static void main_fiq(void);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
#if defined(CFG_WITH_ARM_TRUSTED_FW)
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
diff --git a/core/arch/arm/plat-zynq7k/main.c b/core/arch/arm/plat-zynq7k/main.c
index 74bc1ce5..b7708800 100644
--- a/core/arch/arm/plat-zynq7k/main.c
+++ b/core/arch/arm/plat-zynq7k/main.c
@@ -51,7 +51,7 @@ static void platform_tee_entry_fast(struct thread_smc_args *args);
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = platform_tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
.cpu_on = pm_panic,
.cpu_off = pm_panic,
.cpu_suspend = pm_panic,
diff --git a/core/arch/arm/plat-zynqmp/main.c b/core/arch/arm/plat-zynqmp/main.c
index 31b8475b..16f602c7 100644
--- a/core/arch/arm/plat-zynqmp/main.c
+++ b/core/arch/arm/plat-zynqmp/main.c
@@ -50,7 +50,7 @@ static struct gic_data gic_data;
static const struct thread_handlers handlers = {
.std_smc = tee_entry_std,
.fast_smc = tee_entry_fast,
- .fiq = main_fiq,
+ .nintr = main_fiq,
#if defined(CFG_WITH_ARM_TRUSTED_FW)
.cpu_on = cpu_on_handler,
.cpu_off = pm_do_nothing,
diff --git a/core/arch/arm/pta/interrupt_tests.c b/core/arch/arm/pta/interrupt_tests.c
index bc307a88..2b9ea005 100644
--- a/core/arch/arm/pta/interrupt_tests.c
+++ b/core/arch/arm/pta/interrupt_tests.c
@@ -174,7 +174,7 @@ static TEE_Result test_ppi(void)
itr_add(&ppi_handler);
itr_enable(TEST_PPI_ID);
- exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ);
+ exceptions = thread_mask_exceptions(THREAD_EXCP_FOREIGN_INTR);
expect_ppi_value[get_core_pos()]++;
itr_raise_pi(TEST_PPI_ID);
thread_unmask_exceptions(exceptions);
diff --git a/core/arch/arm/tee/arch_svc.c b/core/arch/arm/tee/arch_svc.c
index 8a89ce93..983eb6cd 100644
--- a/core/arch/arm/tee/arch_svc.c
+++ b/core/arch/arm/tee/arch_svc.c
@@ -201,8 +201,8 @@ void tee_svc_handler(struct thread_svc_regs *regs)
/* TA has just entered kernel mode */
tee_ta_update_session_utime_suspend();
- /* Restore IRQ which are disabled on exception entry */
- thread_restore_irq();
+ /* Restore foreign interrupts which are disabled on exception entry */
+ thread_restore_foreign_intr();
get_scn_max_args(regs, &scn, &max_args);
diff --git a/core/arch/arm/tee/entry_std.c b/core/arch/arm/tee/entry_std.c
index 29c3b747..fb4555be 100644
--- a/core/arch/arm/tee/entry_std.c
+++ b/core/arch/arm/tee/entry_std.c
@@ -346,7 +346,8 @@ void tee_entry_std(struct thread_smc_args *smc_args)
return;
}
- thread_set_irq(true); /* Enable IRQ for STD calls */
+ /* Enable foreign interrupts for STD calls */
+ thread_set_foreign_intr(true);
switch (arg->cmd) {
case OPTEE_MSG_CMD_OPEN_SESSION:
entry_open_session(smc_args, arg, num_params);
diff --git a/documentation/interrupt_handling.md b/documentation/interrupt_handling.md
index 7ca81217..80633579 100644
--- a/documentation/interrupt_handling.md
+++ b/documentation/interrupt_handling.md
@@ -19,8 +19,18 @@ The processor is configured to use:
* Monitor vector for SMC exceptions
* State vector for IRQ exceptions
-Interrupts handled by secure world are sent as FIQs and interrupts handled
-by normal world are sent as IRQs.
+Two types of interrupt are defined in optee_os:
+* Native interrupt - The interrupt handled by optee_os
+ (for example: secure interrupt)
+* Foreign interrupt - The interrupt not handled by optee_os
+ (for example: non-secure interrupt which is handled by normal world)
+
+For ARM GICv2 mode, native interrupt is sent as FIQ and foreign interrupt is
+sent as IRQ.
+
+For ARM GICv3 mode, foreign interrupt is sent as FIQ which could be handled
+by either secure world (EL3 in AArch64) or normal world. This mode is not
+supported yet.
Since IRQs are received using the state vector the actual vector used
depends on the current state of the CPU. If the NS (non-secure) bit in SCR
diff --git a/documentation/optee_design.md b/documentation/optee_design.md
index 073b46b5..cb0a5afa 100644
--- a/documentation/optee_design.md
+++ b/documentation/optee_design.md
@@ -151,12 +151,13 @@ table when the TA context is activated.
![Select xlation table](images/xlat_table.png "Select xlation table")
## Translation tables and switching to normal world
-When switching to normal world either via an IRQ or RPC there is a chance
-that secure world will resume execution on a different CPU. This means that
-the new CPU need to be configured with the context of the currently active
-TA. This is solved by always setting the TA context in the CPU when
-resuming execution. Here is room for improvements since it is more likely
-than not that it is the same CPU that resumes execution in secure world.
+When switching to normal world either via a foreign interrupt or RPC there
+is a chance that secure world will resume execution on a different CPU.
+This means that the new CPU need to be configured with the context of the
+currently active TA. This is solved by always setting the TA context in
+the CPU when resuming execution. Here is room for improvements since it is
+more likely than not that it is the same CPU that resumes execution in
+secure world.
# 6. Stacks
Different stacks are used during different stages. The stacks are:
@@ -216,11 +217,16 @@ is restored it will continue at the next instruction as if this function did a
normal return. CPU switches to use the temp stack before returning to normal
world.
-## IRQ exit
-IRQ exit occurs when OP-TEE receives an IRQ, which is always handled in normal
-world. IRQ exit is similar to RPC exit but it is `thread_irq_handler()` and
-`elx_irq()` (respectively for ARMv7-A/Aarch32 and for Aarch64) that saves the
-thread state instead. The thread is resumed in the same way though.
+## Foreign interrupt exit
+Foreign interrupt exit occurs when OP-TEE receives a foreign interrupt. For ARM
+GICv2 mode, foreign interrupt is sent as IRQ which is always handled in normal
+world. Foreign interrupt exit is similar to RPC exit but it is
+`thread_irq_handler()` and `elx_irq()` (respectively for ARMv7-A/Aarch32 and
+for Aarch64) that saves the thread state instead. The thread is resumed in the
+same way though.
+For ARM GICv3 mode, foreign interrupt is sent as FIQ which could be handled by
+either secure world (EL3 in AArch64) or normal world. This mode is not supported
+yet.
*Notes for ARMv7/AArch32:*
SP_IRQ is initialized to temp stack instead of a separate stack. Prior to
@@ -233,7 +239,8 @@ original `SP_EL0` is saved in the thread context to be restored when resuming.
## Resume entry
OP-TEE is entered using the temp stack in the same way as for normal entry. The
thread to resume is looked up and the state is restored to resume execution. The
-procedure to resume from an RPC exit or an IRQ exit is exactly the same.
+procedure to resume from an RPC exit or an foreign interrupt exit is exactly
+the same.
## Syscall
Syscalls are executed using the thread stack.
diff --git a/lib/libutils/isoc/bget_malloc.c b/lib/libutils/isoc/bget_malloc.c
index 9cb2751a..a4f77595 100644
--- a/lib/libutils/isoc/bget_malloc.c
+++ b/lib/libutils/isoc/bget_malloc.c
@@ -117,7 +117,8 @@ static uint32_t malloc_lock(void)
{
uint32_t exceptions;
- exceptions = thread_mask_exceptions(THREAD_EXCP_IRQ | THREAD_EXCP_FIQ);
+ exceptions = thread_mask_exceptions(
+ THREAD_EXCP_NATIVE_INTR | THREAD_EXCP_FOREIGN_INTR);
cpu_spin_lock(&__malloc_spinlock);
return exceptions;
}