Skip to content

Commit 007d126

Browse files
committed
[NTOSKRNL] Change how system PTEs are calculated
1 parent d7dfeec commit 007d126

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

ntoskrnl/mm/ARM3/i386/init.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -305,26 +305,34 @@ MiInitMachineDependent(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
305305
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart &
306306
~(PDE_MAPPED_VA - 1));
307307

308-
//
309-
// Don't let it go below the minimum
310-
//
311-
if (MmNonPagedSystemStart < (PVOID)0xEB000000)
308+
309+
310+
PVOID PagedPoolEnd = (PVOID)((ULONG_PTR)MmPagedPoolStart +
311+
MmSizeOfPagedPoolInBytes - 1);
312+
313+
if (MmNonPagedSystemStart < PagedPoolEnd)
312314
{
313315
//
314-
// This is a hard-coded limit in the Windows NT address space
316+
// Calculate the maximum system PTE area start that fits between
317+
// paged pool end and nonpaged pool start.
315318
//
316-
MmNonPagedSystemStart = (PVOID)0xEB000000;
319+
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)PagedPoolEnd &
320+
~(PDE_MAPPED_VA - 1));
321+
if ((ULONG_PTR)MmNonPagedSystemStart <= (ULONG_PTR)PagedPoolEnd)
322+
{
323+
MmNonPagedSystemStart = (PVOID)((ULONG_PTR)MmNonPagedSystemStart + PDE_MAPPED_VA);
324+
}
317325

318326
//
319-
// Reduce the amount of system PTEs to reach this point
327+
// Ensure we still have space for system PTEs
320328
//
321-
MmNumberOfSystemPtes = ((ULONG_PTR)MmNonPagedPoolStart -
322-
(ULONG_PTR)MmNonPagedSystemStart) >>
323-
PAGE_SHIFT;
324-
MmNumberOfSystemPtes--;
325-
ASSERT(MmNumberOfSystemPtes > 1000);
329+
if ((ULONG_PTR)MmNonPagedSystemStart >= (ULONG_PTR)MmNonPagedPoolStart)
330+
{
331+
DPRINT1("FATAL: Paged pool overlaps with nonpaged pool! No space for system PTEs.\n");
332+
ASSERT(FALSE);
333+
}
326334
}
327-
335+
328336
//
329337
// Check if we are in a situation where the size of the paged pool
330338
// is so large that it overflows into nonpaged pool

0 commit comments

Comments
 (0)