Commit de4dfa14 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL
Browse files

Split AMB_LazyFixUp in two

If lazy task swapping is active, but it isn't a lazy task swapping
abort, AMB_LazyFixUp will force all of application space to be mapped
in, in order to protect the data/prefetech abort environment handlers
from triggering unexpected recursive aborts (which could easily happen
if the handlers make use of application space in any way). Recursive
aborts generally aren't tolerated by these handlers because they're
entered in ABT32 mode and may rely on the DFSR/DFAR registers being
correct.

To allow for more stages to be added to the abort handler inbetween lazy
task swapping fixup & invoking the abort environment handler,
AMB_LazyFixUp has now been split in two so that the code which maps in
all of application space can be excuted at a more suitable time.
parent 85f92e4f
......@@ -413,7 +413,7 @@ pt SETS ""
; entry which is a translation fault, as seems rational.
;
; entry: r0 = aborting address (data address for data abort, instruction address
; for prefetch abort), r1-r7 trashable, no stack
; for prefetch abort), r1-r7 trashable
; r2 = 1 for prefetch abort, 0 for data abort
; FSR valid for data aborts, unpredictable for prefetch aborts
; exit: r0 = non-zero (NE status) if abort was expected and fixed up, zero (EQ status) if not
......@@ -431,17 +431,17 @@ AMB_LazyFixUp ROUT
LDR r1,AMBMappedInNode
CMP r1,#0
BEQ %FT90 ;no current node
ARM_read_FSR r6 ;hang onto FSR in case we have to preserve it
ARM_read_FSR r6
TEQ r2,#1 ;if data abort
ANDNE r3,r6,#&F
TEQNE r3,#7 ; and not a page translation fault
BNE %FT20 ; then not a lazy abort (and FAR may be invalid anyway)
BNE %FT90 ; then not a lazy abort (and FAR may be invalid anyway)
LDR r2,[r1,#AMBNode_DANode+DANode_PMPSize]
SUBS r0,r0,#ApplicationStart
BLO %FT20 ;abort not in current app space
BLO %FT90 ;abort not in current app space
MOV r0,r0,LSR #Log2PageSize ;address now in terms of pages from ApplicationStart
CMP r0,r2
BHS %FT20 ;abort not in current app space
BHS %FT90 ;abort not in current app space
[ AMB_Debug
Push "lr"
DebugReg r0, "Lazy "
......@@ -459,7 +459,7 @@ AMB_LazyFixUp ROUT
LDR r3,[r2]
LDR r4,[r1,#AMBNode_DANode+DANode_Size] ;count it
TST r3,r5 ;if page already mapped in, not a lazy abort
BNE %FT20
BNE %FT90
ORR r3,r3,r5 ;ok, mark that we are going to map this page in
STR r3,[r2]
ADD r4,r4,#PageSize
......@@ -522,10 +522,46 @@ AMB_LazyFixUp ROUT
MOV r12,r7
MOV pc,lr ;r0 is non-zero, NE status
;
; not our abort, but is possible that client abort handler is in app space, so force all
; app space pages in now (so that client abort handler does not cause lazy abort, scribbling over original abort details)
; not our abort
;
20
90
MOVS r0,#0
MOV r12,r7
MOV pc,lr ;r0 is zero, EQ status
; ----------------------------------------------------------------------------------
;
;AMB_MakeFullyHonest
;
; *Only* for ARMs where the abort handler can restart instructions
;
; Routine to be used in abort handlers (in abort32 mode), to make sure that application space
; is fully mapped in before passing control to a handler that can't cope with recursive aborts,
; e.g. when passing to the data or prefetch abort environment handlers (which are entered in
; abort32, and may be running from application space).
;
; Fix up consists of triggering recursive aborts in order to map in each missing page.
;
; entry: r0-r7 trashable
; FSR valid for data aborts, unpredictable for prefetch aborts
; exit: r0-r7 corrupt
; FAR,FSR,SPSR_abt,lr_abt preserved
;
AMB_MakeFullyHonest ROUT
MOV r7,r12
LDR r12,=ZeroPage+AMBControl_ws
LDR r12,[r12]
CMP r12,#0
BEQ %FT90 ;not initialised!
LDR r1,AMBFlags
TST r1,#AMBFlag_LazyMapIn_disable :OR: AMBFlag_LazyMapIn_suspend
BNE %FT90 ;not active
LDR r1,AMBMappedInNode
CMP r1,#0
BEQ %FT90 ;no current node
ARM_read_FSR r6 ;preserve FSR in case client abort handler wants to read it
MOV r1,#ApplicationStart ;good old page walk to provoke lazy fixups
LDR r2,AMBMappedInNode
LDR r2,[r2,#AMBNode_DANode+DANode_PMPSize]
......@@ -549,7 +585,6 @@ AMB_LazyFixUp ROUT
]
;
90
MOVS r0,#0
MOV r12,r7
MOV pc,lr ;r0 is zero, EQ status
......
......@@ -29,6 +29,7 @@ PAbPreVeneer ROUT
PageTableSyncNE
Pull "r0-r7, lr", NE ; restore regs and
SUBNES pc, lr_abort, #4 ; restart aborting instruction if fixed up
BL AMB_MakeFullyHonest ; PAbHan might not support recursive aborts
LDR lr, [sp, #8*4] ; (not a lazy abort) restore lr
LDR r0, =ZeroPage+PAbHan ; we want to jump to PAb handler, in abort mode
LDR r0, [r0]
......@@ -95,10 +96,12 @@ DAbPreVeneer ROUT
MOV r2, #0
BL AMB_LazyFixUp ; can trash r0-r7, returns NE status if claimed and fixed up
PageTableSyncNE
LDR lr_abort, [r13_abort, #15*4] ; restore lr_abort
LDMIA r13_abort, {r0-r7} ; restore regs
LDRNE lr_abort, [r13_abort, #15*4] ; restore lr_abort
LDMNEIA r13_abort, {r0-r7} ; restore regs
ADDNE r13_abort, r13_abort, #17*4 ; if fixed up, restore r13_abort
SUBNES pc, lr_abort, #8 ; and restart aborting instruction
BL AMB_MakeFullyHonest ; DAbHan might not support recursive aborts
LDR lr_abort, [r13_abort, #15*4] ; restore lr_abort
]
; Remember the details of this abort, for OS_ReadSysInfo 7
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment