From 9bb6050d40b9936beda5cb1cd15040f6c1b07179 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Wed, 18 Jan 2017 14:36:27 +0100 Subject: hwstub: rewrite exception catching Since we can catch exceptions like data aborts on read/write, it takes very little to also catch exceptions in calls. When extending this with the catching of illegal instructions, the call instruction now becomes much more robust and also for address and instruction probing. Since we can catch several types of exception, rename set_data_abort_jmp to set_exception_jmp. At the same time, simplify the logic in read/write request handlers. Also fix a bug in ARM jump code: it was using stmia r1, {..., pc} as if pc would get current pc + 8 but this is actually implementation defined on older ARMs (typically pc + 12) and deprecated on newer ARMs, so rewrite the code avoid that. The set_exception_jmp() function now also reports the exception type. Change-Id: Icd0dd52d2456b361b27c4776be09c3d13528ed93 --- utils/hwstub/stub/asm/mips/system.S | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'utils/hwstub/stub/asm/mips/system.S') diff --git a/utils/hwstub/stub/asm/mips/system.S b/utils/hwstub/stub/asm/mips/system.S index 2d89bde096..7f619c6edd 100644 --- a/utils/hwstub/stub/asm/mips/system.S +++ b/utils/hwstub/stub/asm/mips/system.S @@ -19,23 +19,24 @@ ****************************************************************************/ #include "mips.h" #include "target-config.h" +#include "system.h" -/* Handling of data abort: +/* Handling of exception: * the code can register a "longjmp" buffer to restore the context in case of * fault */ .data -.global data_abort_jmp_ctx_ptr -data_abort_jmp_ctx_ptr: +.global exception_jmp_ctx_ptr +exception_jmp_ctx_ptr: /* buffer contains in order: s0-s7, sp, s8, ra */ .skip 44 /* = 4 * (9 callee saved registers + sp + ra) */ .set noreorder .section .icode, "ax", %progbits -/* Prototype: int set_data_abort_jmp() +/* Prototype: int set_exception_jmp() * Return: 1 in case of data abort, 0 otherwise */ -.global set_data_abort_jmp -set_data_abort_jmp: - la v0, data_abort_jmp_ctx_ptr +.global set_exception_jmp +set_exception_jmp: + la v0, exception_jmp_ctx_ptr sw s0, 0(v0) sw s1, 4(v0) sw s2, 8(v0) @@ -50,10 +51,12 @@ set_data_abort_jmp: jr ra move v0, zero -/* restore context on read/write error, performs the interrupt return */ -.global restore_data_abort_jmp -restore_data_abort_jmp: -la k1, data_abort_jmp_ctx_ptr +/* restore context on read/write error, performs the interrupt return + * arguments: + * a0: exception type (EXCEPTION_*) */ +.global restore_exception_jmp +restore_exception_jmp: + la k1, exception_jmp_ctx_ptr lw s0, 0(k1) lw s1, 4(k1) lw s2, 8(k1) @@ -73,7 +76,7 @@ la k1, data_abort_jmp_ctx_ptr #else ehb #endif - li v0, 1 + move v0, a0 /* set exception type */ eret nop .set reorder -- cgit v1.2.3