reactos/base/system/smss
Hermès Bélusca-Maïto a4274ad548
[SMSS][NTOS:MM] Implement the architecture-specific pagefile size limits + code review. (#4843)
What we have:
- Maximum number of pagefiles: 16
- Minimum pagefile size: 256 pages (1 MB when page size = 4096 bytes)
- Maximum pagefile size:
  * 32-bit platforms: (1024 * 1024 - 1) pages (~ 4095 MB)
  * x86 with PAE support: same size as for AMD x64
  * x64 platform:  (4 * 1024 * 1024 * 1024 - 1) pages (~ 16 TB)
  * IA64 platform: (8 * 1024 * 1024 * 1024 - 1) pages (~ 32 TB)

Those are the values as supported and verified by the NT kernel.
Now,  user-mode programs (including SMSS.EXE)  have different opinions
on these, namely, they consider estimates directly in MB, respectively:
4095 MB, (16 * 1024 * 1024) MB, and (32 * 1024 * 1024) MB
(verified on Win2k3 and Win7 32 and 64 bits).
Also here, the minimum pagefile size is set to 2 MB.

Starting Windows 8+ (and 10), those values change slightly, and are
still not fully synchronized between NTOS:MM and SMSS. Finally, while
(x86 PAE and) AMD64 and ARM64 seem to share the maximum pagefile
size limit, 32-bit ARMv7 appears to use different limits than regular
x86 (2 GB instead of 4).

Please keep those values as they are for NT compatibility!

See the following references:
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/mm/modwrite/create.htm
https://techcommunity.microsoft.com/t5/ask-the-performance-team/what-is-the-page-file-for-anyway/ba-p/372608
+ Manual extraction of the values from different NT 6.2,6.3,10 builds.

[SMSS] Fill out in particular the x86-specific case for PAE.

[NTOS:MM] Some cleanup in the NtCreatePagingFile() code, namely:
- Clarify some comments;
- Validate the lower and upper bounds of the Minimum and Maximum sizes
  (based on Windows behaviour as explained by Geoff + manual tests).
- Open the pagefile in case-insensitive;
- Simplify the loop that finds an existing matching pagefile;
- Simplify some failure exit paths;
- Add a "Missing validation steps TODO" comment block explaining the
  existing code-hole.
2022-11-16 21:54:31 +01:00
..
CMakeLists.txt
crashdmp.c
pagefile.c [SMSS][NTOS:MM] Implement the architecture-specific pagefile size limits + code review. (#4843) 2022-11-16 21:54:31 +01:00
sminit.c [SMSS] Improve comments/code/some DPRINTs. Reorganize smss.h header. 2022-11-14 00:10:35 +01:00
smloop.c [SMSS] Improve comments/code/some DPRINTs. Reorganize smss.h header. 2022-11-14 00:10:35 +01:00
smsbapi.c [SMSS] Fix three SmpLoadSubSystem bugs related to the SB_CREATE_SESSION callback. 2022-11-14 00:10:35 +01:00
smsessn.c [SMSS] Improve comments/code/some DPRINTs. Reorganize smss.h header. 2022-11-14 00:10:35 +01:00
smss.c [SMSS] Improve comments/code/some DPRINTs. Reorganize smss.h header. 2022-11-14 00:10:35 +01:00
smss.h [SMSS] Fix three SmpLoadSubSystem bugs related to the SB_CREATE_SESSION callback. 2022-11-14 00:10:35 +01:00
smss.rc
smsubsys.c [SMSS] Fix three SmpLoadSubSystem bugs related to the SB_CREATE_SESSION callback. 2022-11-14 00:10:35 +01:00
smutil.c [SMSS] Improve comments/code/some DPRINTs. Reorganize smss.h header. 2022-11-14 00:10:35 +01:00