diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-12-04 03:03:15 +0400 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-12-04 03:03:15 +0400 |
commit | 447354e13ccb83e0baeaaf6158f52b9033fba117 (patch) | |
tree | ebd168a9d9fb5028c2349a15f9992e28d105839e /winsup/cygwin/mmap.cc | |
parent | b9aa81491f62f6053bb648f20143ba9e68051622 (diff) |
* mmap.cc (mlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE. Drop
outdated comment. Call NtLockVirtualMemory with LOCK_VM_IN_WSL flag.
(munlock): Drop requesting SE_LOCK_MEMORY_PRIVILEGE. Call
NtUnlockVirtualMemory with LOCK_VM_IN_WSL flag.
Diffstat (limited to 'winsup/cygwin/mmap.cc')
-rw-r--r-- | winsup/cygwin/mmap.cc | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index afbeb7a3a..97f0dad6f 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -1346,14 +1346,6 @@ mlock (const void *addr, size_t len) { int ret = -1; - /* Instead of using VirtualLock, which does not guarantee that the pages - aren't swapped out when the process is inactive, we're using - ZwLockVirtualMemory with the LOCK_VM_IN_RAM flag to do what mlock on - POSIX systems does. On NT, this requires SeLockMemoryPrivilege, - which is given only to SYSTEM by default. */ - - push_thread_privilege (SE_LOCK_MEMORY_PRIVILEGE, true); - /* Align address and length values to page size. */ size_t pagesize = getpagesize (); PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); @@ -1362,7 +1354,7 @@ mlock (const void *addr, size_t len) do { status = NtLockVirtualMemory (NtCurrentProcess (), &base, &size, - LOCK_VM_IN_RAM); + LOCK_VM_IN_WSL); if (status == STATUS_WORKING_SET_QUOTA) { /* The working set is too small, try to increase it so that the @@ -1402,8 +1394,6 @@ mlock (const void *addr, size_t len) } while (status == STATUS_WORKING_SET_QUOTA); - pop_thread_privilege (); - return ret; } @@ -1412,21 +1402,17 @@ munlock (const void *addr, size_t len) { int ret = -1; - push_thread_privilege (SE_LOCK_MEMORY_PRIVILEGE, true); - /* Align address and length values to page size. */ size_t pagesize = getpagesize (); PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize); ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize); NTSTATUS status = NtUnlockVirtualMemory (NtCurrentProcess (), &base, &size, - LOCK_VM_IN_RAM); + LOCK_VM_IN_WSL); if (!NT_SUCCESS (status)) __seterrno_from_nt_status (status); else ret = 0; - pop_thread_privilege (); - return ret; } |