Author: jgardou Date: Tue Nov 15 18:36:26 2011 New Revision: 54386
URL: http://svn.reactos.org/svn/reactos?rev=54386&view=rev Log: [NTOSKRNL/MM] - call mm functions with a process, when we have one. - Fix potential rounding issues - Add some sanity ASSERTs - You never use enough brackets ;-)
Modified: trunk/reactos/ntoskrnl/mm/anonmem.c trunk/reactos/ntoskrnl/mm/freelist.c trunk/reactos/ntoskrnl/mm/marea.c trunk/reactos/ntoskrnl/mm/pagefile.c
Modified: trunk/reactos/ntoskrnl/mm/anonmem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/anonmem.c?rev=5... ============================================================================== --- trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/anonmem.c [iso-8859-1] Tue Nov 15 18:36:26 2011 @@ -183,7 +183,7 @@ * address space when another thread could load the page so we check * that. */ - if (MmIsPagePresent(NULL, Address)) + if (MmIsPagePresent(Process, Address)) { return(STATUS_SUCCESS); } @@ -301,7 +301,7 @@ /* * Handle swapped out pages. */ - if (MmIsPageSwapEntry(NULL, Address)) + if (MmIsPageSwapEntry(Process, Address)) { SWAPENTRY SwapEntry;
@@ -327,7 +327,7 @@ { MmUnlockAddressSpace(AddressSpace); Status = MmCreateVirtualMapping(Process, - Address, + (PVOID)PAGE_ROUND_DOWN(Address), Region->Protect, &Page, 1);
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 [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/freelist.c [iso-8859-1] Tue Nov 15 18:36:26 2011 @@ -92,6 +92,7 @@ /* Set the page as a user page */ ASSERT(Pfn != 0); ASSERT_IS_ROS_PFN(MiGetPfnEntry(Pfn)); + ASSERT(!RtlCheckBit(&MiUserPfnBitMap, (ULONG)Pfn)); OldIrql = KeAcquireQueuedSpinLock(LockQueuePfnLock); RtlSetBit(&MiUserPfnBitMap, (ULONG)Pfn); KeReleaseQueuedSpinLock(LockQueuePfnLock, OldIrql); @@ -123,6 +124,7 @@ /* Unset the page as a user page */ ASSERT(Page != 0); ASSERT_IS_ROS_PFN(MiGetPfnEntry(Page)); + ASSERT(RtlCheckBit(&MiUserPfnBitMap, (ULONG)Page)); RtlClearBit(&MiUserPfnBitMap, (ULONG)Page); }
Modified: trunk/reactos/ntoskrnl/mm/marea.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/marea.c?rev=543... ============================================================================== --- trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/marea.c [iso-8859-1] Tue Nov 15 18:36:26 2011 @@ -893,7 +893,7 @@ Granularity = (MEMORY_AREA_VIRTUAL_MEMORY == Type ? MM_VIRTMEM_GRANULARITY : PAGE_SIZE); if ((*BaseAddress) == 0 && !FixedAddress) { - tmpLength = PAGE_ROUND_UP(Length); + tmpLength = (ULONG_PTR)MM_ROUND_UP(Length, Granularity); *BaseAddress = MmFindGap(AddressSpace, tmpLength, Granularity, @@ -908,6 +908,7 @@ { tmpLength = Length + ((ULONG_PTR) *BaseAddress - (ULONG_PTR) MM_ROUND_DOWN(*BaseAddress, Granularity)); + tmpLength = (ULONG_PTR)MM_ROUND_UP(tmpLength, Granularity); *BaseAddress = MM_ROUND_DOWN(*BaseAddress, Granularity);
if (!MmGetAddressSpaceOwner(AddressSpace) && *BaseAddress < MmSystemRangeStart) @@ -986,6 +987,8 @@ { ULONG i; NTSTATUS Status; + + ASSERT(((ULONG_PTR)BaseAddress % PAGE_SIZE) == 0);
for (i = 0; i < PAGE_ROUND_UP(Length) / PAGE_SIZE; i++) {
Modified: trunk/reactos/ntoskrnl/mm/pagefile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/pagefile.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/mm/pagefile.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/pagefile.c [iso-8859-1] Tue Nov 15 18:36:26 2011 @@ -113,7 +113,7 @@ */ #define FILE_FROM_ENTRY(i) ((i) & 0x0f) #define OFFSET_FROM_ENTRY(i) ((i) >> 11) -#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | (j) << 11 | 0x400) +#define ENTRY_FROM_FILE_OFFSET(i, j) ((i) | ((j) << 11) | 0x400)
static BOOLEAN MmSwapSpaceMessage = FALSE;