On systems with large enough memory (or lots of drivers already loaded), we actually need another PDE to hold the new PTEs to represent the PFN database, since we go past the initial PDEs that come from FreeLDR. On those systems, we would try allocating a new page to hold the PDE, and crash, since the PFN database isn't setup. We now have an MmAllocPageEarly routine which is called during Mm bootstrapping to resolve this issue.

svn path=/trunk/; revision=32383
This commit is contained in:
ReactOS Portable Systems Group 2008-02-15 20:52:36 +00:00
parent 8f7384d246
commit 8a623c61d3
2 changed files with 24 additions and 4 deletions

View file

@ -237,6 +237,20 @@ MmGetContinuousPages(ULONG NumberOfBytes,
return 0;
}
PFN_TYPE
NTAPI
MmAllocEarlyPage(VOID)
{
PFN_TYPE Pfn;
/* Use one of our highest usable pages */
Pfn = MiFreeDescriptor->BasePage + MiFreeDescriptor->PageCount - 1;
MiFreeDescriptor->PageCount--;
/* Return it */
return Pfn;
}
VOID
NTAPI
MmInitializePageList(VOID)
@ -269,8 +283,7 @@ MmInitializePageList(VOID)
if (!MmIsPagePresent(NULL, Address))
{
/* Use one of our highest usable pages */
Pfn = MiFreeDescriptor->BasePage + MiFreeDescriptor->PageCount - 1;
MiFreeDescriptor->PageCount--;
Pfn = MmAllocEarlyPage();
/* Set the PFN */
Status = MmCreateVirtualMappingForKernel(Address,
@ -733,6 +746,14 @@ MmAllocPage(ULONG Consumer, SWAPENTRY SavedSwapEntry)
{
if (IsListEmpty(&FreeUnzeroedPageListHead))
{
/* Check if this allocation is for the PFN DB itself */
if (MmStats.NrTotalPages == 0)
{
/* Allocate an early page -- we'll account for it later */
KeReleaseSpinLock(&PageListLock, oldIrql);
return MmAllocEarlyPage();
}
DPRINT1("MmAllocPage(): Out of memory\n");
KeReleaseSpinLock(&PageListLock, oldIrql);
return 0;

View file

@ -351,8 +351,7 @@ MmInit1(VOID)
/* Count RAM */
MiCountFreePagesInLoaderBlock(KeLoaderBlock);
MmStats.NrTotalPages = MmNumberOfPhysicalPages;
DbgPrint("Used memory %dKb\n", (MmStats.NrTotalPages * PAGE_SIZE) / 1024);
DbgPrint("Used memory %dKb\n", (MmNumberOfPhysicalPages * PAGE_SIZE) / 1024);
/* Initialize the kernel address space */
MmInitializeKernelAddressSpace();