diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2015-12-16 14:37:06 +0100 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2016-02-02 15:29:58 +0100 |
commit | 29e6329118e799b8f1c21204a20889a334cd6909 (patch) | |
tree | de414abdd98beb0bf41f48681bb706874332c6ef | |
parent | 821f46cf73fb85ac65b92bae492df62bde6ab466 (diff) |
core: abort.{c,h} refactoring
Renames structs, functions and defines to show that they are part of the
abort module.
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU, FVP)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
-rw-r--r-- | core/arch/arm/include/kernel/abort.h | 15 | ||||
-rw-r--r-- | core/arch/arm/include/mm/tee_pager.h | 7 | ||||
-rw-r--r-- | core/arch/arm/kernel/abort.c | 124 | ||||
-rw-r--r-- | core/arch/arm/kernel/thread_a32.S | 6 | ||||
-rw-r--r-- | core/arch/arm/mm/tee_pager.c | 22 | ||||
-rw-r--r-- | core/arch/arm/plat-hikey/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-imx/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-ls/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-mediatek/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-stm/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-sunxi/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-ti/main.c | 2 | ||||
-rw-r--r-- | core/arch/arm/plat-vexpress/main.c | 2 |
13 files changed, 89 insertions, 101 deletions
diff --git a/core/arch/arm/include/kernel/abort.h b/core/arch/arm/include/kernel/abort.h index a5e4d191..c9a71278 100644 --- a/core/arch/arm/include/kernel/abort.h +++ b/core/arch/arm/include/kernel/abort.h @@ -28,16 +28,16 @@ #ifndef KERNEL_ABORT_H #define KERNEL_ABORT_H -#define THREAD_ABORT_UNDEF 0 -#define THREAD_ABORT_PREFETCH 1 -#define THREAD_ABORT_DATA 2 +#define ABORT_TYPE_UNDEF 0 +#define ABORT_TYPE_PREFETCH 1 +#define ABORT_TYPE_DATA 2 #ifndef ASM #include <compiler.h> #include <types_ext.h> -struct tee_pager_abort_info { +struct abort_info { uint32_t abort_type; uint32_t fault_descr; vaddr_t va; @@ -45,11 +45,10 @@ struct tee_pager_abort_info { struct thread_abort_regs *regs; }; -void tee_pager_print_abort(struct tee_pager_abort_info *ai __unused); -void tee_pager_print_error_abort(struct tee_pager_abort_info *ai __unused); +void abort_print(struct abort_info *ai); +void abort_print_error(struct abort_info *ai); -void tee_pager_abort_handler(uint32_t abort_type, - struct thread_abort_regs *regs); +void abort_handler(uint32_t abort_type, struct thread_abort_regs *regs); #endif /*ASM*/ #endif /*KERNEL_ABORT_H*/ diff --git a/core/arch/arm/include/mm/tee_pager.h b/core/arch/arm/include/mm/tee_pager.h index a3bce496..34ce748c 100644 --- a/core/arch/arm/include/mm/tee_pager.h +++ b/core/arch/arm/include/mm/tee_pager.h @@ -117,12 +117,11 @@ struct tee_pager_stats { #ifdef CFG_WITH_PAGER void tee_pager_get_stats(struct tee_pager_stats *stats); -void tee_pager_handle_fault(struct tee_pager_abort_info *ai); +void tee_pager_handle_fault(struct abort_info *ai); #else /*CFG_WITH_PAGER*/ -static inline void __noreturn tee_pager_handle_fault( - struct tee_pager_abort_info *ai) +static inline void __noreturn tee_pager_handle_fault(struct abort_info *ai) { - tee_pager_print_error_abort(ai); + abort_print_error(ai); EMSG("Unexpected page fault! Trap CPU"); panic(); } diff --git a/core/arch/arm/kernel/abort.c b/core/arch/arm/kernel/abort.c index 2e92075d..15d6ec2d 100644 --- a/core/arch/arm/kernel/abort.c +++ b/core/arch/arm/kernel/abort.c @@ -34,23 +34,22 @@ #include <trace.h> #include <arm.h> -enum tee_pager_fault_type { - TEE_PAGER_FAULT_TYPE_USER_TA_PANIC, - TEE_PAGER_FAULT_TYPE_PAGEABLE, - TEE_PAGER_FAULT_TYPE_IGNORE, +enum fault_type { + FAULT_TYPE_USER_TA_PANIC, + FAULT_TYPE_PAGEABLE, + FAULT_TYPE_IGNORE, }; static __unused const char *abort_type_to_str(uint32_t abort_type) { - if (abort_type == THREAD_ABORT_DATA) + if (abort_type == ABORT_TYPE_DATA) return "data"; - if (abort_type == THREAD_ABORT_PREFETCH) + if (abort_type == ABORT_TYPE_PREFETCH) return "prefetch"; return "undef"; } -static __unused void tee_pager_print_detailed_abort( - struct tee_pager_abort_info *ai __unused, +static __unused void print_detailed_abort(struct abort_info *ai __unused, const char *ctx __unused) { EMSG_RAW("\n"); @@ -115,28 +114,26 @@ static __unused void tee_pager_print_detailed_abort( #endif /*ARM64*/ } -static void tee_pager_print_user_abort(struct tee_pager_abort_info *ai __unused) +static void print_user_abort(struct abort_info *ai __unused) { #ifdef CFG_TEE_CORE_TA_TRACE - tee_pager_print_detailed_abort(ai, "user TA"); + print_detailed_abort(ai, "user TA"); tee_ta_dump_current(); #endif } -void tee_pager_print_abort(struct tee_pager_abort_info *ai __unused) +void abort_print(struct abort_info *ai __unused) { #if (TRACE_LEVEL >= TRACE_INFO) - tee_pager_print_detailed_abort(ai, "core"); + print_detailed_abort(ai, "core"); #endif /*TRACE_LEVEL >= TRACE_DEBUG*/ } - - -void tee_pager_print_error_abort(struct tee_pager_abort_info *ai __unused) +void abort_print_error(struct abort_info *ai __unused) { #if (TRACE_LEVEL >= TRACE_INFO) /* full verbose log at DEBUG level */ - tee_pager_print_detailed_abort(ai, "core"); + print_detailed_abort(ai, "core"); #else #ifdef ARM32 EMSG("%s-abort at 0x%" PRIxVA "\n" @@ -160,14 +157,14 @@ void tee_pager_print_error_abort(struct tee_pager_abort_info *ai __unused) #ifdef ARM32 static void set_abort_info(uint32_t abort_type, struct thread_abort_regs *regs, - struct tee_pager_abort_info *ai) + struct abort_info *ai) { switch (abort_type) { - case THREAD_ABORT_DATA: + case ABORT_TYPE_DATA: ai->fault_descr = read_dfsr(); ai->va = read_dfar(); break; - case THREAD_ABORT_PREFETCH: + case ABORT_TYPE_PREFETCH: ai->fault_descr = read_ifsr(); ai->va = read_ifar(); break; @@ -184,23 +181,23 @@ static void set_abort_info(uint32_t abort_type, struct thread_abort_regs *regs, #ifdef ARM64 static void set_abort_info(uint32_t abort_type __unused, - struct thread_abort_regs *regs, struct tee_pager_abort_info *ai) + struct thread_abort_regs *regs, struct abort_info *ai) { ai->fault_descr = read_esr_el1(); switch ((ai->fault_descr >> ESR_EC_SHIFT) & ESR_EC_MASK) { case ESR_EC_IABT_EL0: case ESR_EC_IABT_EL1: - ai->abort_type = THREAD_ABORT_PREFETCH; + ai->abort_type = ABORT_TYPE_PREFETCH; ai->va = read_far_el1(); break; case ESR_EC_DABT_EL0: case ESR_EC_DABT_EL1: case ESR_EC_SP_ALIGN: - ai->abort_type = THREAD_ABORT_DATA; + ai->abort_type = ABORT_TYPE_DATA; ai->va = read_far_el1(); break; default: - ai->abort_type = THREAD_ABORT_UNDEF; + ai->abort_type = ABORT_TYPE_UNDEF; ai->va = regs->elr; } ai->pc = regs->elr; @@ -209,7 +206,7 @@ static void set_abort_info(uint32_t abort_type __unused, #endif /*ARM64*/ #ifdef ARM32 -static void handle_user_ta_panic(struct tee_pager_abort_info *ai) +static void handle_user_ta_panic(struct abort_info *ai) { /* * It was a user exception, stop user execution and return @@ -233,7 +230,7 @@ static void handle_user_ta_panic(struct tee_pager_abort_info *ai) #endif /*ARM32*/ #ifdef ARM64 -static void handle_user_ta_panic(struct tee_pager_abort_info *ai) +static void handle_user_ta_panic(struct abort_info *ai) { uint32_t daif; @@ -255,7 +252,7 @@ static void handle_user_ta_panic(struct tee_pager_abort_info *ai) #ifdef ARM32 /* Returns true if the exception originated from user mode */ -static bool tee_pager_is_user_exception(struct tee_pager_abort_info *ai) +static bool is_user_exception(struct abort_info *ai) { return (ai->regs->spsr & ARM32_CPSR_MODE_MASK) == ARM32_CPSR_MODE_USR; } @@ -263,7 +260,7 @@ static bool tee_pager_is_user_exception(struct tee_pager_abort_info *ai) #ifdef ARM64 /* Returns true if the exception originated from user mode */ -static bool tee_pager_is_user_exception(struct tee_pager_abort_info *ai) +static bool is_user_exception(struct abort_info *ai) { uint32_t spsr = ai->regs->spsr; @@ -278,7 +275,7 @@ static bool tee_pager_is_user_exception(struct tee_pager_abort_info *ai) #ifdef ARM32 /* Returns true if the exception originated from abort mode */ -static bool tee_pager_is_abort_in_abort_handler(struct tee_pager_abort_info *ai) +static bool is_abort_in_abort_handler(struct abort_info *ai) { return (ai->regs->spsr & ARM32_CPSR_MODE_MASK) == ARM32_CPSR_MODE_ABT; } @@ -286,90 +283,83 @@ static bool tee_pager_is_abort_in_abort_handler(struct tee_pager_abort_info *ai) #ifdef ARM64 /* Returns true if the exception originated from abort mode */ -static bool tee_pager_is_abort_in_abort_handler( - struct tee_pager_abort_info *ai __unused) +static bool is_abort_in_abort_handler(struct abort_info *ai __unused) { return false; } #endif /*ARM64*/ - - -static enum tee_pager_fault_type tee_pager_get_fault_type( - struct tee_pager_abort_info *ai) +static enum fault_type get_fault_type(struct abort_info *ai) { - if (tee_pager_is_user_exception(ai)) { - tee_pager_print_user_abort(ai); - DMSG("[TEE_PAGER] abort in User mode (TA will panic)"); - return TEE_PAGER_FAULT_TYPE_USER_TA_PANIC; + if (is_user_exception(ai)) { + print_user_abort(ai); + DMSG("[abort] abort in User mode (TA will panic)"); + return FAULT_TYPE_USER_TA_PANIC; } - if (tee_pager_is_abort_in_abort_handler(ai)) { - tee_pager_print_error_abort(ai); - EMSG("[PAGER] abort in abort handler (trap CPU)"); + if (is_abort_in_abort_handler(ai)) { + abort_print_error(ai); + EMSG("[abort] abort in abort handler (trap CPU)"); panic(); } - if (ai->abort_type == THREAD_ABORT_UNDEF) { - tee_pager_print_error_abort(ai); - EMSG("[TEE_PAGER] undefined abort (trap CPU)"); + if (ai->abort_type == ABORT_TYPE_UNDEF) { + abort_print_error(ai); + EMSG("[abort] undefined abort (trap CPU)"); panic(); } switch (core_mmu_get_fault_type(ai->fault_descr)) { case CORE_MMU_FAULT_ALIGNMENT: - tee_pager_print_error_abort(ai); - EMSG("[TEE_PAGER] alignement fault! (trap CPU)"); + abort_print_error(ai); + EMSG("[abort] alignement fault! (trap CPU)"); panic(); break; case CORE_MMU_FAULT_ACCESS_BIT: - tee_pager_print_error_abort(ai); - EMSG("[TEE_PAGER] access bit fault! (trap CPU)"); + abort_print_error(ai); + EMSG("[abort] access bit fault! (trap CPU)"); panic(); break; case CORE_MMU_FAULT_DEBUG_EVENT: - tee_pager_print_abort(ai); - DMSG("[TEE_PAGER] Ignoring debug event!"); - return TEE_PAGER_FAULT_TYPE_IGNORE; + abort_print(ai); + DMSG("[abort] Ignoring debug event!"); + return FAULT_TYPE_IGNORE; case CORE_MMU_FAULT_TRANSLATION: case CORE_MMU_FAULT_WRITE_PERMISSION: case CORE_MMU_FAULT_READ_PERMISSION: - return TEE_PAGER_FAULT_TYPE_PAGEABLE; + return FAULT_TYPE_PAGEABLE; case CORE_MMU_FAULT_ASYNC_EXTERNAL: - tee_pager_print_abort(ai); - DMSG("[TEE_PAGER] Ignoring async external abort!"); - return TEE_PAGER_FAULT_TYPE_IGNORE; + abort_print(ai); + DMSG("[abort] Ignoring async external abort!"); + return FAULT_TYPE_IGNORE; case CORE_MMU_FAULT_OTHER: default: - tee_pager_print_abort(ai); - DMSG("[TEE_PAGER] Unhandled fault!"); - return TEE_PAGER_FAULT_TYPE_IGNORE; + abort_print(ai); + DMSG("[abort] Unhandled fault!"); + return FAULT_TYPE_IGNORE; } } -void tee_pager_abort_handler(uint32_t abort_type, - struct thread_abort_regs *regs) +void abort_handler(uint32_t abort_type, struct thread_abort_regs *regs) { - struct tee_pager_abort_info ai; + struct abort_info ai; set_abort_info(abort_type, regs, &ai); - switch (tee_pager_get_fault_type(&ai)) { - case TEE_PAGER_FAULT_TYPE_IGNORE: + switch (get_fault_type(&ai)) { + case FAULT_TYPE_IGNORE: break; - case TEE_PAGER_FAULT_TYPE_USER_TA_PANIC: + case FAULT_TYPE_USER_TA_PANIC: handle_user_ta_panic(&ai); break; - case TEE_PAGER_FAULT_TYPE_PAGEABLE: + case FAULT_TYPE_PAGEABLE: default: tee_pager_handle_fault(&ai); break; } } - - diff --git a/core/arch/arm/kernel/thread_a32.S b/core/arch/arm/kernel/thread_a32.S index 5d9dd07f..00a508ae 100644 --- a/core/arch/arm/kernel/thread_a32.S +++ b/core/arch/arm/kernel/thread_a32.S @@ -487,7 +487,7 @@ thread_und_handler: cps #CPSR_MODE_ABT push {r0, r1} msr spsr_fsxc, r0 /* In case some code reads spsr directly */ - mov r0, #THREAD_ABORT_UNDEF + mov r0, #ABORT_TYPE_UNDEF b .thread_abort_generic thread_dabort_handler: @@ -495,7 +495,7 @@ thread_dabort_handler: sub r1, lr, #8 mrs r0, spsr push {r0, r1} - mov r0, #THREAD_ABORT_DATA + mov r0, #ABORT_TYPE_DATA b .thread_abort_generic thread_pabort_handler: @@ -503,7 +503,7 @@ thread_pabort_handler: sub r1, lr, #4 mrs r0, spsr push {r0, r1} - mov r0, #THREAD_ABORT_PREFETCH + mov r0, #ABORT_TYPE_PREFETCH b .thread_abort_generic .thread_abort_generic: diff --git a/core/arch/arm/mm/tee_pager.c b/core/arch/arm/mm/tee_pager.c index e83fc973..3a439176 100644 --- a/core/arch/arm/mm/tee_pager.c +++ b/core/arch/arm/mm/tee_pager.c @@ -445,7 +445,7 @@ static bool tee_pager_release_one_zi(vaddr_t page_va) } /* Finds the oldest page and remaps it for the new virtual address */ -static bool tee_pager_get_page(struct tee_pager_abort_info *ai, +static bool tee_pager_get_page(struct abort_info *ai, struct tee_pager_area *area, struct tee_pager_pmem **pmem_ret, paddr_t *pa_ret) { @@ -505,7 +505,7 @@ static bool tee_pager_get_page(struct tee_pager_abort_info *ai, return true; } -static bool pager_check_access(struct tee_pager_abort_info *ai) +static bool pager_check_access(struct abort_info *ai) { unsigned pgidx = core_mmu_va2idx(&tbl_info, ai->va); uint32_t attr; @@ -518,17 +518,17 @@ static bool pager_check_access(struct tee_pager_abort_info *ai) /* Not readable, should not happen */ if (!(attr & TEE_MATTR_PR)) { - tee_pager_print_error_abort(ai); + abort_print_error(ai); panic(); } switch (core_mmu_get_fault_type(ai->fault_descr)) { case CORE_MMU_FAULT_TRANSLATION: case CORE_MMU_FAULT_READ_PERMISSION: - if (ai->abort_type == THREAD_ABORT_PREFETCH && + if (ai->abort_type == ABORT_TYPE_PREFETCH && !(attr & TEE_MATTR_PX)) { /* Attempting to execute from an NOX page */ - tee_pager_print_error_abort(ai); + abort_print_error(ai); panic(); } /* Since the page is mapped now it's OK */ @@ -536,32 +536,32 @@ static bool pager_check_access(struct tee_pager_abort_info *ai) case CORE_MMU_FAULT_WRITE_PERMISSION: if (!(attr & TEE_MATTR_PW)) { /* Attempting to write to an RO page */ - tee_pager_print_error_abort(ai); + abort_print_error(ai); panic(); } return true; default: /* Some fault we can't deal with */ - tee_pager_print_error_abort(ai); + abort_print_error(ai); panic(); } } -void tee_pager_handle_fault(struct tee_pager_abort_info *ai) +void tee_pager_handle_fault(struct abort_info *ai) { struct tee_pager_area *area; vaddr_t page_va = ai->va & ~SMALL_PAGE_MASK; uint32_t exceptions; #ifdef TEE_PAGER_DEBUG_PRINT - tee_pager_print_abort(ai); + abort_print(ai); #endif /* check if the access is valid */ area = tee_pager_find_area(ai->va); if (!area) { - tee_pager_print_abort(ai); + abort_print(ai); DMSG("Invalid addr 0x%" PRIxVA, ai->va); panic(); } @@ -598,7 +598,7 @@ void tee_pager_handle_fault(struct tee_pager_abort_info *ai) } if (!tee_pager_get_page(ai, area, &pmem, &pa)) { - tee_pager_print_abort(ai); + abort_print(ai); panic(); } diff --git a/core/arch/arm/plat-hikey/main.c b/core/arch/arm/plat-hikey/main.c index 9d6c66f3..6548ebb3 100644 --- a/core/arch/arm/plat-hikey/main.c +++ b/core/arch/arm/plat-hikey/main.c @@ -44,7 +44,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 9c896f95..60f837d4 100644 --- a/core/arch/arm/plat-imx/main.c +++ b/core/arch/arm/plat-imx/main.c @@ -44,7 +44,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 8dc5e86f..7e2cb9a5 100644 --- a/core/arch/arm/plat-ls/main.c +++ b/core/arch/arm/plat-ls/main.c @@ -45,7 +45,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 c815f36b..3f13820a 100644 --- a/core/arch/arm/plat-mediatek/main.c +++ b/core/arch/arm/plat-mediatek/main.c @@ -44,7 +44,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 f70c895f..8b9dbbef 100644 --- a/core/arch/arm/plat-stm/main.c +++ b/core/arch/arm/plat-stm/main.c @@ -45,7 +45,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 fcf42d9f..9f411d4b 100644 --- a/core/arch/arm/plat-sunxi/main.c +++ b/core/arch/arm/plat-sunxi/main.c @@ -67,7 +67,7 @@ static const struct thread_handlers handlers = { .fast_smc = main_tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .cpu_on = pm_panic, .cpu_off = pm_panic, .cpu_suspend = pm_panic, diff --git a/core/arch/arm/plat-ti/main.c b/core/arch/arm/plat-ti/main.c index 15f3fa98..21ade62f 100644 --- a/core/arch/arm/plat-ti/main.c +++ b/core/arch/arm/plat-ti/main.c @@ -55,7 +55,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, .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 f5752b48..9708bf1f 100644 --- a/core/arch/arm/plat-vexpress/main.c +++ b/core/arch/arm/plat-vexpress/main.c @@ -52,7 +52,7 @@ static const struct thread_handlers handlers = { .fast_smc = tee_entry_fast, .fiq = main_fiq, .svc = tee_svc_handler, - .abort = tee_pager_abort_handler, + .abort = abort_handler, #if defined(CFG_WITH_ARM_TRUSTED_FW) .cpu_on = cpu_on_handler, .cpu_off = pm_do_nothing, |