This MR adds support for creating file mapping objects backed by large pages on Linux, by making the following changes:
## wineserver
* On Linux, `create_temp_file` will first attempt to use memfds as the backing fd. If it fails, it'll return to the current codepath, creating a temporary file in either the server or config directory.
* The created memfd will be sealed against writes, if the caller requesting the appropriate page protection flags.
* This removes the requirement that FDs be only created on filesystems/directories that aren't `noexec`.
* In the server method `create_mapping` , if large pages have been requested by the caller, hold that the calling thread's token holds `SeLockMemoryPrivilege` .
* Additionally, add `SeLockMemoryPrivilege` to the list of privileges enabled for the Administrator.
## `ntdll`
* Add `virtual_get_min_large_page_size` and its exported wrapper `wine_unix_get_min_large_page_size`.
* On Linux, the minimum page size is determined by going through `/sys/kernel/mm/hugepages`. If hugepage support was not detected, `STATUS_NOT_SUPPORTED` is returned instead. On other platforms, the older hard-coded value of 2\*1024\*1024 is returned instead.
* `NtCreateSection` will validate certain parameters if large pages are requested. Specifically, it will return STATUS_INVALID_PARAMETER if the requested mapping is not anonymous/unnamed, or the size is not a multiple of the minimum supported page size.
## `kernelbase`
* `GetLargePageMinimum` will use `wine_unix_get_min_large_page_size`.
## `kernel32/tests`
* Add new test test_large_page_file_mapping, which validates privilege enforcements and parameter validation while creating large pages backed file mapping obejcts. The tests are skipped if `GetLargePageMinimum` returns 0.
--
v5: create_user_data_mapping: Set the LargePageMinimum field.
Remove declaration for wine_unix_get_min_large_page_size.
Add checks for linux/memfd.h and memfd_create on Linux.
:NtCreateSection: remove trailing whitespace.
Remove virtual_get_large_page_min_size and its exported wine syscall
https://gitlab.winehq.org/wine/wine/-/merge_requests/5769
On Fri May 31 21:05:42 2024 +0000, Alex Henrie wrote:
> Thanks for the patch! Reading and following the instructions at
> https://wiki.winehq.org/Submitting_Patches will improve the chances of
> it being accepted.
> Please use your real name in the Git commit, for example:
> ```
> git config --global user.name "Your Name"
> git commit --amend --reset-author
> git push --force
> ```
> Also, drop "See Bug 53960" and "This patch fixes that" from the commit
> message, wrap the paragraph of explanation to 72 characters per line,
> and add a new line `Wine-Bug:
> https://bugs.winehq.org/show_bug.cgi?id=53960` at the end of the commit message.
Done :)
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5752#note_71998
On Fri May 31 20:58:25 2024 +0000, Piotr Caban wrote:
> There's lots of changes that look suspicious, please start with adding
> some tests.
Hi, Piotr Caban. I think the original tests should work here. What kind of extra tests do you need me to test?
Does msvcrt/tests/file.c provide tests for both msvcrt and ucrt?
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/5752#note_71995