Commit graph

54 commits

Author SHA1 Message Date
Timo Kreuzer ca8fbad361 [0.4.9][NTOS] Fix a regression in the PE loader CORE-11717
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.
This commit allows again to load WIN32K.sys of Win2K3SP2
which regressed by SVN 67793 == git
3565260212

fix cherry picked from commit 0.4.14-dev-143-g
56da95671c
2020-10-22 15:50:57 +02:00
Timo Kreuzer e49ef251b7 [NTOS:MM] Fix ViewSize parameter passed to MiInsertVadEx() from MiCreatePebOrTeb()
The size is in bytes, not in pages! On x86 we got away with it, since PEB and TEB require only a single page and the 1 passed to MiInsertVadEx() was aligned up to PAGE_SIZE. On x64 this doesn't work, since the size is 2 pages.
2018-04-22 15:06:19 +02:00
Thomas Faber b54e5c689c
[NTOS:MM] Do not map two pages into hyperspace in MiCopyFromUserPage. CORE-14548
Doing this is not only wrong because it acquires the same spinlock twice,
it also completely breaks the TLB flushing logic in MiMapPageInHyperSpace.
If the PTE with Offset 1 is still valid when a wrap-around to 0 happens,
the TLB flush on wrap-around will not clear the entry for this previous page.
After another loop around all hyperspace pages, page 1 is re-used but its
TLB entry has not been flushed, which may result into incorrect translation.
2018-04-15 20:07:21 +02:00
Timo Kreuzer 6b1ca75899
[REACTOS] Fix 64 bit build (#465)
* [HAL] Simplify HalpReboot() and make it portable
* [NTOS:MM] Cast constant to PVOID
* [BINPATCH] Fix 64 bit build
* [VFDDRV] Fix 64 bit build and buffer overruns
* [USBOHCI] Fix structure alignment issues
* [ATL_APITEST] Fix 64 bit build
* [XDK] Update unwind structures in winnt.h
* [NTDLL_APITEST] Fix 64 bit build
* [NTDLL_WINETEST] Fix 64 bit build
* [TFTPD] Fix x64 build
* [USBPORT] Fix a C_ASSERT
* [DSOUND] Fix x64 build
* [HAL] Remove obsolete GetPteAddress() macro
2018-04-03 15:13:17 -06:00
Thomas Faber a17bf6f669
[NTOS:MM] Improve debug prints in MmCreateVirtualMappingUnsafe. CORE-14478 2018-03-18 23:49:48 +01:00
Pierre Schweitzer bdae0cce66
[NTOSKRNL] Don't call OOM dumper in case we were trying to allocate more than 100 pages.
In such case, we'll consider the caller is bogus and we'll fail in silence.
Dedicated to Mark (again!)
2018-02-17 15:09:38 +01:00
Pierre Schweitzer 01fcb02880
[NTOSKRNL] Allow more chars in ExpTagAllowPrint().
Dedicated to Mark
2018-02-17 15:06:29 +01:00
Pierre Schweitzer 6b0cb54fe5
[NTOSKRNL] Define the throttling limits for Cc in Mm: MmThrottleTop, MmThrottleBottom.
Modified !defwrites to reflect that change
2018-02-09 14:21:14 +01:00
Pierre Schweitzer 0e932c7bef
[NTOSKRNL] Drop the CcTryToInitializeFileCache() which is actually doing nothing relevant 2018-02-07 22:23:49 +01:00
Pierre Schweitzer d56a249089
[NTOSKRNL] Define the Mm global variables related to Cc on Mm init.
This means that MmSystemCacheStart, MmSystemCacheEnd, MmSizeOfSystemCacheInPages
have now a valid value.
System cache is not used atm the moment though. MmMapViewInSystemCache() is to
be implemented, and Cc is to be made aware of this.

CORE-14259
2018-02-06 13:41:23 +01:00
Timo Kreuzer dae88fb828 [NTOS:MM] Make x64 address space layout more like Vista+
- Change MM_SYSTEM_SPACE_START to 0xFFFFF88000000000
- Move MI_DEBUG_MAPPING to the end of the system PTE range
- Add MI_SYSTEM_CACHE_START and MI_SYSTEM_CACHE_END, which is in the range that Vista uses as dynamic VA space for cache and other allocations
- Wrap x86 specific code that makes now invalid assumptions about the address space layout in #ifdef _M_IX86
2018-02-05 01:09:32 +01:00
Thomas Faber d3a29816ce
[NTOS:MM] Assert MmLocateMemoryAreaByAddress return value to satisfy Coverity. CID 701289 2018-01-28 10:48:27 +01:00
Pierre Schweitzer 07e6e9c9c1
[NTOSKRNL] When marking a BCB dirty, also mark the underlying VACB dirty.
Experiment and MSDN tend to show that a dirty BCB is queued for lazy write.
This will do the job here!

Also, renamed CcRosMarkDirtyFile() which is more accurate, and added a new
function CcRosMarkDirtyVacb() which just takes a VACB as arg (expected locked)
and marks it dirty (using previous implementation). Make CcRosMarkDirtyFile()
use it.

CORE-14235
2018-01-23 23:25:26 +01:00
Pierre Schweitzer c7ad200f8b
[NTOSKRNL] Reimplement the lazy writer in Cc and remove the "basic" one in Mm.
This removes the "modified page writer" thread in Mm that was regularly blindly
attempting to flush dirty pages to the disk.
Instead, this commit introduces a lazy writer that will monitor dirty pages count
and will flush them to disk when this count is above a threshold. The threshold is
computed on Cc init.
Compared to what was done previously, this lazy writer will only write down files
that are not marked as temporary.
The mechanisms involved in this lazy writer worker are well described in Windows
Internals 4th editions (constants are coming from it ;-)).
Also fixed a bad (and old!) bug in CcRosFlushDirtyPages() where target count could
be overflow and the function would spin forever while holding the VACBs lock. This is
mandatory as now lazy writer will call it with "random" values.
This also allows implementing CcWaitForCurrentLazyWriterActivity() :-).
Also renamed DirtyPageCount to its MS equivalent.

CORE-14235
2018-01-23 19:33:59 +01:00
Thomas Faber 2ae756a4e5 [NTOS:MM] Fix broken ASSERT. CID 701285 2018-01-16 22:29:19 +01:00
Timo Kreuzer 2dade10d54 [NTOS] Fix 64 bit warnings 2018-01-14 13:54:14 +01:00
Timo Kreuzer 1014d50a4b [NTOS:MM] Pass FaultCode to MiDispatchFault 2018-01-06 18:20:24 +01:00
Timo Kreuzer 3f426aabde [NTOS:MM] Mark local functions with static 2018-01-06 18:20:24 +01:00
Timo Kreuzer a00378a1a1 [NTOS:MM] Add support for NX page-faults 2018-01-06 18:20:24 +01:00
Timo Kreuzer 4d043aa05e [NTOS:MM] Make use of FaultCode and MI_IS_NOT_PRESENT_FAULT and MI_IS_WRITE_ACCESS macros in MmArmAccessFault. 2018-01-06 18:20:24 +01:00
Timo Kreuzer d5c71429d7 [NTOS:MM] Pass The FaultCode to MmArmAcceessFault as well and translate it there to what was declared as "StoreInstruction"
No functional changes.
2018-01-06 18:20:24 +01:00
Timo Kreuzer 3021c2d571 [NTOS:MM] Pass page fault code to MmAccessFault
Note: before we had a BOOLEAN parameter called StoreInstruction, but in reality it was not specifying whether the fault was from a store store instruction, but whether it was an access violation rather than a page-not-present fault. On x86 without PAE there are only 2 kinds of access violations: (1) Access of a kernel mode page from user mode, which is handled early and (2) access of a read-only (or COW) page with a writing instruction. Therefore we could get away with this, even though it relied on the wrong assumption that a fault, which was not a page-not-present-fault, was automatically a write access. This commit only changes one thing: we pass the full fault-code to MmAccessFault and handle the rest from there in exactly the same way as before. More changes are coming to make things clear.
2018-01-06 18:20:24 +01:00
Timo Kreuzer d17812f933 [NTOS:MM] Use MiResolveDemandZeroFault instead of MiDispatchFault 2018-01-03 23:07:19 +01:00
Timo Kreuzer d4765fe366 [NTOS:MM] Implement resolving PXE/PPE page table demand zero faults 2018-01-03 23:07:19 +01:00
Timo Kreuzer 2eff510074 [NTOS:MM] Increment Prcb->MmDemandZeroCount while holding the Pfn lock 2018-01-03 23:07:19 +01:00
Timo Kreuzer 1240ed9e18 [NTOS/MM] Add Protection parameter to MiResolveDemandZeroFault 2018-01-03 23:07:19 +01:00
Timo Kreuzer a2f7de7ee8
Amd64/misc 64bit fixes (#236)
[REACTOS] Misc 64 bit fixes

* [NTOS:MM] Allow MEM_DOS_LIM in NtMapViewOfSection on x64 as well
* [NTOS:MM] Implement x64 version of MmIsDisabledPage
* [HAL] Remove obsolete code
* [NTOS:KE] Fix amd64 version of KeContextToTrapFrame and KeTrapFrameToContext
* [XDK] Fix CONTEXT_XSTATE definition
* [PCNET] Convert physical address types from pointers to PHYSICAL_ADDRESS
2018-01-01 12:07:50 +01:00
Pierre Schweitzer 7fecde4a20
[NTOSKRNL] Print tags which contains numerics in the memory dumper.
This fixes i8042prt.sys allocations not properly being rendered.
2017-12-29 20:37:43 +01:00
Pierre Schweitzer 4663d02cd7
[NTOSKRNL] In the memory dumper, print in the direct order to make !poolused TAG usage easier 2017-12-29 20:37:43 +01:00
Pierre Schweitzer ca3143b9ab
[NTOSKRNL] Add support for verbose output in the !poolused command 2017-12-29 20:37:43 +01:00
Pierre Schweitzer 2daf2391a6
[NTOSKNRL] Addendum to 9a633f7 2017-12-29 18:22:37 +01:00
Pierre Schweitzer 9a633f7b48
[NTOSKRNL] Fix MSVC build 2017-12-29 18:03:33 +01:00
Pierre Schweitzer 4e34bf2a0b
[NTOSKRNL] Add support for the ? wildcard in the !poolused command 2017-12-29 17:23:36 +01:00
Pierre Schweitzer 454e8738f2
[NTOSKRNL] Allow filtering !poolused output using a tag 2017-12-29 17:23:36 +01:00
Pierre Schweitzer 879d8f2104
[NTOSKRNL] Now that the memory dumper handles paged pool, make use of it in any situation 2017-12-29 17:23:36 +01:00
Pierre Schweitzer 1433ade827
[NTOSKRNL] Add support for the paged pool in the memory dumper 2017-12-29 17:23:36 +01:00
Pierre Schweitzer bb63841b57
[NTOSKRNL] Prettify the memory dumper output and add number of allocs 2017-12-29 17:23:36 +01:00
Pierre Schweitzer 78b55550bb
[NTOSKRNL] Make the memory dumper available as a kdbg command: !poolused 2017-12-29 17:23:36 +01:00
Amine Khaldi 4d4e4bb68a [NTOS] Deduplicate MiSynchronizeSystemPde(). #179 2017-12-25 20:14:46 +01:00
Timo Kreuzer 12e2c48a25 [NTOS:MM] Fix a bug in MiBuildPfnDatabase
MxPfnAllocation is in pages, not in bytes!
2017-12-20 06:56:09 +01:00
Timo Kreuzer 18cd763160 [NTOS:MM] Make debug code in MmArmInitSystem portable 2017-12-20 06:56:09 +01:00
Ivan Labutin 4d35d59fb9 [NTOS:MM] Quick fix: use SIZE_T instead of ULONG, because ULONG is 32-bit and on 64-bit truncates values 2017-12-20 06:56:09 +01:00
Ivan Labutin 5857733996 [NTOS:KE] Remove duplicate NX enabling 2017-12-20 06:56:09 +01:00
Ivan Labutin 39dd47cebb [NTOS:MM] Comment out debug code for x86 that should not run on x64 2017-12-20 06:56:09 +01:00
Serge Gautherie 614ace03fa
[NTOS:MM] Fix NtFreeVirtualMemory() FreeType parameter checks. CORE-13126 2017-12-15 11:56:35 +01:00
Amine Khaldi 24f35397c6 [NTOS] Add some header guards. 2017-12-12 12:42:13 +01:00
Thomas Faber 81532227b6
[NTOS:MM] Implement and use MiAcquirePfnLockAtDpcLevel/MiReleasePfnLockFromDpcLevel. 2017-12-08 10:32:22 +01:00
Thomas Faber da5949280c
[NTOS:MM] Use inline functions to acquire/release the PFN lock. 2017-12-08 10:32:08 +01:00
Pierre Schweitzer c473b1a4d6
[NTOSKRNL] Only activate dumper in DBG builds 2017-12-05 23:28:04 +01:00
Pierre Schweitzer 149e1a2610
[NTOSKRNL] Add a non paged memory dumper in case of low memory situation.
Its purpose is to dump the non paged consumption, tag by tag,
to allow tracking potential faulting driver in case ReactOS starts lacking memory.
This will look like what !poolused outputs, even though it doesn't deal with paged pool.

Thanks to Thomas for his kind review and improvement suggestions.

CORE-14048
2017-12-05 23:19:11 +01:00