Commit graph

175 commits

Author SHA1 Message Date
Timo Kreuzer e67b62251f [NTOS:MM] Handle PXE/PPE gaps in MiDeleteVirtualAddresses 2020-11-07 20:16:41 +01:00
Victor Perevertkin 5c7ce4475e
[REACTOS] Cleanup INIT and some PAGE section allocations
- Change INIT_FUNCTION and INIT_SECTION to CODE_SEG("INIT") and DATA_SEG("INIT") respectively
- Remove INIT_FUNCTION from function prototypes
- Remove alloc_text pragma calls as they are not needed anymore
2020-11-02 21:45:31 +03:00
Timo Kreuzer d4b4cf7448 [NTOS:MM] Make sure PXEs/PPEs and PDEs are always MM_EXECUTE_READWRITE
This is required since the NX protection proagates from the highest level, enforcing NX on the entire range, independent of whether lower level P*Es have the bit set or not. It might be useful to add a platform specific constant to allow making page tables NX on architectures that have a different behavior.
2020-11-01 09:32:27 +01:00
Timo Kreuzer d55811f160 [NTOS:MM:X64] Fix session space initialization on x64 2020-11-01 09:32:27 +01:00
Timo Kreuzer 9095dbf5a5 [NTOS:MM:X64] Implement MmCreatePageFileMapping and MmDeletePageFileMapping 2020-11-01 09:32:27 +01:00
Timo Kreuzer 8980850d56 [NTOS:MM:X64] Simplify and fix x64 mapping code
- Use demand-zero-ptes in MiGetPteForProcess
- Handle NoExecute in MiSetPteProtection
- Fix MmIsPageSwapEntry
- Fix MmGetPageFileMapping
- remove obsolete functions.
2020-11-01 09:32:27 +01:00
Timo Kreuzer 0726cfce10 [NTOS:MM:X64] Handle PPEs and PXEs as well in MmInitializeProcessAddressSpace()
But don't set up the PFNs for the initial process on x64, as these have already been set up.
2020-11-01 09:32:27 +01:00
Timo Kreuzer 48d1bd2c88 [NTOS:MM:X64] On x64 allocate a VAD for the shared user page 2020-11-01 09:32:27 +01:00
Timo Kreuzer a5d47ff72b [NTOS:MM:X64] On x64 reserve the address range between FFFF800000000000 and FFFFF68000000000 in MiInitSystemMemoryAreas() 2020-11-01 09:32:27 +01:00
Timo Kreuzer a8ba58fbb0 [NTOS:MM:X64] Improve x64 Mm initialization
* Move MiBuildPfnDatabaseFromPageTables into MiBuildPfnDatabase
* Make sure to call MmInitializeProcessAddressSpace() from the x64 version of MiInitMachineDependent()
* Handle result of MmInitializeProcessAddressSpace in MiInitMachineDependent (Should do the same for x86)
* Remove obsolete x64 debug print
2020-11-01 09:32:27 +01:00
Jérôme Gardou 15dd31377a Revert "[NTOS/MM] Initialize process Working set and start implementing adding entries to it"
This reverts commit 5abc016401.
Not ready for prime time
2020-10-20 15:56:53 +02:00
Jérôme Gardou 1c528cbf84 Revert "[NTOS/MM]
- Fix PFNs tracing
     - Add private pages to the process working set"

This reverts commit 4c5351bf55.
Not ready for prime time
2020-10-20 15:56:21 +02:00
Jérôme Gardou 4c5351bf55 [NTOS/MM]
- Fix PFNs tracing
 - Add private pages to the process working set
2020-10-20 15:20:59 +02:00
Jérôme Gardou 5abc016401 [NTOS/MM] Initialize process Working set and start implementing adding entries to it 2020-10-20 15:20:59 +02:00
Thomas Faber 6b3f309a08
[NTOS] Consistently use MUTANT_INCREMENT.
Spotted by Hermès.
2020-10-16 16:09:54 +02:00
Thomas Faber ba9bf73d48
[NTOS:MM] Acquire PsLoadedModuleResource when walking PsLoadedModuleList. CORE-16449 2020-10-15 14:49:20 +02:00
Thomas Faber a30edc324e
[NTOS:MM] Acquire MmSystemLoadLock in MiFindInitializationCode. CORE-16449
We might otherwise free the INIT section for an image that's in the
process of being loaded by Mm.
2020-10-15 14:49:11 +02:00
Thomas Faber ef1c726621
[NTOS:MM] Print debugging information in case CORE-16449 happens. 2020-10-08 08:59:46 +02:00
Thomas Faber e57a59a60a
[NTOS:MM] Fail on SizeOfRawData overflow. CORE-17284
Fixes the corresponding tests in ntdll_apitest:NtMapViewOfSection.
Also add a TODO for the remaining test failures.
2020-10-03 13:20:25 +02:00
Thomas Faber b957af4b6b
[NTOS:MM] VirtualSize overrides SizeOfRawData when mapping PE files. CORE-17284
This fixes the related failures in ntdll_apitest:NtMapViewOfSection
as well as loading of OrgPlayer's DragDrop.ocx.
2020-10-03 13:13:35 +02:00
Timo Kreuzer 3d17a7590d [NTOS:MM] Fix paged pool initialization on x64 2020-10-01 11:24:42 +02:00
Victor Perevertkin d01518da7c
[XDK] Add definitions required for newer storage class drivers (cdrom)
That introduced some warnings in the current code which were corrected as well

CORE-17129
2020-09-24 22:30:52 +03:00
Timo Kreuzer 896d090ee6 [NTOS:MM] Call MiSessionAddProcess() from MmCreateProcess() like on x86 2020-09-20 23:08:17 +02:00
Timo Kreuzer bebcda0b0b [NTOS:MM] In the x64 version of MmCreateProcessAddressSpace() zero out all page table PFNs 2020-09-20 23:08:17 +02:00
Serge Gautherie a72b78558d [NTOS:MM] MiGetPageTableForProcess(): #if out unreachable code
No impact.

Detected by Cppcheck: unreachableCode.
Addendum to ddaf47dec3 (r34976).
2020-06-25 21:59:02 +02:00
Serge Gautherie ceccaae311
[NTOS:MM] MmDeleteProcessAddressSpace(): Move 'Address' to where it belongs (#2865)
No impact.

Detected by Cppcheck: unusedVariable.
Addendum to 2dade10d54.
2020-06-01 12:10:11 +03:00
Serge Gautherie b20f815126
[NTOSKRNL] Place INIT_FUNCTION before the return type (#2823)
(but after 'static' or SAL 2 annotation.)
Follow-up to 71fefa32, which mentions that it's actually required by the compiler in some circumstances.
2020-05-23 15:56:10 +02:00
Hervé Poussineau 033102fdb1 [NTOS] Add a #define __ROS_ROSSYM__ when using rossym
Use it where needed.
2020-04-09 23:00:57 +02:00
Vadim Galyant 3c585d0e38
[NTOS:MM] Since the _MMPTE_SUBSECTION structure for x86 (without PAE) uses the SubsectionAddressLow truncated by the least significant three bits, the _CONTROL_AREA, _LARGE_CONTROL_AREA, _SUBSECTION, _MSUBSECTION structures must be 8-byte aligned.
Corresponding checks in MmArmInitSystem() have been removed.
2020-04-06 11:16:34 +02:00
Thomas Faber 5032a40d33
[NTOS:MM] In MmArmInitSystem, perform self-tests after per-arch initialization.
Mm(Non)PagedPoolStart won't be initialized otherwise, making the tests
pretty pointless.
2020-04-06 11:16:34 +02:00
Thomas Faber 74a2c6ba42
[NTOS:MM] Initialize MmSubsectionBase on x86 builds. CORE-16731
Spotted by Vadim Galyant.
2020-04-06 11:16:34 +02:00
Thomas Faber 25a5aee86f
[NTOS:MM] Get rid of unnecessary MmZeroingPageThreadActive. 2020-04-06 11:13:55 +02:00
Thomas Faber 5280deecfa
[NTOS:MM] Fix MmZeroingPageThreadActive race condition.
If a thread calls MiInsertPageInFreeList after the zero page thread has
woken up from its wait but before it acquired the PFN lock,
MmZeroingPageEvent might get set again even though there is no additional
work to be done.
By setting MmZeroingPageThreadActive together with the event, the variable
correctly indicates for future callers that the zero thread will process
newly added free pages.

This partially reverts r72990.
2020-04-06 11:13:55 +02:00
Vadim Galyant ac843d7b82
[NTOS:MM] Make the definitions and macros for x86 more human-readable. (#2487)
- Move also PDE_MAPPED_VA definition from common miarm.h to ..arch/mm.h.
- Add assert "PAE not yet implemented".
2020-04-04 14:26:15 +02:00
Vadim Galyant b78cb36d91
[NTOS:MM] Using the macro MiIsPteOnPdeBoundary(). (#2496)
The SYSTEM_PD_SIZE constant should not be used to determine the page boundary for page tables. It is better to use the portable MiIsPteOnPdeBoundary() macro for this.
2020-04-02 12:15:33 +02:00
Thomas Faber 6831468ccf
[NTOS:MM] Assert PFN lock ownership in MiInsertPageInFreeList.
AMD64 initialization previously only raised the IRQL.
It now acquires the lock where needed, as i386 does.
2020-03-02 20:50:54 +01:00
Thomas Faber 754e175d12
[NTOS:MM] Use MI_ZERO_PTES as the number of usable zeroing PTEs, not the total allocated. CORE-11856
We'll now have 32 usable zeroing PTEs instead of 31.
MP kernels will (some day) zero up to 32 pages at a time.
2020-02-22 12:33:54 +01:00
Thomas Faber feb7275bc8
[NTOS:MM] Use POOL_BILLED_PROCESS_INVALID constant. 2020-02-08 13:00:32 +01:00
Serge Gautherie 2c6747aff0
[NTOS:MM] Stop using PD_COUNT, PDE_COUNT and PTE_COUNT (#2294)
Directly use PPE_PER_PAGE, PDE_PER_PAGE, PTE_PER_PAGE constants from hardware-specific MM headers instead
2020-02-05 23:48:26 +01:00
Timo Kreuzer 7523a7b138 [NTOS:KE] Rename some locking functions to reflect the IRQL level changes
* KiAcquireApcLock -> KiAcquireApcLockRaiseToSynch
* KiAcquireApcLockAtDpcLevel -> KiAcquireApcLockAtSynchLevel
* KiReleaseApcLockFromDpcLevel -> KiReleaseApcLockFromSynchLevel
* KiAcquireApcLockAtApcLevel -> KiAcquireApcLockRaiseToDpc
* KiAcquireProcessLock -> KiAcquireProcessLockRaiseToSynch
* KiReleaseProcessLockFromDpcLevel -> KiReleaseProcessLockFromSynchLevel
* KiAcquireDispatcherLockAtDpcLevel -> KiAcquireDispatcherLockAtSynchLevel
* KiReleaseDispatcherLockFromDpcLevel -> KiReleaseDispatcherLockFromSynchLevel
* Add some ASSERTs
2019-12-31 15:30:27 +01:00
Timo Kreuzer 21647e2c4e [NTOS] Revert pool debugging code
Revert "[NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD"
This reverts commit 24f240be8a.

Revert "[NTOS] Add compile time option to trace callers of pool allocations"
This reverts commit 8b20755040.

Revert "WIP"
This reverts commit 8cfd5c601f.
2019-11-25 19:32:06 +01:00
Timo Kreuzer 8cfd5c601f WIP 2019-11-24 18:26:19 +01:00
Timo Kreuzer 8b20755040 [NTOS] Add compile time option to trace callers of pool allocations 2019-11-24 18:26:19 +01:00
Timo Kreuzer 24f240be8a [NTOS] On DBG builds, fill pool allocations with 0xCD and freed pool with 0xDD
This matches what the MSVC runtime does with heap allocations on debug builds.
2019-11-24 18:26:19 +01:00
Hermès Bélusca-Maïto ea6d427d10
[I8042PRT] Remove dead commented-out code; Allow sending ROS-specific commands to the kernel debugger since KD64 also support them.
[NTOS:MM] Remove an extra ')' in a DbgPrint() string.
2019-11-17 23:21:55 +01:00
Hermès Bélusca-Maïto 7e941247bd
[MM:AMD64] Remove the _WINKD_ around MmDebugPte since it's now used by both kd64 (windbg) and KDBG through the usage of mmdbg.c 2019-11-03 23:46:54 +01:00
Hermès Bélusca-Maïto f5e86c0fd3
[NTOS] Just go ahead and allow printing all the printable ASCII characters in ExpTagAllowPrint().
As documented in https://docs.microsoft.com/fr-fr/windows-hardware/drivers/ddi/wdm/nf-wdm-exallocatepoolwithtag
pool tag "characters" must be a value in the range 0x20 (space) to 0x7E (tilde),
which happen indeed to be the range of printable (non-extended) ASCII characters.

(The display problem was originally caught while attempting to display
the pool tag 0x3a306847 corresponding to 'Gh0:', a win32ss GDIOBJ pool tag
encoded with macro GDIOBJ_POOL_TAG().)
2019-11-01 19:09:29 +01:00
Stanislav Motylkov 9bf672d4f1 [NTOS:MM] Add debug print to MiAllocateContiguousMemory in out-of-memory case 2019-10-27 06:32:50 +01:00
Timo Kreuzer 56da95671c [NTOS] Fix a bug in the PE loader, which caused images to be loaded up to MmHighestUserAddress, thus overwriting the shared user page.
This is now fixed by using MM_HIGHEST_VAD_ADDRESS as the margin instead.
Should fix CORE-11717
2019-10-26 21:38:13 +02:00
Pierre Schweitzer 3b78ca210e
[NTOSKRNL] Simplify buffer definition in MiQueryMemorySectionName().
Also take into account the UNICODE_STRING structure while computing whole size
This is based on Thomas' patch.

CORE-12043
2019-09-29 14:16:44 +02:00