Change page file PTE format to distinguish paged out pages from

noaccess pages. It fixes kernel crash at the end of Sun JRE setup.

svn path=/trunk/; revision=39681
This commit is contained in:
Dmitry Gorbachev 2009-02-19 11:47:34 +00:00
parent 4f7122ff29
commit e884b38e1f
2 changed files with 12 additions and 10 deletions

View file

@ -671,7 +671,7 @@ BOOLEAN
NTAPI NTAPI
MmIsPagePresent(PEPROCESS Process, PVOID Address) MmIsPagePresent(PEPROCESS Process, PVOID Address)
{ {
return MmGetPageEntryForProcess(Process, Address) & PA_PRESENT ? TRUE : FALSE; return MmGetPageEntryForProcess(Process, Address) & PA_PRESENT;
} }
BOOLEAN BOOLEAN
@ -680,7 +680,7 @@ MmIsPageSwapEntry(PEPROCESS Process, PVOID Address)
{ {
ULONG Entry; ULONG Entry;
Entry = MmGetPageEntryForProcess(Process, Address); Entry = MmGetPageEntryForProcess(Process, Address);
return !(Entry & PA_PRESENT) && Entry != 0 ? TRUE : FALSE; return !(Entry & PA_PRESENT) && (Entry & 0x800) && Entry != 0;
} }
NTSTATUS NTSTATUS
@ -841,7 +841,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
if (PageCount > 0x10000 || if (PageCount > 0x10000 ||
(ULONG_PTR) Address / PAGE_SIZE + PageCount > 0x100000) (ULONG_PTR) Address / PAGE_SIZE + PageCount > 0x100000)
{ {
DPRINT1("Page count to large\n"); DPRINT1("Page count too large\n");
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
} }
} }
@ -856,7 +856,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
(ULONG_PTR) Address / PAGE_SIZE + PageCount > (ULONG_PTR) Address / PAGE_SIZE + PageCount >
(ULONG_PTR)MmSystemRangeStart / PAGE_SIZE) (ULONG_PTR)MmSystemRangeStart / PAGE_SIZE)
{ {
DPRINT1("Page Count to large\n"); DPRINT1("Page Count too large\n");
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
} }
} }
@ -909,13 +909,14 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
Pte = *Pt; Pte = *Pt;
MmMarkPageMapped(Pages[i]); MmMarkPageMapped(Pages[i]);
if (PAGE_MASK((Pte)) != 0 && !((Pte) & PA_PRESENT)) if (PAGE_MASK(Pte) != 0 && !(Pte & PA_PRESENT) && (Pte & 0x800))
{ {
DPRINT1("Bad PTE %lx\n", Pte);
KeBugCheck(MEMORY_MANAGEMENT); KeBugCheck(MEMORY_MANAGEMENT);
} }
if (PAGE_MASK((Pte)) != 0) if (PAGE_MASK(Pte) != 0)
{ {
MmMarkPageUnmapped(PTE_TO_PFN((Pte))); MmMarkPageUnmapped(PTE_TO_PFN(Pte));
} }
InterlockedExchangePte(Pt, PFN_TO_PTE(Pages[i]) | Attributes); InterlockedExchangePte(Pt, PFN_TO_PTE(Pages[i]) | Attributes);
if (Pte != 0) if (Pte != 0)
@ -1014,6 +1015,7 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
Process, Address, flProtect); Process, Address, flProtect);
Attributes = ProtectToPTE(flProtect); Attributes = ProtectToPTE(flProtect);
if (Attributes & 0x80000000) if (Attributes & 0x80000000)
{ {
NoExecute = TRUE; NoExecute = TRUE;

View file

@ -117,9 +117,9 @@ ULONG MmCoreDumpType = MM_CORE_DUMP_TYPE_NONE;
/* /*
* Translate between a swap entry and a file and offset pair. * Translate between a swap entry and a file and offset pair.
*/ */
#define FILE_FROM_ENTRY(i) ((i) >> 24) #define FILE_FROM_ENTRY(i) ((i) & 0x0f)
#define OFFSET_FROM_ENTRY(i) (((i) & 0xffffff) - 1) #define OFFSET_FROM_ENTRY(i) ((i) >> 11)
#define ENTRY_FROM_FILE_OFFSET(i, j) (((i) << 24) | ((j) + 1)) #define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | (j) << 11 | 0x400)
static BOOLEAN MmSwapSpaceMessage = FALSE; static BOOLEAN MmSwapSpaceMessage = FALSE;