mirror of
https://github.com/reactos/reactos.git
synced 2024-07-14 00:25:05 +00:00
- Save original value of the free descriptor we're using to alloc early pages from.
- Fix handling of PFN database pages inside PFN: largest free descriptor does not always end with the highest usable physical page (MmPageArraySize). This removes the need for a "good hack" introduced in revision 32405. As a result, the memory above the largest free descriptor (if it exists) is now correctly marked in the PFN database as free and added to the unzeroed list. svn path=/trunk/; revision=32463
This commit is contained in:
parent
a68d895e4d
commit
fae9aa5c48
|
@ -19,6 +19,7 @@ extern PVOID MmPagedPoolBase;
|
||||||
extern ULONG MmPagedPoolSize;
|
extern ULONG MmPagedPoolSize;
|
||||||
|
|
||||||
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
extern PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
||||||
|
extern MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
||||||
extern ULONG MmHighestPhysicalPage;
|
extern ULONG MmHighestPhysicalPage;
|
||||||
extern PVOID MmPfnDatabase;
|
extern PVOID MmPfnDatabase;
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,13 @@ MiGetPfnEntry(IN PFN_TYPE Pfn)
|
||||||
|
|
||||||
/* Make sure the PFN number is valid */
|
/* Make sure the PFN number is valid */
|
||||||
ASSERT(Pfn <= MmPageArraySize);
|
ASSERT(Pfn <= MmPageArraySize);
|
||||||
|
|
||||||
/* Get the entry */
|
/* Get the entry */
|
||||||
Page = &MmPageArray[Pfn];
|
Page = &MmPageArray[Pfn];
|
||||||
|
|
||||||
/* Make sure it's valid */
|
/* Make sure it's valid */
|
||||||
ASSERT_PFN(Page);
|
ASSERT_PFN(Page);
|
||||||
|
|
||||||
/* Return it */
|
/* Return it */
|
||||||
return Page;
|
return Page;
|
||||||
}
|
}
|
||||||
|
@ -368,20 +368,14 @@ MmInitializePageList(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally handle the pages describing the PFN database themselves */
|
/* Finally handle the pages describing the PFN database themselves */
|
||||||
for (i = (MiFreeDescriptor->BasePage + MiFreeDescriptor->PageCount);
|
for (i = (MiFreeDescriptor->BasePage + MiFreeDescriptor->PageCount);
|
||||||
i <= MmPageArraySize;
|
i < (MiFreeDescriptorOrg.BasePage + MiFreeDescriptorOrg.PageCount);
|
||||||
i++)
|
i++)
|
||||||
{
|
{
|
||||||
/* If this page was marked as free it should be removed from
|
/* Ensure this page was not added previously */
|
||||||
the unzeroed free pages list */
|
ASSERT(MmPageArray[i].Flags.Type == 0);
|
||||||
if (MmPageArray[i].Flags.Type == MM_PHYSICAL_PAGE_FREE)
|
|
||||||
{
|
|
||||||
RemoveEntryList(&MmPageArray[i].ListEntry);
|
|
||||||
UnzeroedPageCount--;
|
|
||||||
MmStats.NrFreePages--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mark it as used kernel memory */
|
/* Mark it as used kernel memory */
|
||||||
MmPageArray[i] = UsedPage;
|
MmPageArray[i] = UsedPage;
|
||||||
|
@ -764,7 +758,7 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SavedSwapEntry)
|
||||||
MiZeroPage(PfnOffset);
|
MiZeroPage(PfnOffset);
|
||||||
return PfnOffset;
|
return PfnOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT1("MmAllocPage(): Out of memory\n");
|
DPRINT1("MmAllocPage(): Out of memory\n");
|
||||||
KeReleaseSpinLock(&PageListLock, oldIrql);
|
KeReleaseSpinLock(&PageListLock, oldIrql);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -55,6 +55,7 @@ ULONG_PTR MiKSeg0Start, MiKSeg0End;
|
||||||
PVOID MmPfnDatabase;
|
PVOID MmPfnDatabase;
|
||||||
ULONG_PTR MmPfnDatabaseEnd;
|
ULONG_PTR MmPfnDatabaseEnd;
|
||||||
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
PMEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptor;
|
||||||
|
MEMORY_ALLOCATION_DESCRIPTOR MiFreeDescriptorOrg;
|
||||||
extern KMUTANT MmSystemLoadLock;
|
extern KMUTANT MmSystemLoadLock;
|
||||||
BOOLEAN MiDbgEnableMdDump =
|
BOOLEAN MiDbgEnableMdDump =
|
||||||
#ifdef _ARM_
|
#ifdef _ARM_
|
||||||
|
@ -246,6 +247,10 @@ MiCountFreePagesInLoaderBlock(PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save original values of the free descriptor, since it'll be
|
||||||
|
altered by early allocations */
|
||||||
|
MiFreeDescriptorOrg = *MiFreeDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
Loading…
Reference in a new issue