github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/abi/linux/mm.go (about)

     1  // Copyright 2018 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package linux
    16  
    17  // Protections for mmap(2).
    18  const (
    19  	PROT_NONE      = 0
    20  	PROT_READ      = 1 << 0
    21  	PROT_WRITE     = 1 << 1
    22  	PROT_EXEC      = 1 << 2
    23  	PROT_SEM       = 1 << 3
    24  	PROT_GROWSDOWN = 1 << 24
    25  	PROT_GROWSUP   = 1 << 25
    26  )
    27  
    28  // Flags for mmap(2).
    29  const (
    30  	MAP_SHARED     = 1 << 0
    31  	MAP_PRIVATE    = 1 << 1
    32  	MAP_FIXED      = 1 << 4
    33  	MAP_ANONYMOUS  = 1 << 5
    34  	MAP_32BIT      = 1 << 6 // arch/x86/include/uapi/asm/mman.h
    35  	MAP_GROWSDOWN  = 1 << 8
    36  	MAP_DENYWRITE  = 1 << 11
    37  	MAP_EXECUTABLE = 1 << 12
    38  	MAP_LOCKED     = 1 << 13
    39  	MAP_NORESERVE  = 1 << 14
    40  	MAP_POPULATE   = 1 << 15
    41  	MAP_NONBLOCK   = 1 << 16
    42  	MAP_STACK      = 1 << 17
    43  	MAP_HUGETLB    = 1 << 18
    44  )
    45  
    46  // Flags for mremap(2).
    47  const (
    48  	MREMAP_MAYMOVE = 1 << 0
    49  	MREMAP_FIXED   = 1 << 1
    50  )
    51  
    52  // Flags for mlock2(2).
    53  const (
    54  	MLOCK_ONFAULT = 0x01
    55  )
    56  
    57  // Flags for mlockall(2).
    58  const (
    59  	MCL_CURRENT = 1
    60  	MCL_FUTURE  = 2
    61  	MCL_ONFAULT = 4
    62  )
    63  
    64  // Advice for madvise(2).
    65  const (
    66  	MADV_NORMAL       = 0
    67  	MADV_RANDOM       = 1
    68  	MADV_SEQUENTIAL   = 2
    69  	MADV_WILLNEED     = 3
    70  	MADV_DONTNEED     = 4
    71  	MADV_REMOVE       = 9
    72  	MADV_DONTFORK     = 10
    73  	MADV_DOFORK       = 11
    74  	MADV_MERGEABLE    = 12
    75  	MADV_UNMERGEABLE  = 13
    76  	MADV_HUGEPAGE     = 14
    77  	MADV_NOHUGEPAGE   = 15
    78  	MADV_DONTDUMP     = 16
    79  	MADV_DODUMP       = 17
    80  	MADV_HWPOISON     = 100
    81  	MADV_SOFT_OFFLINE = 101
    82  	MADV_NOMAJFAULT   = 200
    83  	MADV_DONTCHGME    = 201
    84  )
    85  
    86  // Flags for msync(2).
    87  const (
    88  	MS_ASYNC      = 1 << 0
    89  	MS_INVALIDATE = 1 << 1
    90  	MS_SYNC       = 1 << 2
    91  )
    92  
    93  // NumaPolicy is the NUMA memory policy for a memory range. See numa(7).
    94  //
    95  // +marshal
    96  type NumaPolicy int32
    97  
    98  // Policies for get_mempolicy(2)/set_mempolicy(2).
    99  const (
   100  	MPOL_DEFAULT    NumaPolicy = 0
   101  	MPOL_PREFERRED  NumaPolicy = 1
   102  	MPOL_BIND       NumaPolicy = 2
   103  	MPOL_INTERLEAVE NumaPolicy = 3
   104  	MPOL_LOCAL      NumaPolicy = 4
   105  	MPOL_MAX        NumaPolicy = 5
   106  )
   107  
   108  // Flags for get_mempolicy(2).
   109  const (
   110  	MPOL_F_NODE         = 1 << 0
   111  	MPOL_F_ADDR         = 1 << 1
   112  	MPOL_F_MEMS_ALLOWED = 1 << 2
   113  )
   114  
   115  // Flags for set_mempolicy(2).
   116  const (
   117  	MPOL_F_RELATIVE_NODES = 1 << 14
   118  	MPOL_F_STATIC_NODES   = 1 << 15
   119  
   120  	MPOL_MODE_FLAGS = (MPOL_F_STATIC_NODES | MPOL_F_RELATIVE_NODES)
   121  )
   122  
   123  // Flags for mbind(2).
   124  const (
   125  	MPOL_MF_STRICT   = 1 << 0
   126  	MPOL_MF_MOVE     = 1 << 1
   127  	MPOL_MF_MOVE_ALL = 1 << 2
   128  
   129  	MPOL_MF_VALID = MPOL_MF_STRICT | MPOL_MF_MOVE | MPOL_MF_MOVE_ALL
   130  )