kernel/arm/paging: implement Modified Flag

* Introduce SWDBM flag similarly to the arm64 port
* Reuse TEX[2] for SWDBM flag which should be availble
  to be used by the operating system if TEX remap
  is enabled.
* Introduce SetAndClearPageTableEntryFlags for updating
  accessed and modified flags atomically
* Startup sequence is handled similarly to accessed flag, i.e.
  set Modified flag in initially mapped pages in bootloader and early map.
* Once the kernel initialization has progressed enough,
  pages are mapped as read-only and modified flag handling is done
  in the page fault handler.

Change-Id: I8f761e2c6325d1b91481abd569d5e8befded0761
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6518
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
David Karoly
2023-06-18 11:18:24 +00:00
committed by Adrien Destugues
parent 73c451087f
commit b799d160f2
7 changed files with 83 additions and 35 deletions
+8 -6
View File
@@ -60,11 +60,13 @@
#define ARM_MMU_L2_FLAG_S 0x400
#define ARM_MMU_L2_FLAG_NG 0x800
#define ARM_MMU_L2_FLAG_AP_KRW 0x010
// allow read and write for kernel only
#define ARM_MMU_L2_FLAG_HAIKU_SWDBM ARM_MMU_L2_FLAG_TEX2
// reuse TEX[2] for software-emulated Dirty Bit Modifier
#define ARM_MMU_L2_FLAG_AP_RW 0x030
// allow read and write for user and system
#define ARM_MMU_L2_FLAG_HAIKU_KERNEL_RW (ARM_MMU_L2_FLAG_TEX2 | ARM_MMU_L2_FLAG_AP0)
// allow read and write for kernel only
// set Accessed and Modified flag during early page mapping
// as the exception handler may be not available yet
#define ARM_MMU_L1_TABLE_ENTRY_COUNT 4096
#define ARM_MMU_L1_TABLE_SIZE (ARM_MMU_L1_TABLE_ENTRY_COUNT \
@@ -97,7 +99,7 @@
#define ARM_PTE_ADDRESS_MASK 0xfffff000
#define ARM_PTE_TYPE_MASK 0x00000003
#define ARM_PTE_PROTECTION_MASK 0x00000221 // AP[2:1], XN
#define ARM_PTE_MEMORY_TYPE_MASK 0x000001cc // TEX, B, C
#define ARM_PTE_PROTECTION_MASK 0x00000121 // SWDBM, AP[1], XN
#define ARM_PTE_MEMORY_TYPE_MASK 0x0000004c // TEX[0], B, C
#endif /* _ARCH_ARM_ARM_MMU_H */