diff options
author | David Carlier <[email protected]> | 2019-07-27 12:38:31 +0100 |
---|---|---|
committer | David Carlier <[email protected]> | 2019-07-27 13:30:52 +0100 |
commit | efccea267d3989069d06d022d4679717356af026 (patch) | |
tree | f17d18b14003dcff0572c85383ddfa03c8c6ea21 /src/lib/utils | |
parent | c44e822fdef57bdd01193c8ceb5ec52f4b1c1a07 (diff) |
Darwin, monitoring anonymous locked pages via vm_stat tool.
Userland applications are allowed taking ID from 240->255.
The ID can be made dynamic later on if wished.
Diffstat (limited to 'src/lib/utils')
-rw-r--r-- | src/lib/utils/os_utils.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp index 50ebbb072..daa5bb73f 100644 --- a/src/lib/utils/os_utils.cpp +++ b/src/lib/utils/os_utils.cpp @@ -430,11 +430,19 @@ std::vector<void*> OS::allocate_locked_pages(size_t count) #define PROT_MAX(p) 0 #endif const int pflags = PROT_READ | PROT_WRITE; +#if defined(BOTAN_TARGET_OS_IS_IOS) || defined(BOTAN_TARGET_OS_IS_MACOS) +// On Darwin, tagging anonymous pages allows vmmap to track these. +// Allowed from 240 to 255 for userland applications, taken an hardcoded +// value for now even though it can possibly intersect. + const int locked_fd = (255<<24); +#else + const int locked_fd = -1; +#endif ptr = ::mmap(nullptr, 2*page_size, pflags | PROT_MAX(pflags), MAP_ANONYMOUS | MAP_PRIVATE | MAP_NOCORE, - /*fd=*/-1, /*offset=*/0); + /*fd=*/locked_fd, /*offset=*/0); if(ptr == MAP_FAILED) { |