Commit graph

351 commits

Author SHA1 Message Date
Jérôme Gardou 75125228be [NTOS] Add some sanity checks when synchronizing PDEs 2022-09-17 13:48:56 +02:00
Kyle Katarn 3703bbd631
[NTOS:MM] Implement PeakCommitment (MmPeakCommitment, MmTotalCommittedPages) (#4650)
And return the corresponding values in SystemPerformanceInformation.
Lockless updating counters suggestion by Thomas Faber.
2022-09-12 14:22:52 +02:00
Serge Gautherie 730b13daac
[NTOS:MM] kdbg.c: Fix Argv[n] copypastas (#4634) 2022-08-27 15:58:54 +02:00
Timo Kreuzer 253362509e [KDBG] Fix x64 KDBG 2022-07-20 23:57:42 +02:00
Tuur Martens 10126e7710 [NTOS:MM] Fix VADs being inserted even though the quota would exceed
Since we were charging the pool quota after the VAD insertion,
if the quota charge failed, the VAD would still have been inserted.
This commit attempts to resolve this issue by charging quota
before inserting the VAD thus allowing the quota charge to fail early.

Addendum to 884356a0. CORE-18028
2022-07-06 18:48:32 +02:00
Timo Kreuzer f606b36cff [NTOSKRNL] Fix a bug in MiDeleteVirtualAddresses
When a PDE gets empty, we skip the address to the next PDE boundary, which might introduce an AddressGap, which wasn't handled before.
2022-07-05 19:29:05 +02:00
Tuur Martens d31642c712 [NTOS:MM] Fix memory leak in NtAllocateVirtualMemory
When an allocated VAD's insertion fails, the VAD is not freed. This commit attempts to fix this behaviour.
2022-06-04 22:44:27 +02:00
Tuur Martens cc99b9d96e [NTOS:MM] Fix MiInsertSharedUserPageVad preventing boot on x64
Fix MiInsertSharedUserPageVad to not charge the system process pool quota.
Even though PsChargeProcessNonPagedPoolQuota itself checks if the process specified is the system process, this doesn't work here as we're too early into boot for the kernel to know what the system process is.
2022-05-29 13:28:27 +02:00
Tuur Martens 4f8bbd141e [NTOS:MM] Fix memory leak in MiMapViewOfDataSection
If inserting the allocated VAD fails, MiMapViewOfDataSection will make no attempt to free the allocated VAD. Nor will it call MiDereferenceControlArea(ControlArea); like other failure return paths. This commit fixes this behavior.
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2022-05-18 12:31:31 +02:00
Tuur Martens 884356a06e [NTOS:MM] Charge and free quotas for VAD allocations
Charge quotas for VAD allocations and free the quotas again when the VADs are freed.

CORE-18028
2022-05-14 15:09:50 +02:00
Thomas Faber 8d701598fb
[NTOS:MM] Implement partial virtual region releases. CORE-17938
Fixes boot with MS videoprt.sys (and some apitests).
2022-01-22 15:07:06 -05:00
George Bișoc 1649a89cfa
[NTOS:MM] Implement Raise/Return pool quota functions
This implements both MmRaisePoolQuota and MmReturnPoolQuota functions, which serve exclusively for quota pool management. The process manager communicates with the memory manager in a call of need to charge or return pool quota limits.
2022-01-11 10:11:09 +01:00
Stanislav Motylkov f18fb7da09
[NTOS:MM] Unrefernece some dereferences 2021-12-30 01:54:09 +03:00
Thomas Faber 0af3689c2e
[REACTOS] Fix traces with missing arguments.
Courtesy of VS Code Analysis warning C6064:
Missing integer argument to 'DbgPrint' that corresponds to conversion specifier 'N'.
2021-11-21 12:57:35 -05:00
Thomas Faber a7b2703479
[NTOS] Fix broken SAL annotations on MmDereferenceSegmentWithLock. 2021-11-21 12:47:46 -05:00
Hermès Bélusca-Maïto fe9ac14aa3
[NTOS] Move two CODE_SEG("INIT") to a better place. 2021-09-05 21:22:45 +02:00
Victor Perevertkin 6ef6fabfc5
[FREELDR][NTOS][HALPPC][SDK] Remove PowerPC code
Remove PowerPC-related code from the kernel, HAL, SDK and
Freeloader.
2021-08-15 15:35:51 +03:00
Jérôme Gardou 589016ddb9 [NTOS:MM] Implement MmFlushImageSection(MmFlushForWrite) 2021-08-07 09:34:58 +02:00
Jérôme Gardou acf28dbc1e [NTOS:MM] Fix the mess created by the "balancer thread"
When processing:
  Make sure that the process is not terminating.
  Make sure that the process WorkingSet is still valid
  Protect accessing & writing to PTEs by acquiring the working set lock

CORE-17595 CORE-17642
2021-08-05 10:06:19 +02:00
Jérôme Gardou 676dc4b441 Revert "[NTOS:MM] Do proper checks & acquire proper locks when sweeping user pages"
This reverts commit 7c006df7e0.
Note to self: This is what happens when you have too many branch and push the wrong one.
2021-08-04 23:57:39 +02:00
Jérôme Gardou 7c006df7e0 [NTOS:MM] Do proper checks & acquire proper locks when sweeping user pages
CORE-17595
2021-08-04 20:38:37 +02:00
Jérôme Gardou 789d7a7741 [NTOS:MM] When mapping pages for zeroing them, disable cache, enable write through
Idea from Thomas Faber
2021-08-04 17:48:39 +02:00
Jérôme Gardou 98e62b9bca [NTOS:MM] In page zeroing thread, zero more than one page at a time. 2021-08-04 17:48:39 +02:00
Jérôme Gardou e98de5ef1f [NTOS:MM] Use KeZeroPages in zeroing thread 2021-08-04 17:48:39 +02:00
Jérôme Gardou 708dc6b7d6 [NTOS:MM] Do not zero-fill pages when not needed 2021-08-04 17:48:39 +02:00
Jérôme Gardou 34662e2f6f [NTOS:MM] Copy the WorkingSet page when initializing "hand-built" process
CORE-17642
2021-08-04 11:49:38 +02:00
Jérôme Gardou be6a6b806a [NTOS:MM] Remove dead code 2021-08-03 10:57:12 +02:00
Jérôme Gardou b0dfe20981 [NTOS:MM] Fix MiIsUserPte inline 2021-07-30 18:54:54 +02:00
Jérôme Gardou ce65553eaa [NTOS:MM] Annotate some functions with regards to MmPfnLock
Also fix MI_ASSERT_PFN_LOCK_HELD macro.
Now in debug builds, SpinLocks are always non-zero when held.
2021-07-27 15:36:55 +02:00
Jérôme Gardou 6150dc994a [NTOS:MM] Always release PFN lock in MmDereferenceSegmentWithLock
All callers release it after calling it.
CORE-17698
2021-07-27 15:36:55 +02:00
Timo Kreuzer 47372e2ac9 [NTOS:MM] Fix MiSetSystemCodeProtection
CORE-16387 CORE-17638
Windows only makes the header RO for session space mapped drivers (win32k, dx and display drivers)
2021-07-11 21:43:07 +02:00
Jérôme Gardou 91587a432b [NTOS:MM] Fix another instance of reentrant spinlock acquisition 2021-06-29 11:49:20 +02:00
Jérôme Gardou 376fbc5242 [NTOS:MM] Check result of RtlCreateUnicodeString in MmGetFileNameForAddress
CORE-17637
2021-06-28 10:20:57 +02:00
Jérôme Gardou 59cddd15e2 [NTOS:MM] Implement MmFlushImageSection(MmFlushForDelete)
CORE-17544
2021-06-25 10:28:51 +02:00
Jérôme Gardou b3e9c89725 [NTOS:MM] Simplify refcounting when adding/deleting a page in a shared segment
CORE-17544
2021-06-25 10:28:51 +02:00
Jérôme Gardou bec42b6530 [NTOS:MM] Do not call ExAllocatePool* with PFN lock acquired
Unsurprisingly, it actually might acquire it
2021-06-25 10:28:51 +02:00
Jérôme Gardou c6e9fea844 [NTOSKRNL] Deduplicate some symbols 2021-06-24 18:48:31 +02:00
Jérôme Gardou 1c5ce8d11c [NTOS:MM] Fix-up call site of traced PFNs when serving a page fault 2021-06-24 18:48:31 +02:00
Jérôme Gardou 146337cc50 [NTOS:MM] Save caller address when tracing PFNs 2021-06-24 18:48:31 +02:00
Jérôme Gardou c8ce0cc434 [NTOS:MM] Fix one occurrence of MiDeletePte instead of MiDeletePde 2021-06-22 12:05:20 +02:00
Serge Gautherie eab2bb4b20 [NTOS:MM] MmFlushSegment(): Fix Iosb annotation
Addendum to 90c6a65.
2021-06-22 10:33:45 +02:00
Timo Kreuzer 396167bc7e [NTOS:MM] Improve an ASSERT 2021-06-19 12:17:18 +02:00
Timo Kreuzer 33949028fb [NTOS:MM] Fix PFN lock usage 2021-06-19 12:17:18 +02:00
Victor Perevertkin 3f601122bc [NTOS:MM] Fix placing entries into MmNonPagedPoolFreeListHead
When freeing pages, free page entries with pages num == 3 were
incorrectly treated as entries with pages num >= 4 and thus
their re-insertion was not triggered. That lead to non paged pool
fragmentation (can be triggered by kmtest:ExPools, for example)

Also, altered the index acquisition code for MmNonPagedPoolFreeList
entries so it looks more clear
2021-06-16 12:14:27 +02:00
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Jérôme Gardou afc27ab1aa [NTOS:MM] Handle PT references for page table faults in MmAccessFault
Idea from Timo Kreuzer
2021-06-09 11:27:18 +02:00
Jérôme Gardou c7e09061ca [NTOS:MM] Get rid of MiQueryPageTableReferences 2021-06-09 11:27:18 +02:00
Timo Kreuzer 6a2eeaa5ae [NTOS] Implement MiIsPageTablePresent as a replacement for the abused MiQueryPageTableReferences 2021-06-09 11:27:18 +02:00
Jérôme Gardou 678923bf4b [NTOS:MM] In MiMakePdeExistAndValid, do not overly check PDE validity
It's "okay" to not #ifdef, but it's useless and confusing.
2021-06-09 11:27:18 +02:00
Jérôme Gardou c8fb3f7514 [NTOS:MM] Implement proper refcounting of page tables on amd64
CORE-17552
2021-06-09 11:27:18 +02:00