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

OS_DynamicArea 22 fixes

Multiple fixes, mostly related to error handling.

1. Ensure R1 is initialised correctly when generating BadPageNumber
errors (labels 94 & 95). Generally this involves setting it to zero to
indicate that no call to LogOp_MapOut is required. Failing to do this
would typically result in a crash.
2. When branching back to the start of the loop after calling
GetNonReservedPage, ensure R0 is reset to zero. Failing to do this would
have a performance impact on LogOp_MapOut, but shouldn't be fatal.
3. In the main routine, postpone writing back DANode_Size until after
the call to physical_to_ppn (because we may decide to abort the op
and return an error without moving a page).
4. Fix stack offset when accessing PMPLogOp_GlobalTBLFlushNeeded.
Getting this wrong could potentially result in some TLB maintenance
being skipped when moving uncacheable pages.
5. Fix stack imbalance at label 94

Version 6.43. Tagged as 'Kernel-6_43'
parent 5e131c13
......@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate
GBLS Module_HelpVersion
GBLS Module_ComponentName
Module_MajorVersion SETS "6.42"
Module_Version SETA 642
Module_MajorVersion SETS "6.43"
Module_Version SETA 643
Module_MinorVersion SETS ""
Module_Date SETS "25 Jul 2020"
Module_ApplicationDate SETS "25-Jul-20"
Module_Date SETS "19 Sep 2020"
Module_ApplicationDate SETS "19-Sep-20"
Module_ComponentName SETS "Kernel"
Module_FullVersion SETS "6.42"
Module_HelpVersion SETS "6.42 (25 Jul 2020)"
Module_FullVersion SETS "6.43"
Module_HelpVersion SETS "6.43 (19 Sep 2020)"
END
/* (6.42)
/* (6.43)
*
* This file is automatically maintained by srccommit, do not edit manually.
*
*/
#define Module_MajorVersion_CMHG 6.42
#define Module_MajorVersion_CMHG 6.43
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Jul 2020
#define Module_Date_CMHG 19 Sep 2020
#define Module_MajorVersion "6.42"
#define Module_Version 642
#define Module_MajorVersion "6.43"
#define Module_Version 643
#define Module_MinorVersion ""
#define Module_Date "25 Jul 2020"
#define Module_Date "19 Sep 2020"
#define Module_ApplicationDate "25-Jul-20"
#define Module_ApplicationDate "19-Sep-20"
#define Module_ComponentName "Kernel"
#define Module_FullVersion "6.42"
#define Module_HelpVersion "6.42 (25 Jul 2020)"
#define Module_LibraryVersionInfo "6:42"
#define Module_FullVersion "6.43"
#define Module_HelpVersion "6.43 (19 Sep 2020)"
#define Module_LibraryVersionInfo "6:43"
......@@ -3111,12 +3111,12 @@ DynArea_PMP_LogOp ROUT
; Request to map in - examine CAM to see if the page is already at the
; requested location (with requested flags)
CMP r5, r9
BHS %FT95
BHS %FT950
LDR r0, =ZeroPage
LDR r5, [r7, r5, LSL #2]
LDR r0, [r0, #CamEntriesPointer]
CMP r5, #-1
BEQ %FT95
BEQ %FT950
ASSERT CAM_LogAddr=0
ASSERT CAM_PageFlags=4
ADD r0, r0, r5, LSL #CAM_EntrySizeLog2
......@@ -3148,12 +3148,13 @@ DynArea_PMP_LogOp ROUT
LDREQ lr, [r2, #8]
TSTEQ lr, #PageFlags_Reserved ; Or was Reserved specified in the page list?
BNE %FT55 ; Then we're fine
; Attempting to claim a Reserved pag without the proper permission.
; Attempting to claim a Reserved page without the proper permission.
; Try and swap in a replacement page.
MOV r0, r5
BL GetNonReservedPage
MOV r0, #0 ; Reinit LogOp_MapOut counters
MOV r1, #0
BVC %BT06
BVC %BT06 ; Retry this entry
B %FT96
55
Push "r2-r4,r6,r9,r11"
......@@ -3172,8 +3173,8 @@ DynArea_PMP_LogOp ROUT
BL logical_to_physical
ADDCS r1, r1, #4096
BICCC r6, r6, #PageFlags_Unsafe
STR r1, [r10, #DANode_Size]
BCC %FT57
STR r1, [r10, #DANode_Size]
[ PMPDebug
DebugTX "Nothing at dest addr"
]
......@@ -3186,11 +3187,13 @@ DynArea_PMP_LogOp ROUT
57
; There's already a page at the target address. Unmap it before we
; replace it (BangCamUpdate isn't smart enough to do this for us)
MOV r0, r10
Push "r2,r4,r6,r7,r10"
LDR r2, =ZeroPage
LDR r7, [r2, #MaxCamEntry]
BL physical_to_ppn
BCS %FT94
STR r1, [r0, #DANode_Size]
[ PMPDebug
DebugReg r3, "Unmapping existing page first "
]
......@@ -3201,7 +3204,7 @@ DynArea_PMP_LogOp ROUT
LDR r11, [r11, #CAM_PageFlags] ; Preserve flags
; We should be able to make this an unsafe op if the page isn't cacheable. But to avoid global TLB flushes when only one or two pages are being unmapped, only make it unsafe if we've already scheduled a global flush.
TST r11, #DynAreaFlags_NotCacheable
LDRNE r7, [sp, #:INDEX:PMPLogOp_GlobalTLBFlushNeeded + 6*4 + 4*4]
LDRNE r7, [sp, #:INDEX:PMPLogOp_GlobalTLBFlushNeeded + 6*4 + 5*4]
TEQNE r7, #0
ORRNE r11, r11, #PageFlags_Unsafe
BL BangCamUpdate
......@@ -3221,7 +3224,7 @@ DynArea_PMP_LogOp ROUT
BL BangCamUpdate
Pull "r2-r4,r6,r9,r11"
65
MOV r0, #0
MOV r0, #0 ; Reinit LogOp_MapOut counters
MOV r1, #0
ADD r2, r2, #12
SUBS r3, r3, #1
......@@ -3293,8 +3296,10 @@ DynArea_PMP_LogOp ROUT
[ PMPDebug
DebugTX "-> failed to find page which is currently mapped in"
]
Pull "r2,r4,r6,r7"
Pull "r2,r4,r6,r7,r10"
Pull "r2-r4,r6,r9,r11"
950
MOV r1, #0 ; Don't call LogOp_MapOut
95
[ PMPDebug
DebugTX "-> bad logop page number"
......
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