Bounds checking in MmMarkPage(Un)Mapped, call MmMarkPageMapped from

MmMapIoSpace() for symmetry with MmUnmapIoSpace()

svn path=/trunk/; revision=4938
This commit is contained in:
Gé van Geldorp 2003-06-21 14:30:42 +00:00
parent ba8e03d72f
commit 500b7199f9
2 changed files with 23 additions and 13 deletions

View file

@ -40,6 +40,7 @@ typedef struct _PHYSICAL_PAGE
/* GLOBALS ****************************************************************/
static PPHYSICAL_PAGE MmPageArray;
static ULONG MmPageArraySize;
static KSPIN_LOCK PageListLock;
static LIST_ENTRY UsedPageListHeads[MC_MAXIMUM];
@ -303,8 +304,9 @@ MmInitializePageList(PVOID FirstPhysKernelAddress,
LastKernelAddress = PAGE_ROUND_UP(LastKernelAddress);
MmPageArraySize = MemorySizeInPages;
Reserved =
PAGE_ROUND_UP((MemorySizeInPages * sizeof(PHYSICAL_PAGE))) / PAGE_SIZE;
PAGE_ROUND_UP((MmPageArraySize * sizeof(PHYSICAL_PAGE))) / PAGE_SIZE;
MmPageArray = (PHYSICAL_PAGE *)LastKernelAddress;
DPRINT("Reserved %d\n", Reserved);
@ -490,23 +492,29 @@ MmGetRmapListHeadPage(PHYSICAL_ADDRESS PhysicalAddress)
VOID
MmMarkPageMapped(PHYSICAL_ADDRESS PhysicalAddress)
{
ULONG Start = PhysicalAddress.u.LowPart / PAGE_SIZE;
KIRQL oldIrql;
KeAcquireSpinLock(&PageListLock, &oldIrql);
MmPageArray[Start].MapCount++;
KeReleaseSpinLock(&PageListLock, oldIrql);
ULONG Start = PhysicalAddress.u.LowPart / PAGE_SIZE;
KIRQL oldIrql;
if (Start < MmPageArraySize)
{
KeAcquireSpinLock(&PageListLock, &oldIrql);
MmPageArray[Start].MapCount++;
KeReleaseSpinLock(&PageListLock, oldIrql);
}
}
VOID
MmMarkPageUnmapped(PHYSICAL_ADDRESS PhysicalAddress)
{
ULONG Start = PhysicalAddress.u.LowPart / PAGE_SIZE;
KIRQL oldIrql;
ULONG Start = PhysicalAddress.u.LowPart / PAGE_SIZE;
KIRQL oldIrql;
KeAcquireSpinLock(&PageListLock, &oldIrql);
MmPageArray[Start].MapCount--;
KeReleaseSpinLock(&PageListLock, oldIrql);
if (Start < MmPageArraySize)
{
KeAcquireSpinLock(&PageListLock, &oldIrql);
MmPageArray[Start].MapCount--;
KeReleaseSpinLock(&PageListLock, oldIrql);
}
}
ULONG

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: iospace.c,v 1.18 2003/05/17 15:28:58 ekohl Exp $
/* $Id: iospace.c,v 1.19 2003/06/21 14:30:42 gvg Exp $
*
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/mm/iospace.c
@ -110,6 +110,8 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
DbgPrint("Unable to create virtual mapping\n");
KeBugCheck(0);
}
MmMarkPageMapped((PHYSICAL_ADDRESS) (PhysicalAddress.QuadPart +
(i * PAGE_SIZE)));
}
return ((PVOID)(Result + PhysicalAddress.QuadPart % PAGE_SIZE));
}