cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

remap_file_pages.rst (1671B)


      1.. _remap_file_pages:
      2
      3==============================
      4remap_file_pages() system call
      5==============================
      6
      7The remap_file_pages() system call is used to create a nonlinear mapping,
      8that is, a mapping in which the pages of the file are mapped into a
      9nonsequential order in memory. The advantage of using remap_file_pages()
     10over using repeated calls to mmap(2) is that the former approach does not
     11require the kernel to create additional VMA (Virtual Memory Area) data
     12structures.
     13
     14Supporting of nonlinear mapping requires significant amount of non-trivial
     15code in kernel virtual memory subsystem including hot paths. Also to get
     16nonlinear mapping work kernel need a way to distinguish normal page table
     17entries from entries with file offset (pte_file). Kernel reserves flag in
     18PTE for this purpose. PTE flags are scarce resource especially on some CPU
     19architectures. It would be nice to free up the flag for other usage.
     20
     21Fortunately, there are not many users of remap_file_pages() in the wild.
     22It's only known that one enterprise RDBMS implementation uses the syscall
     23on 32-bit systems to map files bigger than can linearly fit into 32-bit
     24virtual address space. This use-case is not critical anymore since 64-bit
     25systems are widely available.
     26
     27The syscall is deprecated and replaced it with an emulation now. The
     28emulation creates new VMAs instead of nonlinear mappings. It's going to
     29work slower for rare users of remap_file_pages() but ABI is preserved.
     30
     31One side effect of emulation (apart from performance) is that user can hit
     32vm.max_map_count limit more easily due to additional VMAs. See comment for
     33DEFAULT_MAX_MAP_COUNT for more details on the limit.