Commit 0830af41 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL

Fixes for zero-size PMPs

OS_DynamicArea 21, 22 & 25 were using the value of the PMP page list
pointer (DANode_PMP) to determine whether the dynamic area is a PMP or
not. However, PMPs which have had their max physical size set to zero
will don't have the page list allocated, which will cause the test to
fail. Normally this won't matter (those calls can't do anything useful
when used on PMPs with zero max size), except for the edge case of where
the SWI has been given a zero-length page list as input. By checking the
value of DANode_PMP, this would result in the calls incorrectly
returning an error.

Fix this by having the code check the DA flags instead. Also, add a
check to OS_DynamicArea 23 (PMP resize), otherwise non-PMP DAs could end
up having page lists allocated for them.
parent 3a26f20e
......@@ -2436,10 +2436,13 @@ DynArea_PMP_PhysOp ROUT
BCC %FT90 ; [it doesn't]
01
; r10 -> DANode
LDR lr, [r10, #DANode_Flags]
TST lr, #DynAreaFlags_PMP
BEQ %FT90
CMP r3, #0 ; early-exit for empty requests
EXIT EQ
LDR r8, [r10, #DANode_PMP]
CMP r8, #0
LDR r9, [r10, #DANode_PMPMaxSize]
BEQ %FT90
BL ClaimCDASemaphore
BNE %FT91
; Before we begin, check to see if there's enough space in the free pool to satisfy any map in requests
......@@ -3015,10 +3018,13 @@ DynArea_PMP_LogOp ROUT
BCC %FT90 ; [it doesn't]
01
; r10 -> DANode
LDR lr, [r10, #DANode_Flags]
TST lr, #DynAreaFlags_PMP
BEQ %FT90
CMP r3, #0 ; early-exit for empty requests
EXIT EQ
LDR r7, [r10, #DANode_PMP]
CMP r7, #0
LDR r9, [r10, #DANode_PMPMaxSize]
BEQ %FT90
BL ClaimCDASemaphore
BNE %FT91
LDR r11, [r10, #DANode_MaxSize]
......@@ -3451,6 +3457,9 @@ DynArea_PMP_Resize ROUT
BCC %FT90 ; [it doesn't]
01
; r10 -> DANode
LDR lr, [r10, #DANode_Flags]
TST lr, #DynAreaFlags_PMP
BEQ %FT90
[ PMPDebug
DebugReg r2, "Resize by: "
]
......@@ -3689,11 +3698,11 @@ DynArea_PMP_GetPages ROUT
]
BCC %FT90 ; [it doesn't]
; r10 -> DANode
LDR r6, [r10, #DANode_PMP]
CMP r6, #0
LDR lr, [r10, #DANode_Flags]
TST lr, #DynAreaFlags_PMP
BEQ %FT90
LDR r6, [r10, #DANode_PMP]
LDR r9, [r10, #DANode_PMPMaxSize]
BEQ %FT90
LDR r11, =ZeroPage
LDR r5, [r10, #DANode_Base]
LDR r7, [r11, #MaxCamEntry]
......
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