diff options
| author | Tuowen Zhao <ztuowen@gmail.com> | 2019-12-04 12:56:58 -0700 | 
|---|---|---|
| committer | Tuowen Zhao <ztuowen@gmail.com> | 2019-12-04 12:56:58 -0700 | 
| commit | 79ba7c05e35b18aa2dc24da57399cfbb94a07d0e (patch) | |
| tree | 189d68f87fe771c5c07fb64754a89c80bd82be3d | |
| download | atsmmap-79ba7c05e35b18aa2dc24da57399cfbb94a07d0e.tar.gz atsmmap-79ba7c05e35b18aa2dc24da57399cfbb94a07d0e.tar.bz2 atsmmap-79ba7c05e35b18aa2dc24da57399cfbb94a07d0e.zip | |
initial commit
| -rw-r--r-- | .gitignore | 15 | ||||
| -rw-r--r-- | CMakeLists.txt | 6 | ||||
| -rw-r--r-- | main.cpp | 28 | 
3 files changed, 49 insertions, 0 deletions
| diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01275f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# CLion stuff +/.idea +cmake-build-* + +# Vim stuff +*.swp + +# My CMake build +build + +# Test artifacts +*.o +*.optrpt +*.s +*.ll diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..58e7603 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.15) +project(atsmmap) + +set(CMAKE_CXX_STANDARD 14) + +add_executable(atsmmap main.cpp)
\ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..43aba7f --- /dev/null +++ b/main.cpp @@ -0,0 +1,28 @@ +#include <iostream> +#include <unistd.h> +#include <sys/mman.h> +#include <string> + +#define GIG (1024*1024*1024ul) +#define VOLUME (2ul*GIG) + +// Real values is in the ~65536, only use half of it to be safe +// sysctl vm.max_map_count +#define MAXMMAPS 32768 + +int main(int argc, char **argv) { +  auto page_size = sysconf(_SC_PAGESIZE); +  std::cout << "The system have a page size of " << page_size << std::endl; +  auto dst = (long*)malloc(VOLUME); +  // Src is using anonymous mapping +  long nmaps = std::stoi(argv[1]); +  if (GIG % (page_size * nmaps) != 0) { +    std::cout << "nmaps is not perfect multiple" << std::endl; +    nmaps = GIG / (page_size * nmaps); +  } +  std::cout << argv[1] << std::endl; +  uint8_t *hint = (uint8_t*)0x600000000000UL; +  mmap(hint); +  auto src = +  return 0; +} | 
