mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 08:00:24 +00:00
[NTOS:MM] Stop inserting fake MEMORY_AREAs for ARM³ VADs
They were introduced when MEMROY_AREAs and VAD still lived in different tables to synchronize between them. Since some time MEMORY_AREAs are special VADs and live in the same table as ARM³ VADs, but with flags to distinguish them. Since then the only reason that the fake MEMORY_AREAs still existed was to determine whether a VAD that is a MEMORY_AREA is still handled by ARM³ (which is the case for some kernel VADs, like for paged pool). This is no longer required as it is now determined by a 2nd flag in the VAD itself. Additionally, we tried to insert the fake MEMORY_AREAs into the VAD table, which would fail, because it was already occupied by the ARM³ VAD, but the failure was ignored.
This commit is contained in:
parent
2696f1a29f
commit
7ec2e1cd2f
2 changed files with 8 additions and 114 deletions
|
@ -211,54 +211,10 @@ MiInsertNode(IN PMM_AVL_TABLE Table,
|
|||
IN PMMADDRESS_NODE Parent,
|
||||
IN TABLE_SEARCH_RESULT Result)
|
||||
{
|
||||
PMMVAD_LONG Vad;
|
||||
|
||||
ASSERT_LOCKED_FOR_WRITE(Table);
|
||||
|
||||
/* Insert it into the tree */
|
||||
RtlpInsertAvlTreeNode(Table, NewNode, Parent, Result);
|
||||
|
||||
/* Now insert an ARM3 MEMORY_AREA for this node, unless the insert was already from the MEMORY_AREA code */
|
||||
Vad = (PMMVAD_LONG)NewNode;
|
||||
if (!MI_IS_MEMORY_AREA_VAD(Vad))
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PMEMORY_AREA MemoryArea;
|
||||
SIZE_T Size;
|
||||
PEPROCESS Process = CONTAINING_RECORD(Table, EPROCESS, VadRoot);
|
||||
PVOID AllocatedBase = (PVOID)(Vad->StartingVpn << PAGE_SHIFT);
|
||||
|
||||
Size = ((Vad->EndingVpn + 1) - Vad->StartingVpn) << PAGE_SHIFT;
|
||||
|
||||
if (AllocatedBase == NULL)
|
||||
{
|
||||
AllocatedBase = (PVOID)(ULONG_PTR)1;
|
||||
Size -= 1;
|
||||
}
|
||||
|
||||
Status = MmCreateMemoryArea(&Process->Vm,
|
||||
MEMORY_AREA_OWNED_BY_ARM3,
|
||||
&AllocatedBase,
|
||||
Size,
|
||||
PAGE_READWRITE,
|
||||
&MemoryArea,
|
||||
0,
|
||||
PAGE_SIZE);
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
|
||||
/* Check if this is VM VAD */
|
||||
if (Vad->ControlArea == NULL)
|
||||
{
|
||||
/* We store the reactos MEMORY_AREA here */
|
||||
Vad->FirstPrototypePte = (PMMPTE)MemoryArea;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a section VAD. Store the MAREA here for now */
|
||||
ASSERT(Vad->u4.Banked == (PVOID)(ULONG_PTR)0xDEADBABEDEADBABEULL);
|
||||
Vad->u4.Banked = (PVOID)MemoryArea;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID
|
||||
|
@ -447,8 +403,6 @@ NTAPI
|
|||
MiRemoveNode(IN PMMADDRESS_NODE Node,
|
||||
IN PMM_AVL_TABLE Table)
|
||||
{
|
||||
PMMVAD_LONG Vad;
|
||||
|
||||
ASSERT_LOCKED_FOR_WRITE(Table);
|
||||
|
||||
/* Call the AVL code */
|
||||
|
@ -464,55 +418,6 @@ MiRemoveNode(IN PMMADDRESS_NODE Node,
|
|||
if (!Table->NumberGenericTableElements) Table->NodeHint = NULL;
|
||||
else Table->NodeHint = Table->BalancedRoot.RightChild;
|
||||
}
|
||||
|
||||
/* Free the node from ReactOS view as well */
|
||||
Vad = (PMMVAD_LONG)Node;
|
||||
if ((Table != &MmSectionBasedRoot) && !MI_IS_MEMORY_AREA_VAD(Vad))
|
||||
{
|
||||
PMEMORY_AREA MemoryArea;
|
||||
PEPROCESS Process;
|
||||
|
||||
/* Check if this is VM VAD */
|
||||
if (Vad->ControlArea == NULL)
|
||||
{
|
||||
/* We store the ReactOS MEMORY_AREA here */
|
||||
MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a section VAD. We store the ReactOS MEMORY_AREA here */
|
||||
MemoryArea = (PMEMORY_AREA)Vad->u4.Banked;
|
||||
}
|
||||
|
||||
/* Make sure one actually still exists */
|
||||
if (MemoryArea)
|
||||
{
|
||||
/* Make sure we have not already freed it */
|
||||
ASSERT(MemoryArea != (PVOID)(ULONG_PTR)0xDEADBAB1DEADBAB1ULL);
|
||||
|
||||
/* Get the process */
|
||||
Process = CONTAINING_RECORD(Table, EPROCESS, VadRoot);
|
||||
|
||||
/* We only create fake memory-areas for ARM3 VADs */
|
||||
ASSERT(MemoryArea->Type == MEMORY_AREA_OWNED_BY_ARM3);
|
||||
ASSERT(MemoryArea->Vad == NULL);
|
||||
|
||||
/* Free it */
|
||||
MmFreeMemoryArea(&Process->Vm, MemoryArea, NULL, NULL);
|
||||
|
||||
/* Check if this is VM VAD */
|
||||
if (Vad->ControlArea == NULL)
|
||||
{
|
||||
/* Delete the pointer to it */
|
||||
Vad->FirstPrototypePte = (PVOID)(ULONG_PTR)0xDEADBAB1DEADBAB1ULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Delete the pointer to it */
|
||||
Vad->u4.Banked = (PVOID)(ULONG_PTR)0xDEADBAB1DEADBAB1ULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PMMADDRESS_NODE
|
||||
|
|
|
@ -94,17 +94,8 @@ MmLocateMemoryAreaByRegion(
|
|||
Vad = (PMMVAD_LONG)Node;
|
||||
if (!MI_IS_MEMORY_AREA_VAD(Vad))
|
||||
{
|
||||
/* Check if this is VM VAD */
|
||||
if (Vad->ControlArea == NULL)
|
||||
{
|
||||
/* We store the reactos MEMORY_AREA here */
|
||||
MemoryArea = (PMEMORY_AREA)Vad->FirstPrototypePte;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is a section VAD. Store the MAREA here for now */
|
||||
MemoryArea = (PMEMORY_AREA)Vad->u4.Banked;
|
||||
}
|
||||
/* This is an ARM3 VAD, we don't return it. */
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -332,15 +323,13 @@ MmFreeMemoryArea(
|
|||
ASSERT(MemoryArea->Type == MEMORY_AREA_SECTION_VIEW);
|
||||
#endif
|
||||
|
||||
/* MmCleanProcessAddressSpace might have removed it (and this would be MmDeleteProcessAddressSpace) */
|
||||
/* We do not have fake ARM3 memory areas anymore. */
|
||||
ASSERT(MI_IS_MEMORY_AREA_VAD(&MemoryArea->VadNode));
|
||||
if (MI_IS_MEMORY_AREA_VAD((PMMVAD)MemoryArea->Vad))
|
||||
{
|
||||
ASSERT((PMMVAD)MemoryArea->Vad == &MemoryArea->VadNode);
|
||||
MiLockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot);
|
||||
MiUnlockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||
}
|
||||
ASSERT(MI_IS_MEMORY_AREA_VAD((PMMVAD)MemoryArea->Vad));
|
||||
ASSERT((PMMVAD)MemoryArea->Vad == &MemoryArea->VadNode);
|
||||
MiLockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||
MiRemoveNode((PMMADDRESS_NODE)&MemoryArea->VadNode, &Process->VadRoot);
|
||||
MiUnlockProcessWorkingSet(PsGetCurrentProcess(), PsGetCurrentThread());
|
||||
|
||||
MemoryArea->Vad = NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue