Things we need to accomplish
- Layer rmap, balance, page and freelist so that reference and dereference calls are properly paired in every case.
- Reduce the width of the mm interface and the number of moving parts.
- Provide a simpler API that will be easier to analyze.
Things I now know
- MapCount is now added to ReferenceCount, since dereference on a mapped page is not legal.
- ReferenceCount must be at least one if .Flags.Type is MM_PHYSICAL_PAGE_USED and zero if .Flags.Type is MM_PHYSICAL_PAGE_FREE. Suggestion: roll these states into ReferenceCount and make MM_PHYSICAL_PAGE_BIOS a flag.
- Pages start free and are freed by the Trim functions called by the balance manager. Pages can have ownership transferred, but we should remove this early optimization and focus on correctness.
- Several functions now ignore out of bounds accesses to the MmPageArray. We need to make those bugcheck and catch the offenders.