mirror of
https://github.com/reactos/reactos.git
synced 2024-08-20 18:35:32 +00:00
[NTOS]: One last fix to the zero page thread before we move to ARM3: use MiRemoveAnyPage instead of dangerous MiRemoveHeadList. The code works on the assumption (validated by Windows through a bug check) that MiRemoveAnyPage always returns the first free page, and we also manually grab the first free page, and compare this is true. Nice way to detect PFN database corruption.
[NTOS]: Fix MiInsertZeroAtBack to increment the MmAvailablePage count, since MiRemoveAnyPage decrements it (MiRemoveHeadList did not). svn path=/trunk/; revision=48918
This commit is contained in:
parent
66ff3d5774
commit
354ad6b9eb
|
@ -156,8 +156,8 @@ MiInsertZeroListAtBack(IN PFN_NUMBER EntryIndex)
|
||||||
/* Update the page location */
|
/* Update the page location */
|
||||||
Pfn1->u3.e1.PageLocation = ZeroedPageList;
|
Pfn1->u3.e1.PageLocation = ZeroedPageList;
|
||||||
|
|
||||||
/* FIXME: NOT YET Due to caller semantics: Update the available page count */
|
/* Update the available page count */
|
||||||
//MmAvailablePages++;
|
MmAvailablePages++;
|
||||||
|
|
||||||
/* Check if we've reached the configured low memory threshold */
|
/* Check if we've reached the configured low memory threshold */
|
||||||
if (MmAvailablePages == MmLowMemoryThreshold)
|
if (MmAvailablePages == MmLowMemoryThreshold)
|
||||||
|
|
|
@ -631,8 +631,8 @@ MmZeroPageThreadMain(PVOID Ignored)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
KIRQL oldIrql;
|
KIRQL oldIrql;
|
||||||
PPHYSICAL_PAGE PageDescriptor;
|
PMMPFN Pfn1;
|
||||||
PFN_NUMBER Pfn;
|
PFN_NUMBER PageIndex, FreePage;
|
||||||
ULONG Count;
|
ULONG Count;
|
||||||
PVOID ZeroAddress;
|
PVOID ZeroAddress;
|
||||||
|
|
||||||
|
@ -660,21 +660,30 @@ MmZeroPageThreadMain(PVOID Ignored)
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
while (MmFreePageListHead.Total)
|
while (MmFreePageListHead.Total)
|
||||||
{
|
{
|
||||||
PageDescriptor = MiRemoveHeadList(&MmFreePageListHead);
|
PageIndex = MmFreePageListHead.Flink;
|
||||||
Pfn = MiGetPfnEntryIndex(PageDescriptor);
|
Pfn1 = MiGetPfnEntry(PageIndex);
|
||||||
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
FreePage = MiRemoveAnyPage(0); // FIXME: Use real color
|
||||||
|
if (FreePage != PageIndex)
|
||||||
PageDescriptor->u1.Flink = LIST_HEAD;
|
{
|
||||||
ZeroAddress = MiMapPagesToZeroInHyperSpace(PageDescriptor, 1);
|
KeBugCheckEx(PFN_LIST_CORRUPT,
|
||||||
ASSERT(ZeroAddress);
|
0x8F,
|
||||||
RtlZeroMemory(ZeroAddress, PAGE_SIZE);
|
FreePage,
|
||||||
MiUnmapPagesInZeroSpace(ZeroAddress, 1);
|
PageIndex,
|
||||||
|
0);
|
||||||
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
}
|
||||||
|
|
||||||
|
Pfn1->u1.Flink = LIST_HEAD;
|
||||||
|
KeReleaseQueuedSpinLock(LockQueuePfnLock, oldIrql);
|
||||||
|
|
||||||
|
ZeroAddress = MiMapPagesToZeroInHyperSpace(Pfn1, 1);
|
||||||
|
ASSERT(ZeroAddress);
|
||||||
|
RtlZeroMemory(ZeroAddress, PAGE_SIZE);
|
||||||
|
MiUnmapPagesInZeroSpace(ZeroAddress, 1);
|
||||||
|
|
||||||
|
oldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock);
|
||||||
|
|
||||||
MiInsertZeroListAtBack(Pfn);
|
MiInsertZeroListAtBack(PageIndex);
|
||||||
Count++;
|
Count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
DPRINT("Zeroed %d pages.\n", Count);
|
DPRINT("Zeroed %d pages.\n", Count);
|
||||||
KeResetEvent(&ZeroPageThreadEvent);
|
KeResetEvent(&ZeroPageThreadEvent);
|
||||||
|
|
Loading…
Reference in a new issue