Author: ros-arm-bringup
Date: Fri Feb 15 23:52:36 2008
New Revision: 32383
URL:
http://svn.reactos.org/svn/reactos?rev=32383&view=rev
Log:
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.
Modified:
trunk/reactos/ntoskrnl/mm/freelist.c
trunk/reactos/ntoskrnl/mm/mminit.c
Modified: trunk/reactos/ntoskrnl/mm/freelist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/freelist.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/freelist.c (original)
+++ trunk/reactos/ntoskrnl/mm/freelist.c Fri Feb 15 23:52:36 2008
@@ -237,6 +237,20 @@
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 @@
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 @@
{
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;
Modified: trunk/reactos/ntoskrnl/mm/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/mminit.c?rev=3…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/mminit.c (original)
+++ trunk/reactos/ntoskrnl/mm/mminit.c Fri Feb 15 23:52:36 2008
@@ -351,8 +351,7 @@
/* 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();