Commit 5e3e9d38 authored by Jeffrey Lee's avatar Jeffrey Lee
Browse files

Fix ability for PMPs to claim specific pages

  s/ChangeDyn - Due to the way that some page flags map to the same bits as (different) DA flags, the Batcall that PMP_PreGrow makes in order to claim the requested page was getting confused and thinking that the special DMA PreGrow handler should be used instead of the DA-specific one (which in this case is a custom one responsible for claiming the right page). Modify PMP_PreGrow so that it only supplies DA flags to the Batcall, and patches in any custom page flags afterwards.
  Also swap magic number for appropriate symbol in PMPGrowHandler.
  Tested on BB-xM
  Fixes CAM corruption when a PMP claims a specific page, due to the PMP code and DA code disagreeing about which page should be used

Version 6.00. Tagged as 'Kernel-6_00'
parent e8eb2eba
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "5.99"
Module_Version SETA 599
Module_MajorVersion SETS "6.00"
Module_Version SETA 600
Module_MinorVersion SETS ""
Module_Date SETS "25 Mar 2018"
Module_ApplicationDate SETS "25-Mar-18"
Module_Date SETS "14 Apr 2018"
Module_ApplicationDate SETS "14-Apr-18"
Module_ComponentName SETS "Kernel"
Module_ComponentPath SETS "castle/RiscOS/Sources/Kernel"
Module_FullVersion SETS "5.99"
Module_HelpVersion SETS "5.99 (25 Mar 2018)"
Module_FullVersion SETS "6.00"
Module_HelpVersion SETS "6.00 (14 Apr 2018)"
/* (5.99)
/* (6.00)
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
#define Module_MajorVersion_CMHG 5.99
#define Module_MajorVersion_CMHG 6.00
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Mar 2018
#define Module_Date_CMHG 14 Apr 2018
#define Module_MajorVersion "5.99"
#define Module_Version 599
#define Module_MajorVersion "6.00"
#define Module_Version 600
#define Module_MinorVersion ""
#define Module_Date "25 Mar 2018"
#define Module_Date "14 Apr 2018"
#define Module_ApplicationDate "25-Mar-18"
#define Module_ApplicationDate "14-Apr-18"
#define Module_ComponentName "Kernel"
#define Module_ComponentPath "castle/RiscOS/Sources/Kernel"
#define Module_FullVersion "5.99"
#define Module_HelpVersion "5.99 (25 Mar 2018)"
#define Module_LibraryVersionInfo "5:99"
#define Module_FullVersion "6.00"
#define Module_HelpVersion "6.00 (14 Apr 2018)"
#define Module_LibraryVersionInfo "6:0"
......@@ -632,7 +632,7 @@ PageFlags_Required * 1 :SHL: 21 ; physical pa
PageFlags_Unsafe * 1 :SHL: 31 ; skip cache/TLB maintenance in BangCamUpdate. flag not saved to CAM map.
; Mask to convert DANode_Flags to page flags
; Mask to convert DANode_Flags to page flags (i.e. flags that are common between the two)
DynAreaFlags_AccessMask * DynAreaFlags_APBits :OR: DynAreaFlags_NotBufferable :OR: DynAreaFlags_NotCacheable :OR: DynAreaFlags_DoublyMapped :OR: DynAreaFlags_CPBits :OR: DynAreaFlags_PMP
; PMP LogOp can specify these flags
DynAreaFlags_PMPLogOpAccessMask * (DynAreaFlags_AccessMask :OR: PageFlags_Unavailable) :AND: :NOT: (DynAreaFlags_DoublyMapped :OR: DynAreaFlags_PMP)
......@@ -2516,6 +2516,7 @@ DynArea_PMP_PhysOp ROUT
MOV r0, #-1
STR r0, [r1]
; Add to our PMP
STR r5, [r8, r4, LSL #2]
ADD r5, r7, r5, LSL #CAM_EntrySizeLog2
LDR r0, [r10, #DANode_Flags] ; Use default DA flags, modified by flags given in page list
......@@ -2561,11 +2562,22 @@ DynArea_PMP_PhysOp ROUT
STR r0, [sp, #DANode_Size]
MOV r0, #4096
STR r0, [sp, #DANode_MaxSize]
LDR r0, [sp, #DANode_Flags] ; Use default DA flags, modified by flags given in page list
LDR lr, =DynAreaFlags_AccessMask :AND: :NOT: DynAreaFlags_PMPPhysOpAccessMask
AND r0, r0, lr
ORR r0, r0, r6
; Because we're claiming the page via a Batcall, we need to make sure that the DA flags used for the call are valid as DA flags - i.e. don't touch any pageflags-only flags, because they might overlap the DA flags.
; Once the page is ours we'll fix up the other flags to be as the user requested.
[ (DynAreaFlags_AccessMask :AND: DynAreaFlags_PMPPhysOpAccessMask) <> 0
LDR r0, [sp, #DANode_Flags]
[ PMPDebug
DebugReg r0, "Area flags: "
LDR lr, =DynAreaFlags_AccessMask :AND: DynAreaFlags_PMPPhysOpAccessMask
BIC r0, r0, lr
AND lr, r6, lr
ORR r0, r0, lr
[ PMPDebug
DebugReg r0, "Batcall flags: "
STR r0, [sp, #DANode_Flags]
; Replace handler routine with our own
STR r5, [sp, #DANode_Workspace] ; Required page number is handler param
ADR r0, PMPGrowHandler
......@@ -2582,16 +2594,7 @@ DynArea_PMP_PhysOp ROUT
ADD sp, sp, #DANode_NodeSize
; Everything went OK, remember the new page as being ours
STR r5, [r8, r4, LSL #2]
ADD r5, r7, r5, LSL #CAM_EntrySizeLog2
STR r10, [r5, #CAM_PMP]
STR r4, [r5, #CAM_PMPIndex]
[ PMPDebug
LDR r5, [r5, #CAM_PageFlags]
DebugReg r5, "Claimed with flags: "
ADD r12, r12, #1
B %BT50
B %BT59
BL PMPMemoryMoved
......@@ -2705,7 +2708,7 @@ PMPMemoryMoved ROUT
PMPGrowHandler ROUT
TEQ r0, #0
TEQ r0, #DAHandler_PreGrow
STREQ r12, [r1]
MOV pc, 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