Author: sir_richard
Date: Sat Jun 5 16:55:17 2010
New Revision: 47588
URL: http://svn.reactos.org/svn/reactos?rev=47588&view=rev
Log:
[NTOS]: In MiInitializePfnForOtherProcess, should increment the sharecount of the page table PFN entry, not the PFN entry of the PTE itself. Spotted by Stefan100.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Sat Jun 5 16:55:17 2010
@@ -791,7 +791,7 @@
Pfn1->u4.PteFrame = PteFrame;
/* Increase its share count so we don't get rid of it */
- Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1 = MiGetPfnEntry(PteFrame);
Pfn1->u2.ShareCount++;
}
}
Author: sir_richard
Date: Sat Jun 5 16:54:26 2010
New Revision: 47587
URL: http://svn.reactos.org/svn/reactos?rev=47587&view=rev
Log:
[NTOS]: In MiDeleteSystemPageableVm, should also handle the case where the PTE is demand-zero. This can happen if the caller allocated, say, 12KB (3 pages) of paged pool, only touched 4KB (1 page), and then frees the allocation -- the other 2 pages will still be demand-zero at this point.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/virtual.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/virtual.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/virtual.c [iso-8859-1] Sat Jun 5 16:54:26 2010
@@ -64,7 +64,6 @@
/* As always, only handle current ARM3 scenarios */
ASSERT(PointerPte->u.Soft.Prototype == 0);
ASSERT(PointerPte->u.Soft.Transition == 0);
- ASSERT(PointerPte->u.Hard.Valid == 1);
/* Normally this is one possibility -- freeing a valid page */
if (PointerPte->u.Hard.Valid)
@@ -106,6 +105,20 @@
/* Actual legitimate pages */
ActualPages++;
}
+ else
+ {
+ /*
+ * The only other ARM3 possibility is a demand zero page, which would
+ * mean freeing some of the paged pool pages that haven't even been
+ * touched yet, as part of a larger allocation.
+ *
+ * Right now, we shouldn't expect any page file information in the PTE
+ */
+ ASSERT(PointerPte->u.Soft.PageFileHigh == 0);
+
+ /* Destroy the PTE */
+ PointerPte->u.Long = 0;
+ }
/* Keep going */
PointerPte++;
Author: ekohl
Date: Sat Jun 5 14:20:53 2010
New Revision: 47586
URL: http://svn.reactos.org/svn/reactos?rev=47586&view=rev
Log:
[NTOSKRNL]
NtDuplicateToken: Fail, if a primary token is to be created from an impersonation token and and the impersonation level of the impersonation token is below SecurityImpersonation.
Modified:
trunk/reactos/ntoskrnl/se/token.c
Modified: trunk/reactos/ntoskrnl/se/token.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/se/token.c?rev=47…
==============================================================================
--- trunk/reactos/ntoskrnl/se/token.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/se/token.c [iso-8859-1] Sat Jun 5 14:20:53 2010
@@ -1871,6 +1871,21 @@
}
}
+ /*
+ * Fail, if a primary token is to be created from an impersonation token
+ * and and the impersonation level of the impersonation token is below SecurityImpersonation.
+ */
+ if (Token->TokenType == TokenImpersonation &&
+ TokenType == TokenPrimary &&
+ Token->ImpersonationLevel < SecurityImpersonation)
+ {
+ ObDereferenceObject(Token);
+ SepReleaseSecurityQualityOfService(CapturedSecurityQualityOfService,
+ PreviousMode,
+ FALSE);
+ return STATUS_BAD_IMPERSONATION_LEVEL;
+ }
+
Status = SepDuplicateToken(Token,
ObjectAttributes,
EffectiveOnly,
Author: sir_richard
Date: Sat Jun 5 00:08:40 2010
New Revision: 47579
URL: http://svn.reactos.org/svn/reactos?rev=47579&view=rev
Log:
[NTOS]: When expanding paged pool, use MiRemoveAnyPage, not MmAllocPage.
[NTOS]: When expanding paged pool, initialize the PFN entry for the allocated page. Note we might be in arbitrary process space, so the PTE is not necessary valid for the process causing the expansion.
[NTOS]: Implement MiInitializePfnForOtherProcess to handle the case above.
[NTOS]: Change two static ASSERTs into C_ASSERTs. Might break non-x86 builds for a bit (vs breaking them at boot, which is worse).
Paged pool should start working soon.
Modified:
trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
trunk/reactos/ntoskrnl/mm/ARM3/pool.c
Modified: trunk/reactos/ntoskrnl/mm/ARM3/miarm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/miarm.h?r…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/miarm.h [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -708,6 +708,14 @@
VOID
NTAPI
+MiInitializePfnForOtherProcess(
+ IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN PFN_NUMBER PteFrame
+);
+
+VOID
+NTAPI
MiDecrementShareCount(
IN PMMPFN Pfn1,
IN PFN_NUMBER PageFrameIndex
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pagfault.…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pagfault.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -65,7 +65,7 @@
if (PointerPde->u.Hard.Valid == 0)
{
/* This seems to be making the assumption that one PDE is one page long */
- ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
+ C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
//
// Copy it from our double-mapped system page directory
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pfnlist.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -16,6 +16,7 @@
#define MODULE_INVOLVED_IN_ARM3
#include "../ARM3/miarm.h"
+#if DBG
#define ASSERT_LIST_INVARIANT(x) \
do { \
ASSERT(((x)->Total == 0 && \
@@ -25,6 +26,9 @@
(x)->Flink != LIST_HEAD && \
(x)->Blink != LIST_HEAD)); \
} while (0)
+#else
+#define ASSERT_LIST_INVARIANT(x)
+#endif
/* GLOBALS ********************************************************************/
@@ -58,7 +62,6 @@
IN PMMPFN Entry)
{
PFN_NUMBER OldBlink, EntryIndex = MiGetPfnEntryIndex(Entry);
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@@ -133,6 +136,7 @@
/* And now the head points back to us, since we are last */
ListHead->Blink = EntryIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* Update the page location */
Pfn1->u3.e1.PageLocation = ZeroedPageList;
@@ -151,8 +155,6 @@
/* Otherwise check if we reached the high threshold and signal the event */
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0
/* Get the page color */
@@ -328,14 +330,13 @@
}
/* We are not on a list anymore */
+ ASSERT_LIST_INVARIANT(ListHead);
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
/* Zero flags but restore color and cache */
Pfn1->u3.e2.ShortFlags = 0;
Pfn1->u3.e1.PageColor = OldColor;
Pfn1->u3.e1.CacheAttribute = OldCache;
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0 // When switching to ARM3
/* Get the first page on the color list */
@@ -433,11 +434,10 @@
(Pfn1->u3.e1.PageLocation == ZeroedPageList));
ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
ASSERT(Pfn1->u2.ShareCount == 0);
+ ASSERT_LIST_INVARIANT(&MmFreePageListHead);
+ ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
/* Return the page */
- ASSERT_LIST_INVARIANT(&MmFreePageListHead);
- ASSERT_LIST_INVARIANT(&MmZeroedPageListHead);
-
return PageIndex;
}
@@ -447,7 +447,6 @@
{
PFN_NUMBER Entry, Flink;
PMMPFN Pfn1;
-
ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
ASSERT_LIST_INVARIANT(ListHead);
@@ -474,7 +473,6 @@
/* We are not on a list anymore */
Pfn1->u1.Flink = Pfn1->u2.Blink = 0;
ListHead->Total--;
-
ASSERT_LIST_INVARIANT(ListHead);
/* Return the head element */
@@ -529,6 +527,7 @@
/* Now make the list head point back to us (since we go at the end) */
ListHead->Blink = PageFrameIndex;
+ ASSERT_LIST_INVARIANT(ListHead);
/* And initialize our own list pointers */
Pfn1->u1.Flink = LIST_HEAD;
@@ -556,8 +555,6 @@
/* Otherwise check if we reached the high threshold and signal the event */
KeSetEvent(MiHighMemoryEvent, 0, FALSE);
}
-
- ASSERT_LIST_INVARIANT(ListHead);
#if 0 // When using ARM3 PFN
/* Get the page color */
@@ -762,4 +759,41 @@
}
}
+VOID
+NTAPI
+MiInitializePfnForOtherProcess(IN PFN_NUMBER PageFrameIndex,
+ IN PMMPTE PointerPte,
+ IN PFN_NUMBER PteFrame)
+{
+ PMMPFN Pfn1;
+
+ /* Setup the PTE */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->PteAddress = PointerPte;
+
+#if 0 // When using ARM3 PFN
+ /* Make this a software PTE */
+ MI_MAKE_SOFTWARE_PTE(&Pfn1->OriginalPte, MM_READWRITE);
+#endif
+
+ /* Setup the page */
+ ASSERT(Pfn1->u3.e2.ReferenceCount == 0);
+ Pfn1->u3.e2.ReferenceCount = 1;
+ Pfn1->u2.ShareCount = 1;
+ Pfn1->u3.e1.PageLocation = ActiveAndValid;
+ Pfn1->u3.e1.Modified = TRUE;
+ Pfn1->u4.InPageError = FALSE;
+
+ /* Did we get a PFN for the page table */
+ if (PteFrame)
+ {
+ /* Store it */
+ Pfn1->u4.PteFrame = PteFrame;
+
+ /* Increase its share count so we don't get rid of it */
+ Pfn1 = MiGetPfnEntry(PageFrameIndex);
+ Pfn1->u2.ShareCount++;
+ }
+}
+
/* EOF */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/pool.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/pool.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/pool.c [iso-8859-1] Sat Jun 5 00:08:40 2010
@@ -325,20 +325,23 @@
//
ASSERT(PointerPte->u.Hard.Valid == 0);
- //
- // Request a paged pool page and write the PFN for it
- //
- PageFrameNumber = MmAllocPage(MC_PPOOL);
+ /* Request a page */
+ PageFrameNumber = MiRemoveAnyPage(0);
TempPte.u.Hard.PageFrameNumber = PageFrameNumber;
//
// Save it into our double-buffered system page directory
//
/* This seems to be making the assumption that one PDE is one page long */
- ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
+ C_ASSERT(PAGE_SIZE == (PD_COUNT * (sizeof(MMPTE) * PDE_COUNT)));
MmSystemPagePtes[(ULONG_PTR)PointerPte & (PAGE_SIZE - 1) /
sizeof(MMPTE)] = TempPte;
+ /* Initialize the PFN */
+ MiInitializePfnForOtherProcess(PageFrameNumber,
+ PointerPte,
+ MmSystemPageDirectory[(PointerPte - (PMMPTE)PDE_BASE) / PDE_COUNT]);
+
/* Write the actual PTE now */
ASSERT(TempPte.u.Hard.Valid == 1);
*PointerPte++ = TempPte;