Make undefined exception entry MPSAFE.

The old code used static storage to preserve a couple registers while
setting up the trapframe for the main handler.  Doing so was the last
leftover crumbs from the days when a low-level debugger was hooked into
the exception entry code.

Now the exception entry sequence is essentially the same as for the
other exceptions, which still involves needlessly indirecting through
a function pointer which points to the same code on every platform.
Removing that indirection will be handled as a separate cleanup.

This work is based on an analysis by Juergen Weiss.
This commit is contained in:
Ian Lepore 2014-03-09 15:36:56 +00:00
parent 9309212899
commit 4ce4252794
2 changed files with 14 additions and 36 deletions

View File

@ -218,46 +218,25 @@ END(exception_exit)
* look like direct entry from the vector.
*/
ASENTRY_NP(undefined_entry)
stmfd sp!, {r0, r1}
ldr r0, Lundefined_handler_indirection
ldr r1, [sp], #0x0004
str r1, [r0, #0x0000]
ldr r1, [sp], #0x0004
str r1, [r0, #0x0004]
ldmia r0, {r0, r1, pc}
Lundefined_handler_indirection:
.word Lundefined_handler_indirection_data
sub lr, lr, #0x00000004 /* Adjust the lr */
PUSHFRAMEINSVC /* Push trap frame and switch */
/* to SVC32 mode */
ldr r1, Lundefined_handler_address
adr lr, exception_exit
mov r0, sp /* pass the stack pointer as r0 */
ldr pc, [r1]
END(undefined_entry)
/*
* assembly bounce code for calling the kernel
* undefined instruction handler. This uses
* a standard trap frame and is called in SVC mode.
*/
ASENTRY_NP(undefinedinstruction_bounce)
b undefinedinstruction
END(undefinedinstruction_bounce)
ENTRY_NP(undefinedinstruction_bounce)
PUSHFRAMEINSVC
mov r0, sp
adr lr, exception_exit
b _C_LABEL(undefinedinstruction)
Lundefined_handler_address:
.word _C_LABEL(undefined_handler_address)
.data
.align 0
/*
* Indirection data
* 2 words use for preserving r0 and r1
* 3rd word contains the undefined handler address.
*/
Lundefined_handler_indirection_data:
.word 0
.word 0
.global _C_LABEL(undefined_handler_address)
_C_LABEL(undefined_handler_address):
.word _C_LABEL(undefinedinstruction_bounce)
END(undefinedinstruction_bounce)
.word undefinedinstruction_bounce

View File

@ -183,7 +183,6 @@ undefinedinstruction(struct trapframe *frame)
if (!(frame->tf_spsr & I32_bit))
enable_interrupts(I32_bit|F32_bit);
frame->tf_pc -= INSN_SIZE;
PCPU_INC(cnt.v_trap);
fault_pc = frame->tf_pc;