mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Do not change the mapping count of a page if the physical address falls
in the range of valid physical memory (in MmMapIoSpace and MmUnmapIoSpace). svn path=/trunk/; revision=9445
This commit is contained in:
parent
a7cf6b254f
commit
4a1429bb28
5 changed files with 38 additions and 107 deletions
|
@ -669,9 +669,5 @@ VOID
|
|||
MmRawDeleteVirtualMapping(PVOID Address);
|
||||
VOID
|
||||
MiStopPagerThread(VOID);
|
||||
NTSTATUS
|
||||
MmCreateVirtualMappingDump(PVOID Address,
|
||||
ULONG flProtect,
|
||||
PHYSICAL_ADDRESS PhysicalAddress);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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: page.c,v 1.65 2004/04/28 20:46:03 hbirr Exp $
|
||||
/* $Id: page.c,v 1.66 2004/05/20 08:37:21 hbirr Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/i386/page.c
|
||||
|
@ -1003,9 +1003,9 @@ BOOLEAN MmIsPageSwapEntry(PEPROCESS Process, PVOID Address)
|
|||
}
|
||||
|
||||
NTSTATUS
|
||||
MmCreateVirtualMappingDump(PVOID Address,
|
||||
ULONG flProtect,
|
||||
PHYSICAL_ADDRESS PhysicalAddress)
|
||||
MmCreateVirtualMappingForKernel(PVOID Address,
|
||||
ULONG flProtect,
|
||||
PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
ULONG Attributes;
|
||||
PULONG Pte;
|
||||
|
@ -1013,7 +1013,7 @@ MmCreateVirtualMappingDump(PVOID Address,
|
|||
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
{
|
||||
DPRINT1("No process\n");
|
||||
DPRINT1("MmCreateVirtualMappingForKernel is called for user space\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
|
||||
|
@ -1031,87 +1031,15 @@ MmCreateVirtualMappingDump(PVOID Address,
|
|||
{
|
||||
return(Status);
|
||||
}
|
||||
if (PAGE_MASK((*Pte)) != 0 && !((*Pte) & PA_PRESENT))
|
||||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
*Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
|
||||
FLUSH_TLB;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
MmCreateVirtualMappingForKernel(PVOID Address,
|
||||
ULONG flProtect,
|
||||
PHYSICAL_ADDRESS PhysicalAddress)
|
||||
{
|
||||
PEPROCESS CurrentProcess;
|
||||
ULONG Attributes;
|
||||
PULONG Pte;
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process = NULL;
|
||||
|
||||
if (Process != NULL)
|
||||
{
|
||||
CurrentProcess = PsGetCurrentProcess();
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentProcess = NULL;
|
||||
}
|
||||
|
||||
if (Process == NULL && Address < (PVOID)KERNEL_BASE)
|
||||
{
|
||||
DPRINT1("No process\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Process != NULL && Address >= (PVOID)KERNEL_BASE)
|
||||
{
|
||||
DPRINT1("Setting kernel address with process context\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
Attributes = ProtectToPTE(flProtect);
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
|
||||
Status = MmGetPageEntry2(Address, &Pte, FALSE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
if (PAGE_MASK((*Pte)) != 0 && !((*Pte) & PA_PRESENT))
|
||||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (PAGE_MASK((*Pte)) != 0)
|
||||
{
|
||||
MmMarkPageUnmapped(PTE_TO_PAGE((*Pte)));
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
|
||||
*Pte = (ULONG)(PhysicalAddress.QuadPart | Attributes);
|
||||
if (Process != NULL &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Address < (PVOID)KERNEL_BASE &&
|
||||
Attributes & PA_PRESENT)
|
||||
{
|
||||
PUSHORT Ptrc;
|
||||
|
||||
Ptrc = Process->AddressSpace.PageTableRefCountTable;
|
||||
|
||||
Ptrc[ADDR_TO_PAGE_TABLE(Address)]++;
|
||||
}
|
||||
FLUSH_TLB;
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.27 2004/05/15 22:45:49 hbirr Exp $
|
||||
/* $Id: iospace.c,v 1.28 2004/05/20 08:37:20 hbirr Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/iospace.c
|
||||
|
@ -126,7 +126,6 @@ MmMapIoSpace (IN PHYSICAL_ADDRESS PhysicalAddress,
|
|||
DbgPrint("Unable to create virtual mapping\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
MmMarkPageMapped(PhysicalAddress);
|
||||
}
|
||||
return ((PVOID)((char*)Result + Offset));
|
||||
}
|
||||
|
|
|
@ -395,28 +395,35 @@ MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace,
|
|||
PHYSICAL_ADDRESS PhysAddr = { 0 };
|
||||
#endif
|
||||
|
||||
BOOL Dirty = FALSE;
|
||||
SWAPENTRY SwapEntry = 0;
|
||||
|
||||
if (MmIsPageSwapEntry(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE)))
|
||||
if (MemoryArea->Type == MEMORY_AREA_IO_MAPPING)
|
||||
{
|
||||
MmDeletePageFileMapping(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
|
||||
&SwapEntry);
|
||||
MmRawDeleteVirtualMapping((char*)MemoryArea->BaseAddress + (i * PAGE_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
MmDeleteVirtualMapping(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i*PAGE_SIZE),
|
||||
FALSE, &Dirty, &PhysAddr);
|
||||
BOOL Dirty = FALSE;
|
||||
SWAPENTRY SwapEntry = 0;
|
||||
|
||||
}
|
||||
if (FreePage != NULL)
|
||||
{
|
||||
FreePage(FreePageContext, MemoryArea,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr,
|
||||
SwapEntry, (BOOLEAN)Dirty);
|
||||
if (MmIsPageSwapEntry(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE)))
|
||||
{
|
||||
MmDeletePageFileMapping(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE),
|
||||
&SwapEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
MmDeleteVirtualMapping(AddressSpace->Process,
|
||||
(char*)MemoryArea->BaseAddress + (i*PAGE_SIZE),
|
||||
FALSE, &Dirty, &PhysAddr);
|
||||
|
||||
}
|
||||
if (FreePage != NULL)
|
||||
{
|
||||
FreePage(FreePageContext, MemoryArea,
|
||||
(char*)MemoryArea->BaseAddress + (i * PAGE_SIZE), PhysAddr,
|
||||
SwapEntry, (BOOLEAN)Dirty);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (AddressSpace->Process != NULL &&
|
||||
|
|
|
@ -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: pagefile.c,v 1.44 2004/04/22 01:57:49 jimtabor Exp $
|
||||
/* $Id: pagefile.c,v 1.45 2004/05/20 08:37:20 hbirr Exp $
|
||||
*
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/pagefile.c
|
||||
|
@ -587,9 +587,9 @@ MmDumpToPagingFile(ULONG BugCode,
|
|||
LARGE_INTEGER PhysicalAddress;
|
||||
PhysicalAddress.QuadPart = i * PAGE_SIZE;
|
||||
MdlMap[0] = i * PAGE_SIZE;
|
||||
MmCreateVirtualMappingDump(MmCoreDumpPageFrame,
|
||||
PAGE_READWRITE,
|
||||
PhysicalAddress);
|
||||
MmCreateVirtualMappingForKernel(MmCoreDumpPageFrame,
|
||||
PAGE_READWRITE,
|
||||
PhysicalAddress);
|
||||
#if defined(__GNUC__)
|
||||
|
||||
DiskOffset = MmGetOffsetPageFile(RetrievalPointers,
|
||||
|
@ -604,6 +604,7 @@ MmDumpToPagingFile(ULONG BugCode,
|
|||
#endif
|
||||
DiskOffset.QuadPart += MmCoreDumpLcnMapping.LcnDiskOffset.QuadPart;
|
||||
Status = MmCoreDumpFunctions->DumpWrite(DiskOffset, Mdl);
|
||||
MmRawDeleteVirtualMapping(MmCoreDumpPageFrame);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("MM: Failed to write page to core dump.\n");
|
||||
|
|
Loading…
Reference in a new issue