ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2020
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
22 participants
156 discussions
Start a n
N
ew thread
[reactos] 01/12: [CMAKE] CMakeParseArguments is not needed anymore, cmake_parse_arguments is a builtin since CMake 3.5
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=980ce77316eb3de9b50e6…
commit 980ce77316eb3de9b50e6106a7af9aa28e93415b Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Sep 17 10:05:02 2020 +0200 Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com> CommitDate: Tue Oct 20 21:44:54 2020 +0200 [CMAKE] CMakeParseArguments is not needed anymore, cmake_parse_arguments is a builtin since CMake 3.5 --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a128b804842..ce1995e3b80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,9 +111,6 @@ else() set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) - #useful stuff! - include(CMakeParseArguments) - if(DBG) add_definitions(-DDBG=1 -D_SEH_ENABLE_TRACE) else()
4 years, 2 months
1
0
0
0
[reactos] 02/02: Revert "[NTOS/MM] Initialize process Working set and start implementing adding entries to it"
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15dd31377a2fb33c06a21…
commit 15dd31377a2fb33c06a2116d8f780e516dbacea4 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Oct 20 15:56:53 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:56:53 2020 +0200 Revert "[NTOS/MM] Initialize process Working set and start implementing adding entries to it" This reverts commit 5abc016401a59dfb60944ea1fc8ea5ed27f7f087. Not ready for prime time --- ntoskrnl/mm/ARM3/miarm.h | 4 -- ntoskrnl/mm/ARM3/pfnlist.c | 1 - ntoskrnl/mm/ARM3/procsup.c | 172 +++++---------------------------------------- sdk/include/ndk/mmtypes.h | 17 ----- 4 files changed, 17 insertions(+), 177 deletions(-) diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index 6df6b7e5385..9d85c42afff 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1054,10 +1054,6 @@ MI_WS_OWNER(IN PEPROCESS Process) (PsGetCurrentThread()->OwnsProcessWorkingSetShared))); } -VOID -NTAPI -MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection); - // // New ARM3<->RosMM PAGE Architecture // diff --git a/ntoskrnl/mm/ARM3/pfnlist.c b/ntoskrnl/mm/ARM3/pfnlist.c index b039a5181a2..f175541a500 100644 --- a/ntoskrnl/mm/ARM3/pfnlist.c +++ b/ntoskrnl/mm/ARM3/pfnlist.c @@ -1003,7 +1003,6 @@ MiInitializePfn(IN PFN_NUMBER PageFrameIndex, Pfn1->u3.e1.PageLocation = ActiveAndValid; ASSERT(Pfn1->u3.e1.Rom == 0); Pfn1->u3.e1.Modified = Modified; - Pfn1->u1.WsIndex = 0; /* Get the page table for the PTE */ PointerPtePte = MiAddressToPte(PointerPte); diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index ab01d902686..6407b7896d0 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -840,108 +840,6 @@ MmCreateTeb(IN PEPROCESS Process, return Status; } -static -ULONG -MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) -{ - PMMWSL WsList = Vm->VmWorkingSetList; - - /* Some sanity checks */ - ASSERT((WsList->FirstFree <= WsList->LastInitializedWsle) || (WsList->FirstFree == MMWSLE_NEXT_FREE_INVALID)); - ASSERT(WsList->LastEntry <= WsList->LastInitializedWsle + 1); - - /* Check if we are initializing */ - if (WsList->LastEntry == 0) - { - ASSERT(WsList->FirstDynamic < WsList->LastInitializedWsle); - return WsList->FirstDynamic++; - } - - if (WsList->FirstFree == MMWSLE_NEXT_FREE_INVALID) - { - if (WsList->LastEntry == WsList->LastInitializedWsle) - { - /* We must grow our array. Allocate a new page */ - PMMPTE PointerPte = MiAddressToPte(&WsList->Wsle[WsList->LastInitializedWsle + 1]); - MMPTE TempPte; - PFN_NUMBER PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); - - MiInitializePfn(PageFrameIndex, PointerPte, TRUE); - MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, MM_READWRITE, PageFrameIndex); - MI_WRITE_VALID_PTE(PointerPte, TempPte); - - WsList->LastInitializedWsle += PAGE_SIZE / sizeof(MMWSLE); - - /* We must insert this page in our working set ! */ - MiInsertInWorkingSetList(Vm, &WsList->Wsle[WsList->LastInitializedWsle], MM_READWRITE); - } - - /* At this point we must be good to go */ - ASSERT(WsList->LastEntry < WsList->LastInitializedWsle); - - return ++WsList->LastEntry; - } - else - { - ULONG WsIndex = WsList->FirstFree; - PMMWSLE WsleEntry = &WsList->Wsle[WsIndex]; - - ASSERT(WsIndex < WsList->LastEntry); - - ASSERT(WsleEntry->u1.Free.MustBeZero == 0); - ASSERT(WsleEntry->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID); - ASSERT(WsleEntry->u1.Free.NextFree > WsIndex); - - if (WsleEntry->u1.Free.NextFree != MMWSLE_NEXT_FREE_INVALID) - { - PMMWSLE_FREE_ENTRY NextFree = &WsList->Wsle[WsleEntry->u1.Free.NextFree].u1.Free; - - ASSERT(NextFree->MustBeZero == 0); - ASSERT(NextFree->PreviousFree == WsList->FirstFree); - NextFree->PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; - } - - WsList->FirstFree = WsleEntry->u1.Free.NextFree; - - return WsIndex; - } -} - -VOID -NTAPI -MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection) -{ - ULONG WsIndex = MiGetFirstFreeWsleIndex(Vm); - PMMWSLE WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; - PMMPTE PointerPte = MiAddressToPte(Address); - PMMPFN Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); - - /* Make sure we got a rounded address */ - Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); - - /* Make sure we are locking the right thing */ - ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); - - /* The Pfn must be an active one */ - ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); - - WsleEntry->u1.Long = 0; - WsleEntry->u1.VirtualAddress = Address; - WsleEntry->u1.e1.Protection = Protection; - - /* Shared pages not supported yet */ - ASSERT(Pfn1->u1.WsIndex == 0); - WsleEntry->u1.e1.Direct = 1; - - Pfn1->u1.WsIndex = WsIndex; - WsleEntry->u1.e1.Valid = 1; - - Vm->WorkingSetSize += PAGE_SIZE; - if (Vm->WorkingSetSize > Vm->PeakWorkingSetSize) - Vm->PeakWorkingSetSize = Vm->WorkingSetSize; -} - - VOID NTAPI MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) @@ -950,56 +848,30 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) PMMPTE sysPte; MMPTE tempPte; - /* We start with the space left behind us */ - MmWorkingSetList->Wsle = (PMMWSLE)(MmWorkingSetList + 1); - /* Which leaves us this much entries */ - MmWorkingSetList->LastInitializedWsle = ((PAGE_SIZE - sizeof(MMWSL)) / sizeof(MMWSLE)) - 1; - - /* No entry in this list yet ! */ - MmWorkingSetList->LastEntry = 0; + /* Setup some bogus list data */ + MmWorkingSetList->LastEntry = CurrentProcess->Vm.MinimumWorkingSetSize; MmWorkingSetList->HashTable = NULL; MmWorkingSetList->HashTableSize = 0; MmWorkingSetList->NumberOfImageWaiters = 0; - MmWorkingSetList->VadBitMapHint = 0; - MmWorkingSetList->HashTableStart = NULL; - MmWorkingSetList->HighestPermittedHashAddress = NULL; - MmWorkingSetList->FirstFree = MMWSLE_NEXT_FREE_INVALID; - MmWorkingSetList->FirstDynamic = 0; - MmWorkingSetList->NextSlot = 0; - - /* Map the process working set in kernel space */ - /* FIXME: there should be no need */ - sysPte = MiReserveSystemPtes(1, SystemPteSpace); - MI_MAKE_HARDWARE_PTE_KERNEL(&tempPte, sysPte, MM_READWRITE, CurrentProcess->WorkingSetPage); - MI_WRITE_VALID_PTE(sysPte, tempPte); - CurrentProcess->Vm.VmWorkingSetList = MiPteToAddress(sysPte); - - /* Insert the address we already know: our PDE base and the Working Set List */ -#if _MI_PAGING_LEVELS == 4 - MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PXE_BASE, 0); -#elif _MI_PAGING_LEVELS == 3 - MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PPE_BASE, 0); -#elif _MI_PAGING_LEVELS == 2 - MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PDE_BASE, 0); -#endif - -#if _MI_PAGING_LEVELS == 4 - MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPpe(MmWorkingSetList), 0); -#endif -#if _MI_PAGING_LEVELS >= 3 - MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPde(MmWorkingSetList), 0); -#endif - MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPte(MmWorkingSetList), 0); - MiInsertInWorkingSetList(&CurrentProcess->Vm, MmWorkingSetList, 0); + MmWorkingSetList->Wsle = (PVOID)(ULONG_PTR)0xDEADBABEDEADBABEULL; + MmWorkingSetList->VadBitMapHint = 1; + MmWorkingSetList->HashTableStart = (PVOID)(ULONG_PTR)0xBADAB00BBADAB00BULL; + MmWorkingSetList->HighestPermittedHashAddress = (PVOID)(ULONG_PTR)0xCAFEBABECAFEBABEULL; + MmWorkingSetList->FirstFree = 1; + MmWorkingSetList->FirstDynamic = 2; + MmWorkingSetList->NextSlot = 3; + MmWorkingSetList->LastInitializedWsle = 4; /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */ Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT); ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); - ASSERT(Pfn1->u1.WsIndex == 0); Pfn1->u1.Event = (PKEVENT)CurrentProcess; - /* Mark this as not initializing anymore */ - MmWorkingSetList->LastEntry = MmWorkingSetList->FirstDynamic - 1; + /* Map the process working set in kernel space */ + sysPte = MiReserveSystemPtes(1, SystemPteSpace); + MI_MAKE_HARDWARE_PTE_KERNEL(&tempPte, sysPte, MM_READWRITE, CurrentProcess->WorkingSetPage); + MI_WRITE_VALID_PTE(sysPte, tempPte); + CurrentProcess->Vm.VmWorkingSetList = MiPteToAddress(sysPte); } NTSTATUS @@ -1043,17 +915,12 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, ASSERT(Process->VadRoot.NumberGenericTableElements == 0); Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot; - /* Lock our working set */ - MiLockProcessWorkingSet(Process, PsGetCurrentThread()); - /* Lock PFN database */ OldIrql = MiAcquirePfnLock(); /* Setup the PFN for the PDE base of this process */ -#if _MI_PAGING_LEVELS == 4 +#ifdef _M_AMD64 PointerPte = MiAddressToPte(PXE_BASE); -#elif _MI_PAGING_LEVELS == 3 - PointerPte = MiAddressToPte(PPE_BASE); #else PointerPte = MiAddressToPte(PDE_BASE); #endif @@ -1062,10 +929,8 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, MiInitializePfn(PageFrameNumber, PointerPte, TRUE); /* Do the same for hyperspace */ -#if _MI_PAGING_LEVELS == 4 +#ifdef _M_AMD64 PointerPde = MiAddressToPxe((PVOID)HYPER_SPACE); -#elif _MI_PAGING_LEVELS == 3 - PointerPde = MiAddressToPpe((PVOID)HYPER_SPACE); #else PointerPde = MiAddressToPde(HYPER_SPACE); #endif @@ -1092,9 +957,6 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, /* Release PFN lock */ MiReleasePfnLock(OldIrql); - /* Release the process working set */ - MiUnlockProcessWorkingSet(Process, PsGetCurrentThread()); - /* Check if there's a Section Object */ if (SectionObject) { diff --git a/sdk/include/ndk/mmtypes.h b/sdk/include/ndk/mmtypes.h index 06d088bf5ab..ca62ebdf5ce 100644 --- a/sdk/include/ndk/mmtypes.h +++ b/sdk/include/ndk/mmtypes.h @@ -844,22 +844,6 @@ typedef struct _MMWSLENTRY ULONG_PTR VirtualPageNumber: MM_PAGE_FRAME_NUMBER_SIZE; } MMWSLENTRY, *PMMWSLENTRY; -typedef struct _MMWSLE_FREE_ENTRY -{ - ULONG MustBeZero:1; -#ifdef _WIN64 - ULONG PreviousFree: 31; - ULONG NextFree; -#define MMWSLE_PREVIOUS_FREE_INVALID 0x7FFFFFFF -#define MMWSLE_NEXT_FREE_INVALID 0xFFFFFFFF -#else - ULONG PreviousFree: 15; - ULONG NextFree: 16; -#define MMWSLE_PREVIOUS_FREE_INVALID 0x7FFF -#define MMWSLE_NEXT_FREE_INVALID 0xFFFF -#endif -} MMWSLE_FREE_ENTRY, *PMMWSLE_FREE_ENTRY; - typedef struct _MMWSLE { union @@ -867,7 +851,6 @@ typedef struct _MMWSLE PVOID VirtualAddress; ULONG_PTR Long; MMWSLENTRY e1; - MMWSLE_FREE_ENTRY Free; } u1; } MMWSLE, *PMMWSLE;
4 years, 2 months
1
0
0
0
[reactos] 01/02: Revert "[NTOS/MM] - Fix PFNs tracing - Add private pages to the process working set"
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1c528cbf84379837b0d44…
commit 1c528cbf84379837b0d44303e7d2e7ca0201827c Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Oct 20 15:56:21 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:56:21 2020 +0200 Revert "[NTOS/MM] - Fix PFNs tracing - Add private pages to the process working set" This reverts commit 4c5351bf55527a35bce09446420dd7296eedbe99. Not ready for prime time --- ntoskrnl/cc/view.c | 20 ++++ ntoskrnl/include/internal/mm.h | 44 +-------- ntoskrnl/mm/ARM3/miarm.h | 4 - ntoskrnl/mm/ARM3/mminit.c | 4 +- ntoskrnl/mm/ARM3/pagfault.c | 69 +++----------- ntoskrnl/mm/ARM3/pfnlist.c | 13 +-- ntoskrnl/mm/ARM3/procsup.c | 212 +---------------------------------------- ntoskrnl/mm/ARM3/sysldr.c | 9 +- ntoskrnl/mm/ARM3/virtual.c | 40 ++++---- ntoskrnl/mm/freelist.c | 15 --- ntoskrnl/mm/i386/page.c | 6 -- ntoskrnl/mm/marea.c | 5 +- ntoskrnl/mm/section.c | 11 +++ 13 files changed, 88 insertions(+), 364 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index c576997f943..fde2bbc926a 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -665,6 +665,7 @@ CcRosMapVacbInKernelSpace( { PFN_NUMBER PageFrameNumber; + MI_SET_USAGE(MI_USAGE_CACHE); Status = MmRequestPageMemoryConsumer(MC_CACHE, TRUE, &PageFrameNumber); if (PageFrameNumber == 0) { @@ -906,6 +907,25 @@ Retry: InsertTailList(&VacbLruListHead, ¤t->VacbLruListEntry); KeReleaseQueuedSpinLock(LockQueueMasterLock, oldIrql); + MI_SET_USAGE(MI_USAGE_CACHE); +#if MI_TRACE_PFNS + if ((SharedCacheMap->FileObject) && (SharedCacheMap->FileObject->FileName.Buffer)) + { + PWCHAR pos; + ULONG len = 0; + pos = wcsrchr(SharedCacheMap->FileObject->FileName.Buffer, '\\'); + if (pos) + { + len = wcslen(pos) * sizeof(WCHAR); + snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos); + } + else + { + snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%wZ", &SharedCacheMap->FileObject->FileName); + } + } +#endif + /* Reference it to allow release */ CcRosVacbIncRefCount(current); diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index d2ead92df1f..32fd7b1146d 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -2,8 +2,6 @@ #include <internal/arch/mm.h> -#define MI_TRACE_PFNS 1 - /* TYPES *********************************************************************/ struct _EPROCESS; @@ -250,45 +248,9 @@ MM_RMAP_ENTRY, *PMM_RMAP_ENTRY; extern ULONG MI_PFN_CURRENT_USAGE; extern CHAR MI_PFN_CURRENT_PROCESS_NAME[16]; #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x -#define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, min(sizeof(x), sizeof(MI_PFN_CURRENT_PROCESS_NAME))) -FORCEINLINE -void -MI_SET_PROCESS(PEPROCESS Process) -{ - if (!Process) - MI_SET_PROCESS2("Kernel"); - else if (Process == (PEPROCESS)1) - MI_SET_PROCESS2("Hydra"); - else - MI_SET_PROCESS2(Process->ImageFileName); -} - -FORCEINLINE -void -MI_SET_PROCESS_USTR(PUNICODE_STRING ustr) -{ - PWSTR pos, strEnd; - int i; - - if (!ustr->Buffer || ustr->Length == 0) - { - MI_PFN_CURRENT_PROCESS_NAME[0] = 0; - return; - } - - pos = strEnd = &ustr->Buffer[ustr->Length / sizeof(WCHAR)]; - while ((*pos != L'\\') && (pos > ustr->Buffer)) - pos--; - - if (*pos == L'\\') - pos++; - - for (i = 0; i < sizeof(MI_PFN_CURRENT_PROCESS_NAME) && pos <= strEnd; i++, pos++) - MI_PFN_CURRENT_PROCESS_NAME[i] = (CHAR)*pos; -} +#define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16) #else #define MI_SET_USAGE(x) -#define MI_SET_PROCESS(x) #define MI_SET_PROCESS2(x) #endif @@ -316,9 +278,6 @@ typedef enum _MI_PFN_USAGES MI_USAGE_PFN_DATABASE, MI_USAGE_BOOT_DRIVER, MI_USAGE_INIT_MEMORY, - MI_USAGE_PAGE_FILE, - MI_USAGE_COW, - MI_USAGE_WSLE, MI_USAGE_FREE_PAGE } MI_PFN_USAGES; @@ -399,7 +358,6 @@ typedef struct _MMPFN #if MI_TRACE_PFNS MI_PFN_USAGES PfnUsage; CHAR ProcessName[16]; -#define MI_SET_PFN_PROCESS_NAME(pfn, x) memcpy(pfn->ProcessName, x, min(sizeof(x), sizeof(pfn->ProcessName))) #endif // HACK until WS lists are supported diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index a30e9957874..6df6b7e5385 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1058,10 +1058,6 @@ VOID NTAPI MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection); -VOID -NTAPI -MiRemoveFromWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address); - // // New ARM3<->RosMM PAGE Architecture // diff --git a/ntoskrnl/mm/ARM3/mminit.c b/ntoskrnl/mm/ARM3/mminit.c index 3c724d8ea3e..0bae38e3e02 100644 --- a/ntoskrnl/mm/ARM3/mminit.c +++ b/ntoskrnl/mm/ARM3/mminit.c @@ -801,7 +801,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1->u3.e1.CacheAttribute = MiNonCached; #if MI_TRACE_PFNS Pfn1->PfnUsage = MI_USAGE_INIT_MEMORY; - MI_SET_PFN_PROCESS_NAME(Pfn1, "Initial PDE"); + memcpy(Pfn1->ProcessName, "Initial PDE", 16); #endif } else @@ -848,7 +848,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn2->u3.e1.CacheAttribute = MiNonCached; #if MI_TRACE_PFNS Pfn2->PfnUsage = MI_USAGE_INIT_MEMORY; - MI_SET_PFN_PROCESS_NAME(Pfn2, "Initial PTE"); + memcpy(Pfn1->ProcessName, "Initial PTE", 16); #endif } } diff --git a/ntoskrnl/mm/ARM3/pagfault.c b/ntoskrnl/mm/ARM3/pagfault.c index a487d3a1ba2..1ab109e9f65 100644 --- a/ntoskrnl/mm/ARM3/pagfault.c +++ b/ntoskrnl/mm/ARM3/pagfault.c @@ -697,6 +697,16 @@ MiResolveDemandZeroFault(IN PVOID Address, /* Increment demand zero faults */ KeGetCurrentPrcb()->MmDemandZeroCount++; + /* Do we have the lock? */ + if (HaveLock) + { + /* Release it */ + MiReleasePfnLock(OldIrql); + + /* Update performance counters */ + if (Process > HYDRA_PROCESS) Process->NumberOfPrivatePages++; + } + /* Zero the page if need be */ if (NeedZero) MiZeroPfn(PageFrameNumber); @@ -735,23 +745,6 @@ MiResolveDemandZeroFault(IN PVOID Address, ASSERT(Pfn1->u3.e1.PrototypePte == 0); } - /* Add the page to our working set, if it's not a proto PTE */ - if ((Process > HYDRA_PROCESS) && (PointerPte == MiAddressToPte(Address))) - { - /* FIXME: Also support session VM scenario */ - MiInsertInWorkingSetList(&Process->Vm, Address, Protection); - } - - /* Do we have the lock? */ - if (HaveLock) - { - /* Release it */ - MiReleasePfnLock(OldIrql); - - /* Update performance counters */ - if (Process > HYDRA_PROCESS) Process->NumberOfPrivatePages++; - } - // // It's all good now // @@ -906,9 +899,6 @@ MiResolvePageFileFault(_In_ BOOLEAN StoreInstruction, ASSERT(CurrentProcess > HYDRA_PROCESS); ASSERT(*OldIrql != MM_NOIRQL); - MI_SET_USAGE(MI_USAGE_PAGE_FILE); - MI_SET_PROCESS(CurrentProcess); - /* We must hold the PFN lock */ MI_ASSERT_PFN_LOCK_HELD(); @@ -969,9 +959,6 @@ MiResolvePageFileFault(_In_ BOOLEAN StoreInstruction, KeSetEvent(Pfn1->u1.Event, IO_NO_INCREMENT, FALSE); } - /* And we can insert this into the working set */ - MiInsertInWorkingSetList(&CurrentProcess->Vm, FaultingAddress, Protection); - return Status; } @@ -989,8 +976,6 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, PMMPFN Pfn1; MMPTE TempPte; PMMPTE PointerToPteForProtoPage; - ULONG Protection; - DPRINT("Transition fault on 0x%p with PTE 0x%p in process %s\n", FaultingAddress, PointerPte, CurrentProcess->ImageFileName); @@ -1084,9 +1069,8 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, ASSERT(PointerPte->u.Hard.Valid == 0); ASSERT(PointerPte->u.Trans.Prototype == 0); ASSERT(PointerPte->u.Trans.Transition == 1); - Protection = TempPte.u.Trans.Protection; TempPte.u.Long = (PointerPte->u.Long & ~0xFFF) | - (MmProtectToPteMask[Protection]) | + (MmProtectToPteMask[PointerPte->u.Trans.Protection]) | MiDetermineUserGlobalPteMask(PointerPte); /* Is the PTE writeable? */ @@ -1106,10 +1090,6 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, /* Write the valid PTE */ MI_WRITE_VALID_PTE(PointerPte, TempPte); - /* If this was a user fault, add it to the working set */ - if (CurrentProcess > HYDRA_PROCESS) - MiInsertInWorkingSetList(&CurrentProcess->Vm, FaultingAddress, Protection); - /* Return success */ return STATUS_PAGE_FAULT_TRANSITION; } @@ -1230,9 +1210,6 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, ASSERT(TempPte.u.Hard.Valid == 1); ProtoPageFrameIndex = PFN_FROM_PTE(&TempPte); - MI_SET_USAGE(MI_USAGE_COW); - MI_SET_PROCESS(Process); - /* Get a new page for the private copy */ if (Process > HYDRA_PROCESS) Color = MI_GET_NEXT_PROCESS_COLOR(Process); @@ -1268,13 +1245,6 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, /* And finally, write the valid PTE */ MI_WRITE_VALID_PTE(PointerPte, PteContents); - /* Add the page to our working set */ - if (Process > HYDRA_PROCESS) - { - /* FIXME: Also support session VM scenario */ - MiInsertInWorkingSetList(&Process->Vm, Address, Protection); - } - /* The caller expects us to release the PFN lock */ MiReleasePfnLock(OldIrql); return Status; @@ -2235,15 +2205,11 @@ UserFault: { PFN_NUMBER PageFrameIndex, OldPageFrameIndex; PMMPFN Pfn1; - ProtectionCode = TempPte.u.Soft.Protection; LockIrql = MiAcquirePfnLock(); ASSERT(MmAvailablePages > 0); - MI_SET_USAGE(MI_USAGE_COW); - MI_SET_PROCESS(CurrentProcess); - /* Allocate a new page and copy it */ PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_PROCESS_COLOR(CurrentProcess)); OldPageFrameIndex = PFN_FROM_PTE(&TempPte); @@ -2265,9 +2231,6 @@ UserFault: MI_WRITE_VALID_PTE(PointerPte, TempPte); - /* We can now add it to our working set */ - MiInsertInWorkingSetList(&CurrentProcess->Vm, Address, ProtectionCode); - MiReleasePfnLock(LockIrql); /* Return the status */ @@ -2384,7 +2347,6 @@ UserFault: TempPte.u.Soft.Protection = ProtectionCode; MI_WRITE_INVALID_PTE(PointerPte, TempPte); } - ProtectionCode = PointerPte->u.Soft.Protection; /* Lock the PFN database since we're going to grab a page */ OldIrql = MiAcquirePfnLock(); @@ -2422,6 +2384,9 @@ UserFault: /* One more demand-zero fault */ KeGetCurrentPrcb()->MmDemandZeroCount++; + /* And we're done with the lock */ + MiReleasePfnLock(OldIrql); + /* Fault on user PDE, or fault on user PTE? */ if (PointerPte <= MiHighestUserPte) { @@ -2448,12 +2413,6 @@ UserFault: Pfn1 = MI_PFN_ELEMENT(PageFrameIndex); ASSERT(Pfn1->u1.Event == NULL); - /* We can now insert it into the working set */ - MiInsertInWorkingSetList(&CurrentProcess->Vm, Address, ProtectionCode); - - /* And we're done with the lock */ - MiReleasePfnLock(OldIrql); - /* Demand zero */ ASSERT(KeGetCurrentIrql() <= APC_LEVEL); MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); diff --git a/ntoskrnl/mm/ARM3/pfnlist.c b/ntoskrnl/mm/ARM3/pfnlist.c index 866a29cd15f..b039a5181a2 100644 --- a/ntoskrnl/mm/ARM3/pfnlist.c +++ b/ntoskrnl/mm/ARM3/pfnlist.c @@ -254,8 +254,8 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); Entry->PfnUsage = MI_PFN_CURRENT_USAGE; memcpy(Entry->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16); - MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; - MI_SET_PROCESS2("Not Set"); +// MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; +// memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16); #endif } @@ -459,11 +459,11 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, MiDecrementAvailablePages(); #if MI_TRACE_PFNS - ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); + //ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); Pfn1->PfnUsage = MI_PFN_CURRENT_USAGE; memcpy(Pfn1->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16); - MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; - MI_SET_PROCESS2("Not Set"); + //MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; + //memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16); #endif /* Return the page */ @@ -937,8 +937,9 @@ MiInsertPageInList(IN PMMPFNLIST ListHead, ColorHead->Count++; #if MI_TRACE_PFNS - ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET); + //ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET); Pfn1->PfnUsage = MI_USAGE_FREE_PAGE; + MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; RtlZeroMemory(Pfn1->ProcessName, 16); #endif } diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index 2e4d9029d36..ab01d902686 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -6,8 +6,6 @@ * PROGRAMMERS: ReactOS Portable Systems Group */ -#define GROW_WSLE 1 - /* INCLUDES *******************************************************************/ #include <ntoskrnl.h> @@ -864,34 +862,18 @@ MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) if (WsList->LastEntry == WsList->LastInitializedWsle) { /* We must grow our array. Allocate a new page */ - PVOID Address = &WsList->Wsle[WsList->LastInitializedWsle + 1]; - PMMPTE PointerPte = MiAddressToPte(Address); + PMMPTE PointerPte = MiAddressToPte(&WsList->Wsle[WsList->LastInitializedWsle + 1]); MMPTE TempPte; - - MI_SET_USAGE(MI_USAGE_WSLE); - MI_SET_PROCESS(PsGetCurrentProcess()); - - /* We must be at page boundary */ - ASSERT(Address == ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE)); - PFN_NUMBER PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); MiInitializePfn(PageFrameIndex, PointerPte, TRUE); - - TempPte = ValidKernelPteLocal; - TempPte.u.Hard.PageFrameNumber = PageFrameIndex; + MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, MM_READWRITE, PageFrameIndex); MI_WRITE_VALID_PTE(PointerPte, TempPte); WsList->LastInitializedWsle += PAGE_SIZE / sizeof(MMWSLE); - /* Make sure we are staying on the same page */ - ASSERT(Address == ALIGN_DOWN_POINTER_BY(&WsList->Wsle[WsList->LastInitializedWsle], PAGE_SIZE)); - /* We must insert this page in our working set ! */ MiInsertInWorkingSetList(Vm, &WsList->Wsle[WsList->LastInitializedWsle], MM_READWRITE); - - /* Now the last entry is the tail of our WSLE array */ - ASSERT(WsList->Wsle[WsList->LastEntry].u1.e1.VirtualPageNumber == ((ULONG_PTR)&WsList->Wsle[WsList->LastInitializedWsle]) >> PAGE_SHIFT); } /* At this point we must be good to go */ @@ -927,26 +909,18 @@ MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) VOID NTAPI -MiInsertInWorkingSetList( - _Inout_ PMMSUPPORT Vm, - _In_ PVOID Address, - _In_ ULONG Protection) +MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection) { ULONG WsIndex = MiGetFirstFreeWsleIndex(Vm); PMMWSLE WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; PMMPTE PointerPte = MiAddressToPte(Address); - PMMPFN Pfn1; + PMMPFN Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); /* Make sure we got a rounded address */ Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); - /* Make sure we are locking the right things */ + /* Make sure we are locking the right thing */ ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); - MI_ASSERT_PFN_LOCK_HELD(); - - /* Make sure we are adding a paged-in address */ - ASSERT(PointerPte->u.Hard.Valid == 1); - Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); /* The Pfn must be an active one */ ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); @@ -957,11 +931,6 @@ MiInsertInWorkingSetList( /* Shared pages not supported yet */ ASSERT(Pfn1->u1.WsIndex == 0); - ASSERT(Pfn1->u3.e1.PrototypePte == 0); - - /* Nor are "ROS PFN" */ - ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); - WsleEntry->u1.e1.Direct = 1; Pfn1->u1.WsIndex = WsIndex; @@ -972,177 +941,6 @@ MiInsertInWorkingSetList( Vm->PeakWorkingSetSize = Vm->WorkingSetSize; } -static -void -MiShrinkWorkingSet(_Inout_ PMMSUPPORT Vm) -{ - PMMWSL WsList = Vm->VmWorkingSetList; - ULONG LastValid = WsList->LastEntry; - - while(WsList->Wsle[LastValid].u1.e1.Valid == 0) - { - LastValid--; - } - - if (LastValid != WsList->LastEntry) - { - /* There was a hole behind us. Handle this */ - PMMWSLE NextFree = &WsList->Wsle[LastValid + 1]; - if (NextFree->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID) - { - /* This was actually our first free entry. */ - ASSERT(WsList->FirstFree == LastValid + 1); - WsList->FirstFree = MMWSLE_NEXT_FREE_INVALID; - } - else - { - /* The previous one is now the last in the queue */ - PMMWSLE PreviousFree = &WsList->Wsle[NextFree->u1.Free.PreviousFree]; - - ASSERT(PreviousFree->u1.Free.MustBeZero == 0); - PreviousFree->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; - } - - /* Nuke everyone */ - RtlZeroMemory(&WsList->Wsle[LastValid + 1], (WsList->LastEntry - LastValid) * sizeof(MMWSLE)); - WsList->LastEntry = LastValid; - } - - if (LastValid < WsList->FirstDynamic) - { - /* Do not mess around with the protected ones */ - return; - } - - /* See if we should shrink our array */ - if (LastValid == (WsList->LastInitializedWsle - (PAGE_SIZE / sizeof(MMWSLE)) + 1)) - { - PVOID WsleArrayQueue = ALIGN_DOWN_POINTER_BY(&WsList->Wsle[LastValid], PAGE_SIZE); - PEPROCESS Process = MmGetAddressSpaceOwner(Vm); - - ASSERT(WsList->Wsle[WsList->LastEntry].u1.e1.VirtualPageNumber == ((ULONG_PTR)WsleArrayQueue) >> PAGE_SHIFT); - - /* Kernel address space not supported yet */ - ASSERT(Process != NULL); - - /* Nuke the PTE. This will remove the virtual address from the working set */ - MiDeletePte(MiAddressToPte(WsleArrayQueue), WsleArrayQueue, Process, NULL); - } -} - -VOID -NTAPI -MiRemoveFromWorkingSetList( - _Inout_ PMMSUPPORT Vm, - _In_ PVOID Address) -{ - PMMWSL WsList = Vm->VmWorkingSetList; - ULONG WsIndex; - PMMWSLE WsleEntry; - PMMPTE PointerPte = MiAddressToPte(Address); - PMMPFN Pfn1; - - /* Make sure we got a rounded address */ - Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); - - /* Make sure we are locking the right things */ - ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); - MI_ASSERT_PFN_LOCK_HELD(); - - /* Make sure we are removing a paged-in address */ - ASSERT(PointerPte->u.Hard.Valid == 1); - Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); - - /* The Pfn must be an active one */ - ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); - - WsIndex = Pfn1->u1.WsIndex; - WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; - - /* Shared page not handled yet */ - ASSERT(Pfn1->u3.e1.PrototypePte == 0); - ASSERT(WsleEntry->u1.e1.Direct == 1); - /* Nor are "ROS PFN" */ - ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); - - /* Some sanity checks */ - ASSERT(WsIndex >= WsList->FirstDynamic); - ASSERT(WsIndex <= WsList->LastEntry); - ASSERT(WsIndex <= WsList->LastInitializedWsle); - ASSERT(WsleEntry->u1.e1.Valid == 1); - ASSERT(WsleEntry->u1.e1.VirtualPageNumber == ((ULONG_PTR)Address) >> PAGE_SHIFT); - - /* Let this go */ - Pfn1->u1.WsIndex = 0; - - /* Nuke it */ - WsleEntry->u1.Long = 0; - - /* Insert our entry into the free list */ - if (WsIndex == WsList->LastEntry) - { - /* Let's shrink the active list */ - WsList->LastEntry--; - MiShrinkWorkingSet(Vm); - } - else if (WsList->FirstFree > WsList->LastEntry) - { - /* We are the first free entry to be inserted */ - WsList->FirstFree = WsIndex; - WsleEntry->u1.Free.PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; - WsleEntry->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; - } - else - { - /* Keep this sorted */ - PMMWSLE NextFree = &WsList->Wsle[WsList->FirstFree]; - PMMWSLE PreviousFree = NULL; - - ASSERT(NextFree->u1.Free.MustBeZero == 0); - - while (NextFree < WsleEntry) - { - PreviousFree = NextFree; - if (NextFree->u1.Free.NextFree != MMWSLE_NEXT_FREE_INVALID) - { - NextFree = &WsList->Wsle[NextFree->u1.Free.NextFree]; - ASSERT(NextFree->u1.Free.MustBeZero == 0); - } - else - { - NextFree = NULL; - break; - } - } - - ASSERT(PreviousFree || NextFree); - - if (PreviousFree) - { - ASSERT((NextFree != NULL) || (PreviousFree->u1.Free.NextFree == MMWSLE_NEXT_FREE_INVALID)); - PreviousFree->u1.Free.NextFree = WsIndex; - WsleEntry->u1.Free.PreviousFree = PreviousFree - WsList->Wsle; - } - else - { - WsleEntry->u1.Free.PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; - ASSERT(NextFree->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID); - WsList->FirstFree = WsIndex; - } - - if (NextFree) - { - NextFree->u1.Free.PreviousFree = WsIndex; - WsleEntry->u1.Free.NextFree = NextFree - WsList->Wsle; - } - else - { - WsleEntry->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; - } - } - - Vm->WorkingSetSize -= PAGE_SIZE; -} VOID NTAPI diff --git a/ntoskrnl/mm/ARM3/sysldr.c b/ntoskrnl/mm/ARM3/sysldr.c index 58e4c3057b2..d414b1f6b43 100644 --- a/ntoskrnl/mm/ARM3/sysldr.c +++ b/ntoskrnl/mm/ARM3/sysldr.c @@ -188,7 +188,14 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, /* Some debug stuff */ MI_SET_USAGE(MI_USAGE_DRIVER_PAGE); #if MI_TRACE_PFNS - MI_SET_PROCESS_USTR(FileName); + if (FileName->Buffer) + { + PWCHAR pos = NULL; + ULONG len = 0; + pos = wcsrchr(FileName->Buffer, '\\'); + len = wcslen(pos) * sizeof(WCHAR); + if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos); + } #endif /* Grab a page */ diff --git a/ntoskrnl/mm/ARM3/virtual.c b/ntoskrnl/mm/ARM3/virtual.c index 630afc5c990..f0ab5d08f7b 100644 --- a/ntoskrnl/mm/ARM3/virtual.c +++ b/ntoskrnl/mm/ARM3/virtual.c @@ -503,9 +503,6 @@ MiDeletePte(IN PMMPTE PointerPte, } else { - /* Remove this address from the WS list */ - MiRemoveFromWorkingSetList(&CurrentProcess->Vm, VirtualAddress); - /* Make sure the saved PTE address is valid */ if ((PMMPTE)((ULONG_PTR)Pfn1->PteAddress & ~0x1) != PointerPte) { @@ -2306,15 +2303,13 @@ MiProtectVirtualMemory(IN PEPROCESS Process, { KIRQL OldIrql = MiAcquirePfnLock(); - /* Remove this from the working set */ - MiRemoveFromWorkingSetList(AddressSpace, MiPteToAddress(PointerPte)); - /* Mark the PTE as transition and change its protection */ PteContents.u.Hard.Valid = 0; PteContents.u.Soft.Transition = 1; PteContents.u.Trans.Protection = ProtectionMask; /* Decrease PFN share count and write the PTE */ MiDecrementShareCount(Pfn1, PFN_FROM_PTE(&PteContents)); + // FIXME: remove the page from the WS MI_WRITE_INVALID_PTE(PointerPte, PteContents); #ifdef CONFIG_SMP // FIXME: Should invalidate entry in every CPU TLB @@ -2452,10 +2447,8 @@ MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, VOID NTAPI -MiProcessValidPteList( - _Inout_ PMMSUPPORT Vm, - _Inout_ PMMPTE *ValidPteList, - _In_ ULONG Count) +MiProcessValidPteList(IN PMMPTE *ValidPteList, + IN ULONG Count) { KIRQL OldIrql; ULONG i; @@ -2475,11 +2468,6 @@ MiProcessValidPteList( TempPte = *ValidPteList[i]; ASSERT(TempPte.u.Hard.Valid == 1); - // - // We can now remove this addres from the working set - // - MiRemoveFromWorkingSetList(Vm, MiPteToAddress(ValidPteList[i])); - // // Get the PFN entry for the page itself, and then for its page table // @@ -2521,6 +2509,7 @@ MiDecommitPages(IN PVOID StartingAddress, ULONG CommitReduction = 0; PMMPTE ValidPteList[256]; ULONG PteCount = 0; + PMMPFN Pfn1; MMPTE PteContents; PETHREAD CurrentThread = PsGetCurrentThread(); @@ -2552,10 +2541,10 @@ MiDecommitPages(IN PVOID StartingAddress, // such, and does not flush the entire TLB all the time, but right // now we have bigger problems to worry about than TLB flushing. // - PointerPde = MiPteToPde(PointerPte); + PointerPde = MiAddressToPde(StartingAddress); if (PteCount) { - MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); + MiProcessValidPteList(ValidPteList, PteCount); PteCount = 0; } @@ -2590,13 +2579,21 @@ MiDecommitPages(IN PVOID StartingAddress, //Process->NumberOfPrivatePages--; if (PteContents.u.Hard.Valid) { + // + // It's valid. At this point make sure that it is not a ROS + // PFN. Also, we don't support ProtoPTEs in this code path. + // + Pfn1 = MiGetPfnEntry(PteContents.u.Hard.PageFrameNumber); + ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); + ASSERT(Pfn1->u3.e1.PrototypePte == FALSE); + // // Flush any pending PTEs that we had not yet flushed, if our // list has gotten too big, then add this PTE to the flush list. // if (PteCount == 256) { - MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); + MiProcessValidPteList(ValidPteList, PteCount); PteCount = 0; } ValidPteList[PteCount++] = PointerPte; @@ -2626,7 +2623,7 @@ MiDecommitPages(IN PVOID StartingAddress, // This used to be a zero PTE and it no longer is, so we must add a // reference to the pagetable. // - MiIncrementPageTableReferences(MiPteToAddress(PointerPte)); + MiIncrementPageTableReferences(StartingAddress); // // Next, we account for decommitted PTEs and make the PTE as such @@ -2636,16 +2633,17 @@ MiDecommitPages(IN PVOID StartingAddress, } // - // Move to the next PTE + // Move to the next PTE and the next address // PointerPte++; + StartingAddress = (PVOID)((ULONG_PTR)StartingAddress + PAGE_SIZE); } // // Flush any dangling PTEs from the loop in the last page table, and then // release the working set and return the commit reduction accounting. // - if (PteCount) MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); + if (PteCount) MiProcessValidPteList(ValidPteList, PteCount); MiUnlockProcessWorkingSetUnsafe(Process, CurrentThread); return CommitReduction; } diff --git a/ntoskrnl/mm/freelist.c b/ntoskrnl/mm/freelist.c index 80447593ecd..93d9bbd9f59 100644 --- a/ntoskrnl/mm/freelist.c +++ b/ntoskrnl/mm/freelist.c @@ -574,21 +574,6 @@ MmAllocPage(ULONG Type) OldIrql = MiAcquirePfnLock(); -#if MI_TRACE_PFNS - switch(Type) - { - case MC_CACHE: - case MC_SYSTEM: - MI_SET_USAGE(MI_USAGE_CACHE); - break; - case MC_USER: - MI_SET_USAGE(MI_USAGE_SECTION); - break; - default: - ASSERT(FALSE); - } -#endif - PfnOffset = MiRemoveZeroPage(MI_GET_NEXT_COLOR()); if (!PfnOffset) { diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index f8337dadc26..6b5ac1e8353 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -264,10 +264,6 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde); // Tiny HACK: Parameter 1 is the architecture specific FaultCode for an access violation (i.e. page is present) - - /* Lock the working set, as this will add this address to it */ - MiLockProcessWorkingSetUnsafe(Process, PsGetCurrentThread()); - Status = MiDispatchFault(0x1, Pt, PointerPde, @@ -279,8 +275,6 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) DBG_UNREFERENCED_LOCAL_VARIABLE(Status); ASSERT(KeAreAllApcsDisabled() == TRUE); ASSERT(PointerPde->u.Hard.Valid == 1); - - MiUnlockProcessWorkingSetUnsafe(Process, PsGetCurrentThread()); } return (PULONG)MiAddressToPte(Address); } diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c index a68adecd9be..d953f422f96 100644 --- a/ntoskrnl/mm/marea.c +++ b/ntoskrnl/mm/marea.c @@ -331,16 +331,13 @@ MmFreeMemoryArea( ASSERT(AddressSpace != MmGetKernelAddressSpace()); if (MiQueryPageTableReferences((PVOID)Address) == 0) { - KIRQL OldIrql; /* No PTE relies on this PDE. Release it */ - MiLockProcessWorkingSet(Process, PsGetCurrentThread()); - OldIrql = MiAcquirePfnLock(); + KIRQL OldIrql = MiAcquirePfnLock(); PMMPDE PointerPde = MiAddressToPde(Address); ASSERT(PointerPde->u.Hard.Valid == 1); MiDeletePte(PointerPde, MiPdeToPte(PointerPde), Process, NULL); ASSERT(PointerPde->u.Hard.Valid == 0); MiReleasePfnLock(OldIrql); - MiUnlockProcessWorkingSet(Process, PsGetCurrentThread()); } } #endif diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index 0825d4ecb49..ce63e796a3d 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1163,6 +1163,8 @@ MiReadPage(PMEMORY_AREA MemoryArea, * Allocate a page, this is rather complicated by the possibility * we might have to move other things out of memory */ + MI_SET_USAGE(MI_USAGE_SECTION); + MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, Page); if (!NT_SUCCESS(Status)) { @@ -1622,6 +1624,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart) && (Section->AllocationAttributes & SEC_IMAGE)))) { + MI_SET_USAGE(MI_USAGE_SECTION); + if (Process) MI_SET_PROCESS2(Process->ImageFileName); + if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page); if (!NT_SUCCESS(Status)) { @@ -1702,6 +1707,9 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); + MI_SET_USAGE(MI_USAGE_SECTION); + if (Process) MI_SET_PROCESS2(Process->ImageFileName); + if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page); if (!NT_SUCCESS(Status)) { @@ -1870,6 +1878,9 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, /* * Allocate a page */ + MI_SET_USAGE(MI_USAGE_SECTION); + if (Process) MI_SET_PROCESS2(Process->ImageFileName); + if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &NewPage); if (!NT_SUCCESS(Status)) {
4 years, 2 months
1
0
0
0
[reactos] 01/01: [CMAKE] Add target-level dependency between ntdll_apitest and load_notifications
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7b3faadaf5b0db279fdf4…
commit 7b3faadaf5b0db279fdf4ab1d65af512d506cc01 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Oct 20 09:32:00 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:21:00 2020 +0200 [CMAKE] Add target-level dependency between ntdll_apitest and load_notifications --- modules/rostests/apitests/ntdll/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index c92fa973588..bb2a8cad1f6 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -97,6 +97,7 @@ target_link_libraries(ntdll_apitest wine uuid ${PSEH_LIB}) set_module_type(ntdll_apitest win32cui) add_importlibs(ntdll_apitest msvcrt advapi32 kernel32 ntdll) add_pch(ntdll_apitest precomp.h "${PCH_SKIP_SOURCE}") +add_dependencies(ntdll_apitest load_notifications) if(NOT MSVC) set_source_files_properties(RtlGetFullPathName_UstrEx.c PROPERTIES COMPILE_FLAGS "-Wno-format")
4 years, 2 months
1
0
0
0
[reactos] 01/01: [CMAKE] Use explicit path for "custom.dll" dependency
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=971b3223ba3eb773a4a67…
commit 971b3223ba3eb773a4a675259e708587f0399602 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Oct 20 09:06:26 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:21:00 2020 +0200 [CMAKE] Use explicit path for "custom.dll" dependency --- modules/rostests/winetests/msi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rostests/winetests/msi/CMakeLists.txt b/modules/rostests/winetests/msi/CMakeLists.txt index a480519bbcb..2c71551a024 100644 --- a/modules/rostests/winetests/msi/CMakeLists.txt +++ b/modules/rostests/winetests/msi/CMakeLists.txt @@ -36,7 +36,7 @@ list(APPEND PCH_SKIP_SOURCE # CMake 3.9 and higher requires to specify this dependency manually # see
https://gitlab.kitware.com/cmake/cmake/issues/19933
-set_property(SOURCE msi_winetest.rc PROPERTY OBJECT_DEPENDS custom.dll) +set_property(SOURCE msi_winetest.rc PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/custom.dll) add_executable(msi_winetest ${SOURCE}
4 years, 2 months
1
0
0
0
[reactos] 03/03: [CMAKE] Fix generation of UTF-16 inf file
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0ed4fdb3a14fd4d571fc…
commit d0ed4fdb3a14fd4d571fc266b27291b03a17aaa4 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Tue Oct 20 09:05:47 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:21:00 2020 +0200 [CMAKE] Fix generation of UTF-16 inf file --- media/themes/Lautus/lautus.msstyles/CMakeLists.txt | 11 +++++------ media/themes/Lunar/lunar.msstyles/CMakeLists.txt | 11 +++++------ media/themes/Mizu/mizu.msstyles/CMakeLists.txt | 11 +++++------ media/themes/Modern/modern.msstyles/CMakeLists.txt | 11 +++++------ sdk/cmake/CMakeMacros.cmake | 5 +++-- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/media/themes/Lautus/lautus.msstyles/CMakeLists.txt b/media/themes/Lautus/lautus.msstyles/CMakeLists.txt index 01d26935a14..0f0971f9c55 100644 --- a/media/themes/Lautus/lautus.msstyles/CMakeLists.txt +++ b/media/themes/Lautus/lautus.msstyles/CMakeLists.txt @@ -7,13 +7,12 @@ list(APPEND TEXTFILES file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/textfiles) foreach(_file ${TEXTFILES}) get_filename_component(_file_name ${_file} NAME_WE) - string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}") - string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file}) - set(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_converted_file}) + get_filename_component(_subdir ${_file} DIRECTORY) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}) + set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}/${_file_name}_utf16.INI) add_custom_command(OUTPUT ${_converted_file} - COMMAND native-utf16le ${_file} ${_converted_file} - DEPENDS native-utf16le ${_file}) + COMMAND native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${_converted_file} + DEPENDS native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) list(APPEND _converted_files ${_converted_file}) endforeach() diff --git a/media/themes/Lunar/lunar.msstyles/CMakeLists.txt b/media/themes/Lunar/lunar.msstyles/CMakeLists.txt index 72d1b86d37f..60deacfd57b 100644 --- a/media/themes/Lunar/lunar.msstyles/CMakeLists.txt +++ b/media/themes/Lunar/lunar.msstyles/CMakeLists.txt @@ -7,13 +7,12 @@ list(APPEND TEXTFILES file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/textfiles) foreach(_file ${TEXTFILES}) get_filename_component(_file_name ${_file} NAME_WE) - string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}") - string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file}) - set(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_converted_file}) + get_filename_component(_subdir ${_file} DIRECTORY) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}) + set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}/${_file_name}_utf16.INI) add_custom_command(OUTPUT ${_converted_file} - COMMAND native-utf16le ${_file} ${_converted_file} - DEPENDS native-utf16le ${_file}) + COMMAND native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${_converted_file} + DEPENDS native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) list(APPEND _converted_files ${_converted_file}) endforeach() diff --git a/media/themes/Mizu/mizu.msstyles/CMakeLists.txt b/media/themes/Mizu/mizu.msstyles/CMakeLists.txt index 51f65c31bd2..f2e264c045a 100644 --- a/media/themes/Mizu/mizu.msstyles/CMakeLists.txt +++ b/media/themes/Mizu/mizu.msstyles/CMakeLists.txt @@ -7,13 +7,12 @@ list(APPEND TEXTFILES file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/textfiles) foreach(_file ${TEXTFILES}) get_filename_component(_file_name ${_file} NAME_WE) - string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}") - string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file}) - set(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_converted_file}) + get_filename_component(_subdir ${_file} DIRECTORY) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}) + set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}/${_file_name}_utf16.INI) add_custom_command(OUTPUT ${_converted_file} - COMMAND native-utf16le ${_file} ${_converted_file} - DEPENDS native-utf16le ${_file}) + COMMAND native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${_converted_file} + DEPENDS native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) list(APPEND _converted_files ${_converted_file}) endforeach() diff --git a/media/themes/Modern/modern.msstyles/CMakeLists.txt b/media/themes/Modern/modern.msstyles/CMakeLists.txt index 6a1be70e14a..2b2fb43bd2c 100644 --- a/media/themes/Modern/modern.msstyles/CMakeLists.txt +++ b/media/themes/Modern/modern.msstyles/CMakeLists.txt @@ -12,13 +12,12 @@ list(APPEND TEXTFILES file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/textfiles) foreach(_file ${TEXTFILES}) get_filename_component(_file_name ${_file} NAME_WE) - string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}") - string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file}) - set(_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_converted_file}) + get_filename_component(_subdir ${_file} DIRECTORY) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}) + set(_converted_file ${CMAKE_CURRENT_BINARY_DIR}/${_subdir}/${_file_name}_utf16.INI) add_custom_command(OUTPUT ${_converted_file} - COMMAND native-utf16le ${_file} ${_converted_file} - DEPENDS native-utf16le ${_file}) + COMMAND native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file} ${_converted_file} + DEPENDS native-utf16le ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) list(APPEND _converted_files ${_converted_file}) endforeach() diff --git a/sdk/cmake/CMakeMacros.cmake b/sdk/cmake/CMakeMacros.cmake index 5ac5dec5555..fa408d7d631 100644 --- a/sdk/cmake/CMakeMacros.cmake +++ b/sdk/cmake/CMakeMacros.cmake @@ -821,8 +821,9 @@ function(create_registry_hives) # Convert files to utf16le foreach(_file ${_inf_files}) get_filename_component(_file_name ${_file} NAME_WE) - string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} _converted_file "${_file}") - string(REPLACE ${_file_name} "${_file_name}_utf16" _converted_file ${_converted_file}) + file(RELATIVE_PATH _subdir ${CMAKE_SOURCE_DIR} ${_file}) + get_filename_component(_subdir ${_subdir} DIRECTORY) + set(_converted_file ${CMAKE_BINARY_DIR}/${_subdir}/${_file_name}_utf16.inf) add_custom_command(OUTPUT ${_converted_file} COMMAND native-utf16le ${_file} ${_converted_file} DEPENDS native-utf16le ${_file})
4 years, 2 months
1
0
0
0
[reactos] 02/03: [NTOS/MM] - Fix PFNs tracing - Add private pages to the process working set
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4c5351bf55527a35bce09…
commit 4c5351bf55527a35bce09446420dd7296eedbe99 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Fri Oct 16 15:27:07 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:20:59 2020 +0200 [NTOS/MM] - Fix PFNs tracing - Add private pages to the process working set --- ntoskrnl/cc/view.c | 20 ---- ntoskrnl/include/internal/mm.h | 44 ++++++++- ntoskrnl/mm/ARM3/miarm.h | 4 + ntoskrnl/mm/ARM3/mminit.c | 4 +- ntoskrnl/mm/ARM3/pagfault.c | 69 +++++++++++--- ntoskrnl/mm/ARM3/pfnlist.c | 13 ++- ntoskrnl/mm/ARM3/procsup.c | 212 ++++++++++++++++++++++++++++++++++++++++- ntoskrnl/mm/ARM3/sysldr.c | 9 +- ntoskrnl/mm/ARM3/virtual.c | 40 ++++---- ntoskrnl/mm/freelist.c | 15 +++ ntoskrnl/mm/i386/page.c | 6 ++ ntoskrnl/mm/marea.c | 5 +- ntoskrnl/mm/section.c | 11 --- 13 files changed, 364 insertions(+), 88 deletions(-) diff --git a/ntoskrnl/cc/view.c b/ntoskrnl/cc/view.c index fde2bbc926a..c576997f943 100644 --- a/ntoskrnl/cc/view.c +++ b/ntoskrnl/cc/view.c @@ -665,7 +665,6 @@ CcRosMapVacbInKernelSpace( { PFN_NUMBER PageFrameNumber; - MI_SET_USAGE(MI_USAGE_CACHE); Status = MmRequestPageMemoryConsumer(MC_CACHE, TRUE, &PageFrameNumber); if (PageFrameNumber == 0) { @@ -907,25 +906,6 @@ Retry: InsertTailList(&VacbLruListHead, ¤t->VacbLruListEntry); KeReleaseQueuedSpinLock(LockQueueMasterLock, oldIrql); - MI_SET_USAGE(MI_USAGE_CACHE); -#if MI_TRACE_PFNS - if ((SharedCacheMap->FileObject) && (SharedCacheMap->FileObject->FileName.Buffer)) - { - PWCHAR pos; - ULONG len = 0; - pos = wcsrchr(SharedCacheMap->FileObject->FileName.Buffer, '\\'); - if (pos) - { - len = wcslen(pos) * sizeof(WCHAR); - snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos); - } - else - { - snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%wZ", &SharedCacheMap->FileObject->FileName); - } - } -#endif - /* Reference it to allow release */ CcRosVacbIncRefCount(current); diff --git a/ntoskrnl/include/internal/mm.h b/ntoskrnl/include/internal/mm.h index 32fd7b1146d..d2ead92df1f 100644 --- a/ntoskrnl/include/internal/mm.h +++ b/ntoskrnl/include/internal/mm.h @@ -2,6 +2,8 @@ #include <internal/arch/mm.h> +#define MI_TRACE_PFNS 1 + /* TYPES *********************************************************************/ struct _EPROCESS; @@ -248,9 +250,45 @@ MM_RMAP_ENTRY, *PMM_RMAP_ENTRY; extern ULONG MI_PFN_CURRENT_USAGE; extern CHAR MI_PFN_CURRENT_PROCESS_NAME[16]; #define MI_SET_USAGE(x) MI_PFN_CURRENT_USAGE = x -#define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, 16) +#define MI_SET_PROCESS2(x) memcpy(MI_PFN_CURRENT_PROCESS_NAME, x, min(sizeof(x), sizeof(MI_PFN_CURRENT_PROCESS_NAME))) +FORCEINLINE +void +MI_SET_PROCESS(PEPROCESS Process) +{ + if (!Process) + MI_SET_PROCESS2("Kernel"); + else if (Process == (PEPROCESS)1) + MI_SET_PROCESS2("Hydra"); + else + MI_SET_PROCESS2(Process->ImageFileName); +} + +FORCEINLINE +void +MI_SET_PROCESS_USTR(PUNICODE_STRING ustr) +{ + PWSTR pos, strEnd; + int i; + + if (!ustr->Buffer || ustr->Length == 0) + { + MI_PFN_CURRENT_PROCESS_NAME[0] = 0; + return; + } + + pos = strEnd = &ustr->Buffer[ustr->Length / sizeof(WCHAR)]; + while ((*pos != L'\\') && (pos > ustr->Buffer)) + pos--; + + if (*pos == L'\\') + pos++; + + for (i = 0; i < sizeof(MI_PFN_CURRENT_PROCESS_NAME) && pos <= strEnd; i++, pos++) + MI_PFN_CURRENT_PROCESS_NAME[i] = (CHAR)*pos; +} #else #define MI_SET_USAGE(x) +#define MI_SET_PROCESS(x) #define MI_SET_PROCESS2(x) #endif @@ -278,6 +316,9 @@ typedef enum _MI_PFN_USAGES MI_USAGE_PFN_DATABASE, MI_USAGE_BOOT_DRIVER, MI_USAGE_INIT_MEMORY, + MI_USAGE_PAGE_FILE, + MI_USAGE_COW, + MI_USAGE_WSLE, MI_USAGE_FREE_PAGE } MI_PFN_USAGES; @@ -358,6 +399,7 @@ typedef struct _MMPFN #if MI_TRACE_PFNS MI_PFN_USAGES PfnUsage; CHAR ProcessName[16]; +#define MI_SET_PFN_PROCESS_NAME(pfn, x) memcpy(pfn->ProcessName, x, min(sizeof(x), sizeof(pfn->ProcessName))) #endif // HACK until WS lists are supported diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index 6df6b7e5385..a30e9957874 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1058,6 +1058,10 @@ VOID NTAPI MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection); +VOID +NTAPI +MiRemoveFromWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address); + // // New ARM3<->RosMM PAGE Architecture // diff --git a/ntoskrnl/mm/ARM3/mminit.c b/ntoskrnl/mm/ARM3/mminit.c index 0bae38e3e02..3c724d8ea3e 100644 --- a/ntoskrnl/mm/ARM3/mminit.c +++ b/ntoskrnl/mm/ARM3/mminit.c @@ -801,7 +801,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn1->u3.e1.CacheAttribute = MiNonCached; #if MI_TRACE_PFNS Pfn1->PfnUsage = MI_USAGE_INIT_MEMORY; - memcpy(Pfn1->ProcessName, "Initial PDE", 16); + MI_SET_PFN_PROCESS_NAME(Pfn1, "Initial PDE"); #endif } else @@ -848,7 +848,7 @@ MiBuildPfnDatabaseFromPages(IN PLOADER_PARAMETER_BLOCK LoaderBlock) Pfn2->u3.e1.CacheAttribute = MiNonCached; #if MI_TRACE_PFNS Pfn2->PfnUsage = MI_USAGE_INIT_MEMORY; - memcpy(Pfn1->ProcessName, "Initial PTE", 16); + MI_SET_PFN_PROCESS_NAME(Pfn2, "Initial PTE"); #endif } } diff --git a/ntoskrnl/mm/ARM3/pagfault.c b/ntoskrnl/mm/ARM3/pagfault.c index 1ab109e9f65..a487d3a1ba2 100644 --- a/ntoskrnl/mm/ARM3/pagfault.c +++ b/ntoskrnl/mm/ARM3/pagfault.c @@ -697,16 +697,6 @@ MiResolveDemandZeroFault(IN PVOID Address, /* Increment demand zero faults */ KeGetCurrentPrcb()->MmDemandZeroCount++; - /* Do we have the lock? */ - if (HaveLock) - { - /* Release it */ - MiReleasePfnLock(OldIrql); - - /* Update performance counters */ - if (Process > HYDRA_PROCESS) Process->NumberOfPrivatePages++; - } - /* Zero the page if need be */ if (NeedZero) MiZeroPfn(PageFrameNumber); @@ -745,6 +735,23 @@ MiResolveDemandZeroFault(IN PVOID Address, ASSERT(Pfn1->u3.e1.PrototypePte == 0); } + /* Add the page to our working set, if it's not a proto PTE */ + if ((Process > HYDRA_PROCESS) && (PointerPte == MiAddressToPte(Address))) + { + /* FIXME: Also support session VM scenario */ + MiInsertInWorkingSetList(&Process->Vm, Address, Protection); + } + + /* Do we have the lock? */ + if (HaveLock) + { + /* Release it */ + MiReleasePfnLock(OldIrql); + + /* Update performance counters */ + if (Process > HYDRA_PROCESS) Process->NumberOfPrivatePages++; + } + // // It's all good now // @@ -899,6 +906,9 @@ MiResolvePageFileFault(_In_ BOOLEAN StoreInstruction, ASSERT(CurrentProcess > HYDRA_PROCESS); ASSERT(*OldIrql != MM_NOIRQL); + MI_SET_USAGE(MI_USAGE_PAGE_FILE); + MI_SET_PROCESS(CurrentProcess); + /* We must hold the PFN lock */ MI_ASSERT_PFN_LOCK_HELD(); @@ -959,6 +969,9 @@ MiResolvePageFileFault(_In_ BOOLEAN StoreInstruction, KeSetEvent(Pfn1->u1.Event, IO_NO_INCREMENT, FALSE); } + /* And we can insert this into the working set */ + MiInsertInWorkingSetList(&CurrentProcess->Vm, FaultingAddress, Protection); + return Status; } @@ -976,6 +989,8 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, PMMPFN Pfn1; MMPTE TempPte; PMMPTE PointerToPteForProtoPage; + ULONG Protection; + DPRINT("Transition fault on 0x%p with PTE 0x%p in process %s\n", FaultingAddress, PointerPte, CurrentProcess->ImageFileName); @@ -1069,8 +1084,9 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, ASSERT(PointerPte->u.Hard.Valid == 0); ASSERT(PointerPte->u.Trans.Prototype == 0); ASSERT(PointerPte->u.Trans.Transition == 1); + Protection = TempPte.u.Trans.Protection; TempPte.u.Long = (PointerPte->u.Long & ~0xFFF) | - (MmProtectToPteMask[PointerPte->u.Trans.Protection]) | + (MmProtectToPteMask[Protection]) | MiDetermineUserGlobalPteMask(PointerPte); /* Is the PTE writeable? */ @@ -1090,6 +1106,10 @@ MiResolveTransitionFault(IN BOOLEAN StoreInstruction, /* Write the valid PTE */ MI_WRITE_VALID_PTE(PointerPte, TempPte); + /* If this was a user fault, add it to the working set */ + if (CurrentProcess > HYDRA_PROCESS) + MiInsertInWorkingSetList(&CurrentProcess->Vm, FaultingAddress, Protection); + /* Return success */ return STATUS_PAGE_FAULT_TRANSITION; } @@ -1210,6 +1230,9 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, ASSERT(TempPte.u.Hard.Valid == 1); ProtoPageFrameIndex = PFN_FROM_PTE(&TempPte); + MI_SET_USAGE(MI_USAGE_COW); + MI_SET_PROCESS(Process); + /* Get a new page for the private copy */ if (Process > HYDRA_PROCESS) Color = MI_GET_NEXT_PROCESS_COLOR(Process); @@ -1245,6 +1268,13 @@ MiResolveProtoPteFault(IN BOOLEAN StoreInstruction, /* And finally, write the valid PTE */ MI_WRITE_VALID_PTE(PointerPte, PteContents); + /* Add the page to our working set */ + if (Process > HYDRA_PROCESS) + { + /* FIXME: Also support session VM scenario */ + MiInsertInWorkingSetList(&Process->Vm, Address, Protection); + } + /* The caller expects us to release the PFN lock */ MiReleasePfnLock(OldIrql); return Status; @@ -2205,11 +2235,15 @@ UserFault: { PFN_NUMBER PageFrameIndex, OldPageFrameIndex; PMMPFN Pfn1; + ProtectionCode = TempPte.u.Soft.Protection; LockIrql = MiAcquirePfnLock(); ASSERT(MmAvailablePages > 0); + MI_SET_USAGE(MI_USAGE_COW); + MI_SET_PROCESS(CurrentProcess); + /* Allocate a new page and copy it */ PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_PROCESS_COLOR(CurrentProcess)); OldPageFrameIndex = PFN_FROM_PTE(&TempPte); @@ -2231,6 +2265,9 @@ UserFault: MI_WRITE_VALID_PTE(PointerPte, TempPte); + /* We can now add it to our working set */ + MiInsertInWorkingSetList(&CurrentProcess->Vm, Address, ProtectionCode); + MiReleasePfnLock(LockIrql); /* Return the status */ @@ -2347,6 +2384,7 @@ UserFault: TempPte.u.Soft.Protection = ProtectionCode; MI_WRITE_INVALID_PTE(PointerPte, TempPte); } + ProtectionCode = PointerPte->u.Soft.Protection; /* Lock the PFN database since we're going to grab a page */ OldIrql = MiAcquirePfnLock(); @@ -2384,9 +2422,6 @@ UserFault: /* One more demand-zero fault */ KeGetCurrentPrcb()->MmDemandZeroCount++; - /* And we're done with the lock */ - MiReleasePfnLock(OldIrql); - /* Fault on user PDE, or fault on user PTE? */ if (PointerPte <= MiHighestUserPte) { @@ -2413,6 +2448,12 @@ UserFault: Pfn1 = MI_PFN_ELEMENT(PageFrameIndex); ASSERT(Pfn1->u1.Event == NULL); + /* We can now insert it into the working set */ + MiInsertInWorkingSetList(&CurrentProcess->Vm, Address, ProtectionCode); + + /* And we're done with the lock */ + MiReleasePfnLock(OldIrql); + /* Demand zero */ ASSERT(KeGetCurrentIrql() <= APC_LEVEL); MiUnlockProcessWorkingSet(CurrentProcess, CurrentThread); diff --git a/ntoskrnl/mm/ARM3/pfnlist.c b/ntoskrnl/mm/ARM3/pfnlist.c index b039a5181a2..866a29cd15f 100644 --- a/ntoskrnl/mm/ARM3/pfnlist.c +++ b/ntoskrnl/mm/ARM3/pfnlist.c @@ -254,8 +254,8 @@ MiUnlinkFreeOrZeroedPage(IN PMMPFN Entry) ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); Entry->PfnUsage = MI_PFN_CURRENT_USAGE; memcpy(Entry->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16); -// MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; -// memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16); + MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; + MI_SET_PROCESS2("Not Set"); #endif } @@ -459,11 +459,11 @@ MiRemovePageByColor(IN PFN_NUMBER PageIndex, MiDecrementAvailablePages(); #if MI_TRACE_PFNS - //ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); + ASSERT(MI_PFN_CURRENT_USAGE != MI_USAGE_NOT_SET); Pfn1->PfnUsage = MI_PFN_CURRENT_USAGE; memcpy(Pfn1->ProcessName, MI_PFN_CURRENT_PROCESS_NAME, 16); - //MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; - //memcpy(MI_PFN_CURRENT_PROCESS_NAME, "Not Set", 16); + MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; + MI_SET_PROCESS2("Not Set"); #endif /* Return the page */ @@ -937,9 +937,8 @@ MiInsertPageInList(IN PMMPFNLIST ListHead, ColorHead->Count++; #if MI_TRACE_PFNS - //ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET); + ASSERT(MI_PFN_CURRENT_USAGE == MI_USAGE_NOT_SET); Pfn1->PfnUsage = MI_USAGE_FREE_PAGE; - MI_PFN_CURRENT_USAGE = MI_USAGE_NOT_SET; RtlZeroMemory(Pfn1->ProcessName, 16); #endif } diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index ab01d902686..2e4d9029d36 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -6,6 +6,8 @@ * PROGRAMMERS: ReactOS Portable Systems Group */ +#define GROW_WSLE 1 + /* INCLUDES *******************************************************************/ #include <ntoskrnl.h> @@ -862,18 +864,34 @@ MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) if (WsList->LastEntry == WsList->LastInitializedWsle) { /* We must grow our array. Allocate a new page */ - PMMPTE PointerPte = MiAddressToPte(&WsList->Wsle[WsList->LastInitializedWsle + 1]); + PVOID Address = &WsList->Wsle[WsList->LastInitializedWsle + 1]; + PMMPTE PointerPte = MiAddressToPte(Address); MMPTE TempPte; + + MI_SET_USAGE(MI_USAGE_WSLE); + MI_SET_PROCESS(PsGetCurrentProcess()); + + /* We must be at page boundary */ + ASSERT(Address == ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE)); + PFN_NUMBER PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); MiInitializePfn(PageFrameIndex, PointerPte, TRUE); - MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, MM_READWRITE, PageFrameIndex); + + TempPte = ValidKernelPteLocal; + TempPte.u.Hard.PageFrameNumber = PageFrameIndex; MI_WRITE_VALID_PTE(PointerPte, TempPte); WsList->LastInitializedWsle += PAGE_SIZE / sizeof(MMWSLE); + /* Make sure we are staying on the same page */ + ASSERT(Address == ALIGN_DOWN_POINTER_BY(&WsList->Wsle[WsList->LastInitializedWsle], PAGE_SIZE)); + /* We must insert this page in our working set ! */ MiInsertInWorkingSetList(Vm, &WsList->Wsle[WsList->LastInitializedWsle], MM_READWRITE); + + /* Now the last entry is the tail of our WSLE array */ + ASSERT(WsList->Wsle[WsList->LastEntry].u1.e1.VirtualPageNumber == ((ULONG_PTR)&WsList->Wsle[WsList->LastInitializedWsle]) >> PAGE_SHIFT); } /* At this point we must be good to go */ @@ -909,18 +927,26 @@ MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) VOID NTAPI -MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection) +MiInsertInWorkingSetList( + _Inout_ PMMSUPPORT Vm, + _In_ PVOID Address, + _In_ ULONG Protection) { ULONG WsIndex = MiGetFirstFreeWsleIndex(Vm); PMMWSLE WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; PMMPTE PointerPte = MiAddressToPte(Address); - PMMPFN Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); + PMMPFN Pfn1; /* Make sure we got a rounded address */ Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); - /* Make sure we are locking the right thing */ + /* Make sure we are locking the right things */ ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); + MI_ASSERT_PFN_LOCK_HELD(); + + /* Make sure we are adding a paged-in address */ + ASSERT(PointerPte->u.Hard.Valid == 1); + Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); /* The Pfn must be an active one */ ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); @@ -931,6 +957,11 @@ MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG P /* Shared pages not supported yet */ ASSERT(Pfn1->u1.WsIndex == 0); + ASSERT(Pfn1->u3.e1.PrototypePte == 0); + + /* Nor are "ROS PFN" */ + ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); + WsleEntry->u1.e1.Direct = 1; Pfn1->u1.WsIndex = WsIndex; @@ -941,6 +972,177 @@ MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG P Vm->PeakWorkingSetSize = Vm->WorkingSetSize; } +static +void +MiShrinkWorkingSet(_Inout_ PMMSUPPORT Vm) +{ + PMMWSL WsList = Vm->VmWorkingSetList; + ULONG LastValid = WsList->LastEntry; + + while(WsList->Wsle[LastValid].u1.e1.Valid == 0) + { + LastValid--; + } + + if (LastValid != WsList->LastEntry) + { + /* There was a hole behind us. Handle this */ + PMMWSLE NextFree = &WsList->Wsle[LastValid + 1]; + if (NextFree->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID) + { + /* This was actually our first free entry. */ + ASSERT(WsList->FirstFree == LastValid + 1); + WsList->FirstFree = MMWSLE_NEXT_FREE_INVALID; + } + else + { + /* The previous one is now the last in the queue */ + PMMWSLE PreviousFree = &WsList->Wsle[NextFree->u1.Free.PreviousFree]; + + ASSERT(PreviousFree->u1.Free.MustBeZero == 0); + PreviousFree->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; + } + + /* Nuke everyone */ + RtlZeroMemory(&WsList->Wsle[LastValid + 1], (WsList->LastEntry - LastValid) * sizeof(MMWSLE)); + WsList->LastEntry = LastValid; + } + + if (LastValid < WsList->FirstDynamic) + { + /* Do not mess around with the protected ones */ + return; + } + + /* See if we should shrink our array */ + if (LastValid == (WsList->LastInitializedWsle - (PAGE_SIZE / sizeof(MMWSLE)) + 1)) + { + PVOID WsleArrayQueue = ALIGN_DOWN_POINTER_BY(&WsList->Wsle[LastValid], PAGE_SIZE); + PEPROCESS Process = MmGetAddressSpaceOwner(Vm); + + ASSERT(WsList->Wsle[WsList->LastEntry].u1.e1.VirtualPageNumber == ((ULONG_PTR)WsleArrayQueue) >> PAGE_SHIFT); + + /* Kernel address space not supported yet */ + ASSERT(Process != NULL); + + /* Nuke the PTE. This will remove the virtual address from the working set */ + MiDeletePte(MiAddressToPte(WsleArrayQueue), WsleArrayQueue, Process, NULL); + } +} + +VOID +NTAPI +MiRemoveFromWorkingSetList( + _Inout_ PMMSUPPORT Vm, + _In_ PVOID Address) +{ + PMMWSL WsList = Vm->VmWorkingSetList; + ULONG WsIndex; + PMMWSLE WsleEntry; + PMMPTE PointerPte = MiAddressToPte(Address); + PMMPFN Pfn1; + + /* Make sure we got a rounded address */ + Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); + + /* Make sure we are locking the right things */ + ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); + MI_ASSERT_PFN_LOCK_HELD(); + + /* Make sure we are removing a paged-in address */ + ASSERT(PointerPte->u.Hard.Valid == 1); + Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); + + /* The Pfn must be an active one */ + ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); + + WsIndex = Pfn1->u1.WsIndex; + WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; + + /* Shared page not handled yet */ + ASSERT(Pfn1->u3.e1.PrototypePte == 0); + ASSERT(WsleEntry->u1.e1.Direct == 1); + /* Nor are "ROS PFN" */ + ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); + + /* Some sanity checks */ + ASSERT(WsIndex >= WsList->FirstDynamic); + ASSERT(WsIndex <= WsList->LastEntry); + ASSERT(WsIndex <= WsList->LastInitializedWsle); + ASSERT(WsleEntry->u1.e1.Valid == 1); + ASSERT(WsleEntry->u1.e1.VirtualPageNumber == ((ULONG_PTR)Address) >> PAGE_SHIFT); + + /* Let this go */ + Pfn1->u1.WsIndex = 0; + + /* Nuke it */ + WsleEntry->u1.Long = 0; + + /* Insert our entry into the free list */ + if (WsIndex == WsList->LastEntry) + { + /* Let's shrink the active list */ + WsList->LastEntry--; + MiShrinkWorkingSet(Vm); + } + else if (WsList->FirstFree > WsList->LastEntry) + { + /* We are the first free entry to be inserted */ + WsList->FirstFree = WsIndex; + WsleEntry->u1.Free.PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; + WsleEntry->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; + } + else + { + /* Keep this sorted */ + PMMWSLE NextFree = &WsList->Wsle[WsList->FirstFree]; + PMMWSLE PreviousFree = NULL; + + ASSERT(NextFree->u1.Free.MustBeZero == 0); + + while (NextFree < WsleEntry) + { + PreviousFree = NextFree; + if (NextFree->u1.Free.NextFree != MMWSLE_NEXT_FREE_INVALID) + { + NextFree = &WsList->Wsle[NextFree->u1.Free.NextFree]; + ASSERT(NextFree->u1.Free.MustBeZero == 0); + } + else + { + NextFree = NULL; + break; + } + } + + ASSERT(PreviousFree || NextFree); + + if (PreviousFree) + { + ASSERT((NextFree != NULL) || (PreviousFree->u1.Free.NextFree == MMWSLE_NEXT_FREE_INVALID)); + PreviousFree->u1.Free.NextFree = WsIndex; + WsleEntry->u1.Free.PreviousFree = PreviousFree - WsList->Wsle; + } + else + { + WsleEntry->u1.Free.PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; + ASSERT(NextFree->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID); + WsList->FirstFree = WsIndex; + } + + if (NextFree) + { + NextFree->u1.Free.PreviousFree = WsIndex; + WsleEntry->u1.Free.NextFree = NextFree - WsList->Wsle; + } + else + { + WsleEntry->u1.Free.NextFree = MMWSLE_NEXT_FREE_INVALID; + } + } + + Vm->WorkingSetSize -= PAGE_SIZE; +} VOID NTAPI diff --git a/ntoskrnl/mm/ARM3/sysldr.c b/ntoskrnl/mm/ARM3/sysldr.c index d414b1f6b43..58e4c3057b2 100644 --- a/ntoskrnl/mm/ARM3/sysldr.c +++ b/ntoskrnl/mm/ARM3/sysldr.c @@ -188,14 +188,7 @@ MiLoadImageSection(IN OUT PVOID *SectionPtr, /* Some debug stuff */ MI_SET_USAGE(MI_USAGE_DRIVER_PAGE); #if MI_TRACE_PFNS - if (FileName->Buffer) - { - PWCHAR pos = NULL; - ULONG len = 0; - pos = wcsrchr(FileName->Buffer, '\\'); - len = wcslen(pos) * sizeof(WCHAR); - if (pos) snprintf(MI_PFN_CURRENT_PROCESS_NAME, min(16, len), "%S", pos); - } + MI_SET_PROCESS_USTR(FileName); #endif /* Grab a page */ diff --git a/ntoskrnl/mm/ARM3/virtual.c b/ntoskrnl/mm/ARM3/virtual.c index f0ab5d08f7b..630afc5c990 100644 --- a/ntoskrnl/mm/ARM3/virtual.c +++ b/ntoskrnl/mm/ARM3/virtual.c @@ -503,6 +503,9 @@ MiDeletePte(IN PMMPTE PointerPte, } else { + /* Remove this address from the WS list */ + MiRemoveFromWorkingSetList(&CurrentProcess->Vm, VirtualAddress); + /* Make sure the saved PTE address is valid */ if ((PMMPTE)((ULONG_PTR)Pfn1->PteAddress & ~0x1) != PointerPte) { @@ -2303,13 +2306,15 @@ MiProtectVirtualMemory(IN PEPROCESS Process, { KIRQL OldIrql = MiAcquirePfnLock(); + /* Remove this from the working set */ + MiRemoveFromWorkingSetList(AddressSpace, MiPteToAddress(PointerPte)); + /* Mark the PTE as transition and change its protection */ PteContents.u.Hard.Valid = 0; PteContents.u.Soft.Transition = 1; PteContents.u.Trans.Protection = ProtectionMask; /* Decrease PFN share count and write the PTE */ MiDecrementShareCount(Pfn1, PFN_FROM_PTE(&PteContents)); - // FIXME: remove the page from the WS MI_WRITE_INVALID_PTE(PointerPte, PteContents); #ifdef CONFIG_SMP // FIXME: Should invalidate entry in every CPU TLB @@ -2447,8 +2452,10 @@ MiMakePdeExistAndMakeValid(IN PMMPDE PointerPde, VOID NTAPI -MiProcessValidPteList(IN PMMPTE *ValidPteList, - IN ULONG Count) +MiProcessValidPteList( + _Inout_ PMMSUPPORT Vm, + _Inout_ PMMPTE *ValidPteList, + _In_ ULONG Count) { KIRQL OldIrql; ULONG i; @@ -2468,6 +2475,11 @@ MiProcessValidPteList(IN PMMPTE *ValidPteList, TempPte = *ValidPteList[i]; ASSERT(TempPte.u.Hard.Valid == 1); + // + // We can now remove this addres from the working set + // + MiRemoveFromWorkingSetList(Vm, MiPteToAddress(ValidPteList[i])); + // // Get the PFN entry for the page itself, and then for its page table // @@ -2509,7 +2521,6 @@ MiDecommitPages(IN PVOID StartingAddress, ULONG CommitReduction = 0; PMMPTE ValidPteList[256]; ULONG PteCount = 0; - PMMPFN Pfn1; MMPTE PteContents; PETHREAD CurrentThread = PsGetCurrentThread(); @@ -2541,10 +2552,10 @@ MiDecommitPages(IN PVOID StartingAddress, // such, and does not flush the entire TLB all the time, but right // now we have bigger problems to worry about than TLB flushing. // - PointerPde = MiAddressToPde(StartingAddress); + PointerPde = MiPteToPde(PointerPte); if (PteCount) { - MiProcessValidPteList(ValidPteList, PteCount); + MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); PteCount = 0; } @@ -2579,21 +2590,13 @@ MiDecommitPages(IN PVOID StartingAddress, //Process->NumberOfPrivatePages--; if (PteContents.u.Hard.Valid) { - // - // It's valid. At this point make sure that it is not a ROS - // PFN. Also, we don't support ProtoPTEs in this code path. - // - Pfn1 = MiGetPfnEntry(PteContents.u.Hard.PageFrameNumber); - ASSERT(MI_IS_ROS_PFN(Pfn1) == FALSE); - ASSERT(Pfn1->u3.e1.PrototypePte == FALSE); - // // Flush any pending PTEs that we had not yet flushed, if our // list has gotten too big, then add this PTE to the flush list. // if (PteCount == 256) { - MiProcessValidPteList(ValidPteList, PteCount); + MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); PteCount = 0; } ValidPteList[PteCount++] = PointerPte; @@ -2623,7 +2626,7 @@ MiDecommitPages(IN PVOID StartingAddress, // This used to be a zero PTE and it no longer is, so we must add a // reference to the pagetable. // - MiIncrementPageTableReferences(StartingAddress); + MiIncrementPageTableReferences(MiPteToAddress(PointerPte)); // // Next, we account for decommitted PTEs and make the PTE as such @@ -2633,17 +2636,16 @@ MiDecommitPages(IN PVOID StartingAddress, } // - // Move to the next PTE and the next address + // Move to the next PTE // PointerPte++; - StartingAddress = (PVOID)((ULONG_PTR)StartingAddress + PAGE_SIZE); } // // Flush any dangling PTEs from the loop in the last page table, and then // release the working set and return the commit reduction accounting. // - if (PteCount) MiProcessValidPteList(ValidPteList, PteCount); + if (PteCount) MiProcessValidPteList(&Process->Vm, ValidPteList, PteCount); MiUnlockProcessWorkingSetUnsafe(Process, CurrentThread); return CommitReduction; } diff --git a/ntoskrnl/mm/freelist.c b/ntoskrnl/mm/freelist.c index 93d9bbd9f59..80447593ecd 100644 --- a/ntoskrnl/mm/freelist.c +++ b/ntoskrnl/mm/freelist.c @@ -574,6 +574,21 @@ MmAllocPage(ULONG Type) OldIrql = MiAcquirePfnLock(); +#if MI_TRACE_PFNS + switch(Type) + { + case MC_CACHE: + case MC_SYSTEM: + MI_SET_USAGE(MI_USAGE_CACHE); + break; + case MC_USER: + MI_SET_USAGE(MI_USAGE_SECTION); + break; + default: + ASSERT(FALSE); + } +#endif + PfnOffset = MiRemoveZeroPage(MI_GET_NEXT_COLOR()); if (!PfnOffset) { diff --git a/ntoskrnl/mm/i386/page.c b/ntoskrnl/mm/i386/page.c index 6b5ac1e8353..f8337dadc26 100644 --- a/ntoskrnl/mm/i386/page.c +++ b/ntoskrnl/mm/i386/page.c @@ -264,6 +264,10 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) MI_WRITE_INVALID_PTE(PointerPde, DemandZeroPde); // Tiny HACK: Parameter 1 is the architecture specific FaultCode for an access violation (i.e. page is present) + + /* Lock the working set, as this will add this address to it */ + MiLockProcessWorkingSetUnsafe(Process, PsGetCurrentThread()); + Status = MiDispatchFault(0x1, Pt, PointerPde, @@ -275,6 +279,8 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) DBG_UNREFERENCED_LOCAL_VARIABLE(Status); ASSERT(KeAreAllApcsDisabled() == TRUE); ASSERT(PointerPde->u.Hard.Valid == 1); + + MiUnlockProcessWorkingSetUnsafe(Process, PsGetCurrentThread()); } return (PULONG)MiAddressToPte(Address); } diff --git a/ntoskrnl/mm/marea.c b/ntoskrnl/mm/marea.c index d953f422f96..a68adecd9be 100644 --- a/ntoskrnl/mm/marea.c +++ b/ntoskrnl/mm/marea.c @@ -331,13 +331,16 @@ MmFreeMemoryArea( ASSERT(AddressSpace != MmGetKernelAddressSpace()); if (MiQueryPageTableReferences((PVOID)Address) == 0) { + KIRQL OldIrql; /* No PTE relies on this PDE. Release it */ - KIRQL OldIrql = MiAcquirePfnLock(); + MiLockProcessWorkingSet(Process, PsGetCurrentThread()); + OldIrql = MiAcquirePfnLock(); PMMPDE PointerPde = MiAddressToPde(Address); ASSERT(PointerPde->u.Hard.Valid == 1); MiDeletePte(PointerPde, MiPdeToPte(PointerPde), Process, NULL); ASSERT(PointerPde->u.Hard.Valid == 0); MiReleasePfnLock(OldIrql); + MiUnlockProcessWorkingSet(Process, PsGetCurrentThread()); } } #endif diff --git a/ntoskrnl/mm/section.c b/ntoskrnl/mm/section.c index ce63e796a3d..0825d4ecb49 100644 --- a/ntoskrnl/mm/section.c +++ b/ntoskrnl/mm/section.c @@ -1163,8 +1163,6 @@ MiReadPage(PMEMORY_AREA MemoryArea, * Allocate a page, this is rather complicated by the possibility * we might have to move other things out of memory */ - MI_SET_USAGE(MI_USAGE_SECTION); - MI_SET_PROCESS2(PsGetCurrentProcess()->ImageFileName); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, Page); if (!NT_SUCCESS(Status)) { @@ -1624,9 +1622,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, ((Offset.QuadPart >= (LONGLONG)PAGE_ROUND_UP(Segment->RawLength.QuadPart) && (Section->AllocationAttributes & SEC_IMAGE)))) { - MI_SET_USAGE(MI_USAGE_SECTION); - if (Process) MI_SET_PROCESS2(Process->ImageFileName); - if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page); if (!NT_SUCCESS(Status)) { @@ -1707,9 +1702,6 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace, MmUnlockSectionSegment(Segment); MmUnlockAddressSpace(AddressSpace); - MI_SET_USAGE(MI_USAGE_SECTION); - if (Process) MI_SET_PROCESS2(Process->ImageFileName); - if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &Page); if (!NT_SUCCESS(Status)) { @@ -1878,9 +1870,6 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace, /* * Allocate a page */ - MI_SET_USAGE(MI_USAGE_SECTION); - if (Process) MI_SET_PROCESS2(Process->ImageFileName); - if (!Process) MI_SET_PROCESS2("Kernel Section"); Status = MmRequestPageMemoryConsumer(MC_USER, TRUE, &NewPage); if (!NT_SUCCESS(Status)) {
4 years, 2 months
1
0
0
0
[reactos] 01/03: [NTOS/MM] Initialize process Working set and start implementing adding entries to it
by Jérôme Gardou
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5abc016401a59dfb60944…
commit 5abc016401a59dfb60944ea1fc8ea5ed27f7f087 Author: Jérôme Gardou <jerome.gardou(a)reactos.org> AuthorDate: Thu Oct 15 13:09:39 2020 +0200 Commit: Jérôme Gardou <jerome.gardou(a)reactos.org> CommitDate: Tue Oct 20 15:20:59 2020 +0200 [NTOS/MM] Initialize process Working set and start implementing adding entries to it --- ntoskrnl/mm/ARM3/miarm.h | 4 ++ ntoskrnl/mm/ARM3/pfnlist.c | 1 + ntoskrnl/mm/ARM3/procsup.c | 172 ++++++++++++++++++++++++++++++++++++++++----- sdk/include/ndk/mmtypes.h | 17 +++++ 4 files changed, 177 insertions(+), 17 deletions(-) diff --git a/ntoskrnl/mm/ARM3/miarm.h b/ntoskrnl/mm/ARM3/miarm.h index 9d85c42afff..6df6b7e5385 100644 --- a/ntoskrnl/mm/ARM3/miarm.h +++ b/ntoskrnl/mm/ARM3/miarm.h @@ -1054,6 +1054,10 @@ MI_WS_OWNER(IN PEPROCESS Process) (PsGetCurrentThread()->OwnsProcessWorkingSetShared))); } +VOID +NTAPI +MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection); + // // New ARM3<->RosMM PAGE Architecture // diff --git a/ntoskrnl/mm/ARM3/pfnlist.c b/ntoskrnl/mm/ARM3/pfnlist.c index f175541a500..b039a5181a2 100644 --- a/ntoskrnl/mm/ARM3/pfnlist.c +++ b/ntoskrnl/mm/ARM3/pfnlist.c @@ -1003,6 +1003,7 @@ MiInitializePfn(IN PFN_NUMBER PageFrameIndex, Pfn1->u3.e1.PageLocation = ActiveAndValid; ASSERT(Pfn1->u3.e1.Rom == 0); Pfn1->u3.e1.Modified = Modified; + Pfn1->u1.WsIndex = 0; /* Get the page table for the PTE */ PointerPtePte = MiAddressToPte(PointerPte); diff --git a/ntoskrnl/mm/ARM3/procsup.c b/ntoskrnl/mm/ARM3/procsup.c index 6407b7896d0..ab01d902686 100644 --- a/ntoskrnl/mm/ARM3/procsup.c +++ b/ntoskrnl/mm/ARM3/procsup.c @@ -840,6 +840,108 @@ MmCreateTeb(IN PEPROCESS Process, return Status; } +static +ULONG +MiGetFirstFreeWsleIndex(_Inout_ PMMSUPPORT Vm) +{ + PMMWSL WsList = Vm->VmWorkingSetList; + + /* Some sanity checks */ + ASSERT((WsList->FirstFree <= WsList->LastInitializedWsle) || (WsList->FirstFree == MMWSLE_NEXT_FREE_INVALID)); + ASSERT(WsList->LastEntry <= WsList->LastInitializedWsle + 1); + + /* Check if we are initializing */ + if (WsList->LastEntry == 0) + { + ASSERT(WsList->FirstDynamic < WsList->LastInitializedWsle); + return WsList->FirstDynamic++; + } + + if (WsList->FirstFree == MMWSLE_NEXT_FREE_INVALID) + { + if (WsList->LastEntry == WsList->LastInitializedWsle) + { + /* We must grow our array. Allocate a new page */ + PMMPTE PointerPte = MiAddressToPte(&WsList->Wsle[WsList->LastInitializedWsle + 1]); + MMPTE TempPte; + PFN_NUMBER PageFrameIndex = MiRemoveAnyPage(MI_GET_NEXT_COLOR()); + + MiInitializePfn(PageFrameIndex, PointerPte, TRUE); + MI_MAKE_HARDWARE_PTE_KERNEL(&TempPte, PointerPte, MM_READWRITE, PageFrameIndex); + MI_WRITE_VALID_PTE(PointerPte, TempPte); + + WsList->LastInitializedWsle += PAGE_SIZE / sizeof(MMWSLE); + + /* We must insert this page in our working set ! */ + MiInsertInWorkingSetList(Vm, &WsList->Wsle[WsList->LastInitializedWsle], MM_READWRITE); + } + + /* At this point we must be good to go */ + ASSERT(WsList->LastEntry < WsList->LastInitializedWsle); + + return ++WsList->LastEntry; + } + else + { + ULONG WsIndex = WsList->FirstFree; + PMMWSLE WsleEntry = &WsList->Wsle[WsIndex]; + + ASSERT(WsIndex < WsList->LastEntry); + + ASSERT(WsleEntry->u1.Free.MustBeZero == 0); + ASSERT(WsleEntry->u1.Free.PreviousFree == MMWSLE_PREVIOUS_FREE_INVALID); + ASSERT(WsleEntry->u1.Free.NextFree > WsIndex); + + if (WsleEntry->u1.Free.NextFree != MMWSLE_NEXT_FREE_INVALID) + { + PMMWSLE_FREE_ENTRY NextFree = &WsList->Wsle[WsleEntry->u1.Free.NextFree].u1.Free; + + ASSERT(NextFree->MustBeZero == 0); + ASSERT(NextFree->PreviousFree == WsList->FirstFree); + NextFree->PreviousFree = MMWSLE_PREVIOUS_FREE_INVALID; + } + + WsList->FirstFree = WsleEntry->u1.Free.NextFree; + + return WsIndex; + } +} + +VOID +NTAPI +MiInsertInWorkingSetList(_Inout_ PMMSUPPORT Vm, _In_ PVOID Address, _In_ ULONG Protection) +{ + ULONG WsIndex = MiGetFirstFreeWsleIndex(Vm); + PMMWSLE WsleEntry = &Vm->VmWorkingSetList->Wsle[WsIndex]; + PMMPTE PointerPte = MiAddressToPte(Address); + PMMPFN Pfn1 = MiGetPfnEntry(PFN_FROM_PTE(PointerPte)); + + /* Make sure we got a rounded address */ + Address = ALIGN_DOWN_POINTER_BY(Address, PAGE_SIZE); + + /* Make sure we are locking the right thing */ + ASSERT(MM_ANY_WS_LOCK_HELD(PsGetCurrentThread())); + + /* The Pfn must be an active one */ + ASSERT(Pfn1->u3.e1.PageLocation == ActiveAndValid); + + WsleEntry->u1.Long = 0; + WsleEntry->u1.VirtualAddress = Address; + WsleEntry->u1.e1.Protection = Protection; + + /* Shared pages not supported yet */ + ASSERT(Pfn1->u1.WsIndex == 0); + WsleEntry->u1.e1.Direct = 1; + + Pfn1->u1.WsIndex = WsIndex; + WsleEntry->u1.e1.Valid = 1; + + Vm->WorkingSetSize += PAGE_SIZE; + if (Vm->WorkingSetSize > Vm->PeakWorkingSetSize) + Vm->PeakWorkingSetSize = Vm->WorkingSetSize; +} + + VOID NTAPI MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) @@ -848,30 +950,56 @@ MiInitializeWorkingSetList(IN PEPROCESS CurrentProcess) PMMPTE sysPte; MMPTE tempPte; - /* Setup some bogus list data */ - MmWorkingSetList->LastEntry = CurrentProcess->Vm.MinimumWorkingSetSize; + /* We start with the space left behind us */ + MmWorkingSetList->Wsle = (PMMWSLE)(MmWorkingSetList + 1); + /* Which leaves us this much entries */ + MmWorkingSetList->LastInitializedWsle = ((PAGE_SIZE - sizeof(MMWSL)) / sizeof(MMWSLE)) - 1; + + /* No entry in this list yet ! */ + MmWorkingSetList->LastEntry = 0; MmWorkingSetList->HashTable = NULL; MmWorkingSetList->HashTableSize = 0; MmWorkingSetList->NumberOfImageWaiters = 0; - MmWorkingSetList->Wsle = (PVOID)(ULONG_PTR)0xDEADBABEDEADBABEULL; - MmWorkingSetList->VadBitMapHint = 1; - MmWorkingSetList->HashTableStart = (PVOID)(ULONG_PTR)0xBADAB00BBADAB00BULL; - MmWorkingSetList->HighestPermittedHashAddress = (PVOID)(ULONG_PTR)0xCAFEBABECAFEBABEULL; - MmWorkingSetList->FirstFree = 1; - MmWorkingSetList->FirstDynamic = 2; - MmWorkingSetList->NextSlot = 3; - MmWorkingSetList->LastInitializedWsle = 4; - - /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */ - Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT); - ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); - Pfn1->u1.Event = (PKEVENT)CurrentProcess; + MmWorkingSetList->VadBitMapHint = 0; + MmWorkingSetList->HashTableStart = NULL; + MmWorkingSetList->HighestPermittedHashAddress = NULL; + MmWorkingSetList->FirstFree = MMWSLE_NEXT_FREE_INVALID; + MmWorkingSetList->FirstDynamic = 0; + MmWorkingSetList->NextSlot = 0; /* Map the process working set in kernel space */ + /* FIXME: there should be no need */ sysPte = MiReserveSystemPtes(1, SystemPteSpace); MI_MAKE_HARDWARE_PTE_KERNEL(&tempPte, sysPte, MM_READWRITE, CurrentProcess->WorkingSetPage); MI_WRITE_VALID_PTE(sysPte, tempPte); CurrentProcess->Vm.VmWorkingSetList = MiPteToAddress(sysPte); + + /* Insert the address we already know: our PDE base and the Working Set List */ +#if _MI_PAGING_LEVELS == 4 + MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PXE_BASE, 0); +#elif _MI_PAGING_LEVELS == 3 + MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PPE_BASE, 0); +#elif _MI_PAGING_LEVELS == 2 + MiInsertInWorkingSetList(&CurrentProcess->Vm, (PVOID)PDE_BASE, 0); +#endif + +#if _MI_PAGING_LEVELS == 4 + MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPpe(MmWorkingSetList), 0); +#endif +#if _MI_PAGING_LEVELS >= 3 + MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPde(MmWorkingSetList), 0); +#endif + MiInsertInWorkingSetList(&CurrentProcess->Vm, MiAddressToPte(MmWorkingSetList), 0); + MiInsertInWorkingSetList(&CurrentProcess->Vm, MmWorkingSetList, 0); + + /* The rule is that the owner process is always in the FLINK of the PDE's PFN entry */ + Pfn1 = MiGetPfnEntry(CurrentProcess->Pcb.DirectoryTableBase[0] >> PAGE_SHIFT); + ASSERT(Pfn1->u4.PteFrame == MiGetPfnEntryIndex(Pfn1)); + ASSERT(Pfn1->u1.WsIndex == 0); + Pfn1->u1.Event = (PKEVENT)CurrentProcess; + + /* Mark this as not initializing anymore */ + MmWorkingSetList->LastEntry = MmWorkingSetList->FirstDynamic - 1; } NTSTATUS @@ -915,12 +1043,17 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, ASSERT(Process->VadRoot.NumberGenericTableElements == 0); Process->VadRoot.BalancedRoot.u1.Parent = &Process->VadRoot.BalancedRoot; + /* Lock our working set */ + MiLockProcessWorkingSet(Process, PsGetCurrentThread()); + /* Lock PFN database */ OldIrql = MiAcquirePfnLock(); /* Setup the PFN for the PDE base of this process */ -#ifdef _M_AMD64 +#if _MI_PAGING_LEVELS == 4 PointerPte = MiAddressToPte(PXE_BASE); +#elif _MI_PAGING_LEVELS == 3 + PointerPte = MiAddressToPte(PPE_BASE); #else PointerPte = MiAddressToPte(PDE_BASE); #endif @@ -929,8 +1062,10 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, MiInitializePfn(PageFrameNumber, PointerPte, TRUE); /* Do the same for hyperspace */ -#ifdef _M_AMD64 +#if _MI_PAGING_LEVELS == 4 PointerPde = MiAddressToPxe((PVOID)HYPER_SPACE); +#elif _MI_PAGING_LEVELS == 3 + PointerPde = MiAddressToPpe((PVOID)HYPER_SPACE); #else PointerPde = MiAddressToPde(HYPER_SPACE); #endif @@ -957,6 +1092,9 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process, /* Release PFN lock */ MiReleasePfnLock(OldIrql); + /* Release the process working set */ + MiUnlockProcessWorkingSet(Process, PsGetCurrentThread()); + /* Check if there's a Section Object */ if (SectionObject) { diff --git a/sdk/include/ndk/mmtypes.h b/sdk/include/ndk/mmtypes.h index ca62ebdf5ce..06d088bf5ab 100644 --- a/sdk/include/ndk/mmtypes.h +++ b/sdk/include/ndk/mmtypes.h @@ -844,6 +844,22 @@ typedef struct _MMWSLENTRY ULONG_PTR VirtualPageNumber: MM_PAGE_FRAME_NUMBER_SIZE; } MMWSLENTRY, *PMMWSLENTRY; +typedef struct _MMWSLE_FREE_ENTRY +{ + ULONG MustBeZero:1; +#ifdef _WIN64 + ULONG PreviousFree: 31; + ULONG NextFree; +#define MMWSLE_PREVIOUS_FREE_INVALID 0x7FFFFFFF +#define MMWSLE_NEXT_FREE_INVALID 0xFFFFFFFF +#else + ULONG PreviousFree: 15; + ULONG NextFree: 16; +#define MMWSLE_PREVIOUS_FREE_INVALID 0x7FFF +#define MMWSLE_NEXT_FREE_INVALID 0xFFFF +#endif +} MMWSLE_FREE_ENTRY, *PMMWSLE_FREE_ENTRY; + typedef struct _MMWSLE { union @@ -851,6 +867,7 @@ typedef struct _MMWSLE PVOID VirtualAddress; ULONG_PTR Long; MMWSLENTRY e1; + MMWSLE_FREE_ENTRY Free; } u1; } MMWSLE, *PMMWSLE;
4 years, 2 months
1
0
0
0
[reactos] 01/01: [USETUP] Work around GCC's complaints (will be fixed properly later on).
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6c94e4f4876fd230d6286…
commit 6c94e4f4876fd230d62860b34d4df9651ffb58ba Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Tue Oct 20 01:26:49 2020 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Tue Oct 20 01:32:30 2020 +0200 [USETUP] Work around GCC's complaints (will be fixed properly later on). --- base/setup/usetup/usetup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index abc18ff0222..b4956d1be46 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -3519,7 +3519,7 @@ FormatPartitionPage(PINPUT_RECORD Ir) "\n" " \x07 Press ENTER to continue Setup.\n" " \x07 Press F3 to quit Setup.", - PartEntry->FileSystem); + SelectedFileSystem->FileSystem /* PartEntry->FileSystem */); PopupError(Buffer, MUIGetString(STRING_QUITCONTINUE),
4 years, 2 months
1
0
0
0
[reactos] 01/01: [USETUP][SETUPLIB] Continue hiding the FAT32 format in the format list, but take it into account anyway later on.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=08924c1850a26e10c4478…
commit 08924c1850a26e10c4478cd8448b0fc57ecc1718 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Mon Oct 19 23:49:26 2020 +0200 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Tue Oct 20 01:19:58 2020 +0200 [USETUP][SETUPLIB] Continue hiding the FAT32 format in the format list, but take it into account anyway later on. The formatter will select it anyway as soon as the partition size permits it. We make it available internally however so as to "emulate" FMIFS functionality. Now rely on the partition filesystem for InstallVBRToPartition() instead of the unreliable and deprecated partition type. --- base/setup/lib/bootsup.c | 78 ++++++++++++++++++++++++---------------------- base/setup/lib/bootsup.h | 2 +- base/setup/lib/fsutil.c | 29 +++++++++++------ base/setup/lib/fsutil.h | 6 ++-- base/setup/usetup/fslist.c | 31 ++++++++++++++++-- base/setup/usetup/usetup.c | 10 +++--- 6 files changed, 97 insertions(+), 59 deletions(-) diff --git a/base/setup/lib/bootsup.c b/base/setup/lib/bootsup.c index c7462403630..37f7bdb43ab 100644 --- a/base/setup/lib/bootsup.c +++ b/base/setup/lib/bootsup.c @@ -794,7 +794,7 @@ InstallFatBootcodeToPartition( IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, - IN UCHAR PartitionType) + IN PCWSTR FileSystemName) { NTSTATUS Status; BOOLEAN DoesFreeLdrExist; @@ -856,8 +856,7 @@ InstallFatBootcodeToPartition( /* Install new bootcode into a file */ CombinePaths(DstPath, ARRAYSIZE(DstPath), 2, SystemRootPath->Buffer, L"bootsect.ros"); - if (PartitionType == PARTITION_FAT32 || - PartitionType == PARTITION_FAT32_XINT13) + if (wcsicmp(FileSystemName, L"FAT32") == 0) { /* Install FAT32 bootcode */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin"); @@ -872,7 +871,7 @@ InstallFatBootcodeToPartition( return Status; } } - else + else // if (wcsicmp(FileSystemName, L"FAT") == 0) { /* Install FAT16 bootcode */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); @@ -1070,8 +1069,7 @@ InstallFatBootcodeToPartition( } /* Install new bootsector on the disk */ - if (PartitionType == PARTITION_FAT32 || - PartitionType == PARTITION_FAT32_XINT13) + if (wcsicmp(FileSystemName, L"FAT32") == 0) { /* Install FAT32 bootcode */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat32.bin"); @@ -1084,7 +1082,7 @@ InstallFatBootcodeToPartition( return Status; } } - else + else // if (wcsicmp(FileSystemName, L"FAT") == 0) { /* Install FAT16 bootcode */ CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 2, SourceRootPath->Buffer, L"\\loader\\fat.bin"); @@ -1212,40 +1210,46 @@ InstallVBRToPartition( IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, - IN UCHAR PartitionType) + IN PCWSTR FileSystemName) { - switch (PartitionType) + if (wcsicmp(FileSystemName, L"FAT") == 0 || + wcsicmp(FileSystemName, L"FAT32") == 0) { - case PARTITION_FAT_12: - case PARTITION_FAT_16: - case PARTITION_HUGE: - case PARTITION_XINT13: - case PARTITION_FAT32: - case PARTITION_FAT32_XINT13: - { - return InstallFatBootcodeToPartition(SystemRootPath, - SourceRootPath, - DestinationArcPath, - PartitionType); - } - - case PARTITION_LINUX: - { - return InstallBtrfsBootcodeToPartition(SystemRootPath, - SourceRootPath, - DestinationArcPath); - } - - case PARTITION_IFS: - DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n"); - break; - - default: - DPRINT1("PartitionType 0x%02X unknown!\n", PartitionType); - break; + return InstallFatBootcodeToPartition(SystemRootPath, + SourceRootPath, + DestinationArcPath, + FileSystemName); + } + /* + else if (wcsicmp(FileSystemName, L"NTFS") == 0) + { + DPRINT1("Partitions of type NTFS or HPFS are not supported yet!\n"); + return STATUS_NOT_SUPPORTED; + } + */ + else if (wcsicmp(FileSystemName, L"BTRFS") == 0) + { + return InstallBtrfsBootcodeToPartition(SystemRootPath, + SourceRootPath, + DestinationArcPath); + } + /* + else if (wcsicmp(FileSystemName, L"EXT2") == 0 || + wcsicmp(FileSystemName, L"EXT3") == 0 || + wcsicmp(FileSystemName, L"EXT4") == 0 || + wcsicmp(FileSystemName, L"FFS") == 0 || + wcsicmp(FileSystemName, L"REISERFS") == 0) + { + return STATUS_NOT_SUPPORTED; + } + */ + else + { + /* Unknown file system */ + DPRINT1("Unknown file system '%S'\n", FileSystemName); } - return STATUS_UNSUCCESSFUL; + return STATUS_NOT_SUPPORTED; } diff --git a/base/setup/lib/bootsup.h b/base/setup/lib/bootsup.h index c9bd8544ee0..3dcb2b6fd03 100644 --- a/base/setup/lib/bootsup.h +++ b/base/setup/lib/bootsup.h @@ -37,7 +37,7 @@ InstallVBRToPartition( IN PUNICODE_STRING SystemRootPath, IN PUNICODE_STRING SourceRootPath, IN PUNICODE_STRING DestinationArcPath, - IN UCHAR PartitionType); + IN PCWSTR FileSystemName); NTSTATUS InstallFatBootcodeToFloppy( diff --git a/base/setup/lib/fsutil.c b/base/setup/lib/fsutil.c index 9bd0aee4c2a..fec1aa7283a 100644 --- a/base/setup/lib/fsutil.c +++ b/base/setup/lib/fsutil.c @@ -129,11 +129,11 @@ typedef struct _FILE_SYSTEM /* The list of file systems on which we can install ReactOS */ static FILE_SYSTEM RegisteredFileSystems[] = { - /* NOTE: The FAT formatter automatically determines - * whether it will use FAT-16 or FAT-32. */ + /* NOTE: The FAT formatter will automatically + * determine whether to use FAT12/16 or FAT32. */ { L"FAT" , VfatFormat, VfatChkdsk }, + { L"FAT32", VfatFormat, VfatChkdsk }, #if 0 - { L"FAT32", VfatFormat, VfatChkdsk }, // Do we support specific FAT sub-formats specifications? { L"FATX" , VfatxFormat, VfatxChkdsk }, { L"NTFS" , NtfsFormat, NtfsChkdsk }, #endif @@ -180,9 +180,7 @@ GetFileSystemByName( { Item = CONTAINING_RECORD(ListEntry, FILE_SYSTEM_ITEM, ListEntry); if (Item->FileSystemName && - (wcsicmp(FileSystemName, Item->FileSystemName) == 0 || - /* Map FAT32 back to FAT */ - (wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(Item->FileSystemName, L"FAT") == 0))) + (wcsicmp(FileSystemName, Item->FileSystemName) == 0)) { return Item; } @@ -200,9 +198,7 @@ GetFileSystemByName( while (Count--) { if (FileSystems->FileSystemName && - (wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0 || - /* Map FAT32 back to FAT */ - (wcsicmp(FileSystemName, L"FAT32") == 0 && wcsicmp(FileSystems->FileSystemName, L"FAT") == 0))) + (wcsicmp(FileSystemName, FileSystems->FileSystemName) == 0)) { return FileSystems; } @@ -330,7 +326,7 @@ FormatFileSystem( // NTSTATUS -InstallFat1216BootCode( +InstallFatBootCode( IN PCWSTR SrcPath, // FAT12/16 bootsector source file (on the installation medium) IN HANDLE DstPath, // Where to save the bootsector built from the source + partition information IN HANDLE RootPartition) // Partition holding the (old) FAT12/16 information @@ -645,6 +641,19 @@ PreparePartitionForFormatting( SetPartitionType(PartEntry, PartitionType); + /* + * Adjust the filesystem name in case of FAT vs. FAT32, according to + * the type of partition set by FileSystemToPartitionType(). + */ + if (wcsicmp(FileSystemName, L"FAT") == 0) + { + if ((/*PartEntry->*/PartitionType == PARTITION_FAT32) || + (/*PartEntry->*/PartitionType == PARTITION_FAT32_XINT13)) + { + FileSystemName = L"FAT32"; + } + } + // // FIXME: Do this now, or after the partition was actually formatted?? // diff --git a/base/setup/lib/fsutil.h b/base/setup/lib/fsutil.h index d4518885b9f..ef5e6a3ccd8 100644 --- a/base/setup/lib/fsutil.h +++ b/base/setup/lib/fsutil.h @@ -76,13 +76,13 @@ typedef NTSTATUS IN HANDLE RootPartition); // Partition holding the (old) bootsector data information NTSTATUS -InstallFat1216BootCode( +InstallFatBootCode( IN PCWSTR SrcPath, IN HANDLE DstPath, IN HANDLE RootPartition); -#define InstallFat12BootCode InstallFat1216BootCode -#define InstallFat16BootCode InstallFat1216BootCode +#define InstallFat12BootCode InstallFatBootCode +#define InstallFat16BootCode InstallFatBootCode NTSTATUS InstallFat32BootCode( diff --git a/base/setup/usetup/fslist.c b/base/setup/usetup/fslist.c index 75c9fbfaf0d..05c45d9da57 100644 --- a/base/setup/usetup/fslist.c +++ b/base/setup/usetup/fslist.c @@ -29,6 +29,9 @@ #define NDEBUG #include <debug.h> +/* Enable this define to hide FAT32 choice in case FAT is already present */ +#define HIDE_FAT32_CHOICE + /* FUNCTIONS ****************************************************************/ static VOID @@ -60,14 +63,38 @@ AddProvider( static VOID InitializeFileSystemList( - IN PFILE_SYSTEM_LIST List, + IN OUT PFILE_SYSTEM_LIST List, IN BOOLEAN ForceFormat) { - ULONG Index = 0; PCWSTR FileSystemName; + ULONG Index; + +#ifdef HIDE_FAT32_CHOICE + BOOLEAN FatPresent = FALSE; + + /* Check whether the FAT filesystem is present */ + Index = 0; + while (GetRegisteredFileSystems(Index++, &FileSystemName)) + { + if (wcsicmp(FileSystemName, L"FAT") == 0) + { + FatPresent = TRUE; + break; + } + } + +#endif + Index = 0; while (GetRegisteredFileSystems(Index++, &FileSystemName)) { +#ifdef HIDE_FAT32_CHOICE + /* USETUP only: If the FAT filesystem is present, show it, but + * don't display FAT32. The FAT formatter will automatically + * determine whether to use FAT12/16 or FAT32. */ + if (FatPresent && wcsicmp(FileSystemName, L"FAT32") == 0) + continue; +#endif AddProvider(List, FileSystemName); } diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c index cdd6a3e4f74..abc18ff0222 100644 --- a/base/setup/usetup/usetup.c +++ b/base/setup/usetup/usetup.c @@ -3510,7 +3510,7 @@ FormatPartitionPage(PINPUT_RECORD Ir) /* Format the partition */ Status = FormatPartition(&PartitionRootPath, - SelectedFileSystem->FileSystem, + PartEntry->FileSystem, SelectedFileSystem->QuickFormat); if (Status == STATUS_NOT_SUPPORTED) { @@ -3519,7 +3519,7 @@ FormatPartitionPage(PINPUT_RECORD Ir) "\n" " \x07 Press ENTER to continue Setup.\n" " \x07 Press F3 to quit Setup.", - SelectedFileSystem->FileSystem); + PartEntry->FileSystem); PopupError(Buffer, MUIGetString(STRING_QUITCONTINUE), @@ -4612,11 +4612,10 @@ BootLoaderHarddiskVbrPage(PINPUT_RECORD Ir) { NTSTATUS Status; - // FIXME! We must not use the partition type, but instead use the partition FileSystem!! Status = InstallVBRToPartition(&USetupData.SystemRootPath, &USetupData.SourceRootPath, &USetupData.DestinationArcPath, - SystemPartition->PartitionType); + SystemPartition->FileSystem); if (!NT_SUCCESS(Status)) { MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER, @@ -4649,11 +4648,10 @@ BootLoaderHarddiskMbrPage(PINPUT_RECORD Ir) WCHAR DestinationDevicePathBuffer[MAX_PATH]; /* Step 1: Write the VBR */ - // FIXME! We must not use the partition type, but instead use the partition FileSystem!! Status = InstallVBRToPartition(&USetupData.SystemRootPath, &USetupData.SourceRootPath, &USetupData.DestinationArcPath, - SystemPartition->PartitionType); + SystemPartition->FileSystem); if (!NT_SUCCESS(Status)) { MUIDisplayError(ERROR_WRITE_BOOT, Ir, POPUP_WAIT_ENTER,
4 years, 2 months
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
16
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Results per page:
10
25
50
100
200