Commit 276eee6d authored by Mike Stephens's avatar Mike Stephens
Browse files

fix for accidental degeneracy of mapping during page swaps

Detail:
  page swap as part of PagesUnsafe/PagesSafe mechanism
Admin:
  not tested
parent 18dc64d9
......@@ -2635,9 +2635,18 @@ DoTheGrowPagesSpecified
LDR r6, [r8, #0] ; r6 = page number required
LDR lr, [r8, #PageBlockSize+0] ; lr = page number of replacement page
TEQ r6, lr ; if the same
Pull "r0-r4,r7-r12", EQ ; then restore registers
BEQ %FT76 ; and skip copy and first page move
BNE %FT21
; if the same page, we can skip copy and just move needed page to destination
;
Pull "r0-r4,r7-r12" ; restore registers
LDR r2, [r8, #0]
MOV r3, r1
LDR r11, DestFlags
BL Call_CAM_Mapping ; move needed page
B %FT76 ; and continue
21
;mjs
; - if the old page is currently mapped in, copy normally
; - if the old page is not mapped in, copy via temporary mapping
......@@ -2700,6 +2709,20 @@ DoTheGrowPagesSpecified
74
Pull "r0-r4,r7-r12" ; restore registers
; mjs: old code moved pages in wrong order for MMU, creating a temporary degeneracy
; of two physical pages at same logical address - eg. undefined behaviour for cache writebacks
;
; so do it this way now:
; first, move needed page to destination (nothing there at present)
; this also moves page out of way for moving the replacement page in, see below
;
LDR r2, [r8, #0]
MOV r3, r1
LDR r11, DestFlags
BL Call_CAM_Mapping
; next, move replacement page in
;
MOV lr, #0
LDR lr, [lr, #CamEntriesPointer] ; lr -> soft cam map
ADD lr, lr, #4 ; point at PPLs, not addresses
......@@ -2709,13 +2732,9 @@ DoTheGrowPagesSpecified
ADD lr, r8, #PageBlockSize
LDMIA lr, {r2, r3} ; get page number, logical address
BL Call_CAM_Mapping ; move replacement page in
76
LDR r2, [r8, #0]
MOV r3, r1
LDR r11, DestFlags
BL Call_CAM_Mapping ; move needed page to destination
BL Call_CAM_Mapping
76
LDR lr, SavedPSR
MSR CPSR_cf, lr
......
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