Commit graph

100 commits

Author SHA1 Message Date
Ratin Gao ffb20d3330
[REACTOS] Fix typos (#6198)
- Adress -> Address
- Currupted -> Corrupted

3rd-party files are not modified.
2023-12-23 21:37:08 +01:00
Timo Kreuzer 07ad8c4c11 [NTOS:MM] Attach to the target process in MmMapViewOfSection
This is required to satisfy VAD locking rules.
2023-10-24 21:45:27 +03:00
Joachim Henze 8c76870639 [NTOS:MM] Fix missing \n in unimplemented codepath DPRINT
We can hit that unimplemented code-path-line in NtQuerySection()
when browsing youtube.com with Chromium 49.
2023-09-30 19:06:30 +02:00
Timo Kreuzer 9bc5b8357a [NTOS:MM] Fix use-after-free error
The VAD / memory area can get deleted when calling MmUnmapViewOfSegment, so it must not be used after that.
2023-08-05 11:57:58 +03:00
Timo Kreuzer 7c6e4d38c7 [NTOS:Mm] Handle failure to allocate pages in the page fault handler 2023-07-29 14:00:44 +03:00
Timo Kreuzer 73de609917 [NTOS:Mm] Implement MmCreatePhysicalMapping and MmDeletePhysicalMapping to handle pyhsical memory sections 2023-07-29 14:00:44 +03:00
Timo Kreuzer 477792856e [NTOS:Mm] Replace YieldProcessor() with KeDelayExecutionThread()
These are used in the paging path, when the page is currently in the process of being read from or written to the disk. While YieldProcessor() provides the chance to switch context to the other paging thread, it only does so, once the current thread's quantum has expired. On a single CPU system this effectively leads to busy waiting for the rest of the quantum. On SMP systems this could succeed earlier, thus reducing latency, but it would still contribute to high CPU usage, while waiting for the IO operation to complete, which is not what we want.
Using KeDelayExecutionThread() will instantly allow another thread to run, providing enough time to complete the IO operation.
2023-07-29 14:00:44 +03:00
Adam Słaboń 6eb8fe4f82
[NTOS:MM] MmCanFileBeTruncated: Check whether second (optional) parameter was passed (#5248)
Second parameter is optional, so mark it as such and check whether it was passed. Fixes a sporadic 0x24 bugcheck caused by access violation when running ReactOS on NTFS volume with WinXP ntfs.sys.
2023-04-19 23:12:11 +02:00
Jérôme Gardou 573d579873
[NTOSKRNL] Flush file to disk when deleting file mappings (#4302)
CORE-17627
When closing a file, fastfat zeroes it out from ValidDataLength up to the end of the file.
The ValidDataLength field is updated when the file content is actually written to disk.
There is currently a race between the file-close path and the page out path, leading to potential file corruptions when the zeroing happens after the memory has been flushed to disk.

Fix this by actually flushing the file to disk when unmapping files, with file lock acquired. This way, the FS driver cannot zero out the tail of the file while we're actually flushing it to disk.
2023-04-01 23:56:49 +09:00
Roy Tam 0d4a8d0ea6 [NTOS:MM] Ignore sections either PointerToRawData or SizeOfRawData is zero
VC1 Linker fills BSS.SizeOfRawData with data in IMAGE_OPTIONAL_HEADER.SizeOfUninitializedData but keeps PointerToRawData to zero.

CORE-18797
2023-01-20 17:02:12 +08:00
Jérôme Gardou 2ae9feb59f [NTOS] Properly implement and use FsRtlAcquireFileForModWriteEx 2022-11-02 19:41:04 +01:00
Hermès Bélusca-Maïto 58983061e9
[NTOS:MM] Remove residual hack from commit 864a1bc6a (r55323). 2022-10-27 01:08:07 +02:00
Adam Słaboń 23e5d3fe25
[NTOS:MM] MmPurgeSegment: Fix wrong return value (#4801)
Return TRUE instead of NTSTATUS code which has a value of FALSE and may confuse caller.
Fixes sporadic 0x7B bugcheck when booting from corrupted NTFS volume using WinXP ntfs.sys.
2022-10-26 02:15:16 +02:00
Jérôme Gardou 75125228be [NTOS] Add some sanity checks when synchronizing PDEs 2022-09-17 13:48:56 +02:00
Thomas Faber a7b2703479
[NTOS] Fix broken SAL annotations on MmDereferenceSegmentWithLock. 2021-11-21 12:47:46 -05:00
Jérôme Gardou 589016ddb9 [NTOS:MM] Implement MmFlushImageSection(MmFlushForWrite) 2021-08-07 09:34:58 +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
Jérôme Gardou 59cddd15e2 [NTOS:MM] Implement MmFlushImageSection(MmFlushForDelete)
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
Serge Gautherie eab2bb4b20 [NTOS:MM] MmFlushSegment(): Fix Iosb annotation
Addendum to 90c6a65.
2021-06-22 10:33:45 +02:00
Jérôme Gardou a5ea259b28 [NTOS:MM] Fix remnants of CORE-17587 2021-06-07 17:04:18 +02:00
Jérôme Gardou 3adf450867 [REACTOS] Addendum to 5c7ce4475e - Fix MSVC 2015 build
Put data into PAGEDATA or INITDATA sections
Keep section declaration for prototypes

CORE-17540
2021-05-12 11:04:29 +02:00
Jérôme Gardou c48580135d [NTOS:MM] Fix a bit page fault handler with regard to COW sections 2021-04-08 15:40:37 +02:00
Jérôme Gardou 43378411fb [NTOS:MM] Rewrite arch-specifics of the legacy Mm
Properly handle PDE refcounting
Clean-up of the internal API
Enforce attaching to the process when modifying its memory layout, instead of
making circonvoluted mappings which always end up being broken.
2021-04-08 15:40:37 +02:00
Jérôme Gardou b445005c70 [NTOS:MM] Get rid of MmRosFlushVirtualMemory
It's not used anywhere now, and it will eventually be gone
2021-04-08 15:40:37 +02:00
Jérôme Gardou 9e121fb6c2 [NTOS:MM] Get rid of MmSetCleanAllRmaps and MmIsDirtyPageRmap
Everything is wrong with them. Bad locking. Bad logic.
2021-04-08 15:40:37 +02:00
Jérôme Gardou 36a92e6ea5 [NTOS:MM] Fix a bit the page-out/page-in logic
- Do not lock the section segment when we are serving a fault for a process private page.
 - Do not keep the process address space lock while writing to pagefile.
 - Do not wait for an event that might never be set.
2021-04-08 15:40:37 +02:00
Jérôme Gardou 0187c1e113 [NTOS:MM] Fix PFN tracing 2021-03-30 16:26:43 +02:00
Jérôme Gardou a93e065ebc [NTOS:MM] Do not chunk-read file when we are the modified-page-writer thread 2021-02-26 08:46:53 +01:00
Jérôme Gardou 35c091adaf [NTOS:MM] Do not chunk-read files marked with FO_RANDOM_ACCESS 2021-02-26 08:46:53 +01:00
Jérôme Gardou b7eb0fddf3 Address PR review 2021-02-03 09:41:24 +01:00
Jérôme Gardou c0bf352069 [NTOS:MM] Fix regression of MmCanFileBeTruncated 2021-02-03 09:41:24 +01:00
Jérôme Gardou 2ba1926037 [NTOS:MM][NTOS:CC] Performance improvement again
Read files by 64kb chunks instead of page-sized chunks.
2021-02-03 09:41:23 +01:00
Jérôme Gardou 41475dfcd7 [NTOS:CC] Performance improvements
Do not ditch the pages as soon as the section are unmapped
Improve MmBalancer "algorithm" (or whatever you call that)
Various needed fixes to get this going.
2021-02-03 09:41:23 +01:00
Jérôme Gardou ea354c4bc7 [NTOS:MM] Unconditionally purge cache on image section creation. 2021-02-03 09:41:23 +01:00
Jérôme Gardou c1c51e31e4 [NTOS:MM] Keep a ref on the segment when mapping a page & keep trace of what is the highest offset mapped. 2021-02-03 09:41:23 +01:00
Jérôme Gardou 91a4e62376 [NTOS:MM] Improve MmCanFileBeTruncated 2021-02-03 09:41:23 +01:00
Jérôme Gardou 3e43aa1305 [NTOS:MM] Use 64-bit integer to count references on segments 2021-02-03 09:41:23 +01:00
Jérôme Gardou 90c6a65efe [NTOS:MM] Introduce MmPurgeSegment & MmFlushSegment
Those will back CcFlushCache and CcPurgeCache.
2021-02-03 09:41:23 +01:00
Jérôme Gardou 5949d5095d [NTOS:CC][NTOS:MM] Try respecting ValidDataLength 2021-02-03 09:41:23 +01:00
Jérôme Gardou e46f1a9af3 [NTOS:MM] Disable APC while performing Paged Read 2021-02-03 09:41:23 +01:00
Jérôme Gardou caf89b9582 [NTOS:MM] Fix a race condition when unmapping sections views 2021-02-03 09:41:23 +01:00
Jérôme Gardou cff3c399c6 [NTOS:MM] Fix input validation/correction in MmMapViewInSystemSpace 2021-02-03 09:41:23 +01:00
Jérôme Gardou addf824d87 [NTOS:MM] Keep image maps & file maps coherent at the time of creating the image map 2021-02-03 09:41:23 +01:00
Jérôme Gardou 543112008a Fix physical memory section creation 2021-02-03 09:41:22 +01:00
Jérôme Gardou 674ab3dce3 [NTOS:MM] Remove a check for now 2021-02-03 09:41:22 +01:00
Jérôme Gardou 1f796267bc [NTOS:MM] Do not reference the section when mapping it.
Referencing the segment is enough.
2021-02-03 09:41:22 +01:00
Jérôme Gardou 3c2b1bf59b [NTOS:MM] Save the dirty bit when sharing a segment page 2021-02-03 09:41:22 +01:00
Jérôme Gardou 3141668724 [NTOS:MM] Various fixes.
Fix MmFlushImageSection behaviour
Remove an invalid ASSERT
2021-02-03 09:41:22 +01:00