18cf108c5SZhang Yi /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 28cf108c5SZhang Yi #ifndef __ASM_GENERIC_MMAN_COMMON_H 38cf108c5SZhang Yi #define __ASM_GENERIC_MMAN_COMMON_H 48cf108c5SZhang Yi 58cf108c5SZhang Yi /* 68cf108c5SZhang Yi Author: Michael S. Tsirkin <mst@mellanox.co.il>, Mellanox Technologies Ltd. 78cf108c5SZhang Yi Based on: asm-xxx/mman.h 88cf108c5SZhang Yi */ 98cf108c5SZhang Yi 108cf108c5SZhang Yi #define PROT_READ 0x1 /* page can be read */ 118cf108c5SZhang Yi #define PROT_WRITE 0x2 /* page can be written */ 128cf108c5SZhang Yi #define PROT_EXEC 0x4 /* page can be executed */ 138cf108c5SZhang Yi #define PROT_SEM 0x8 /* page may be used for atomic ops */ 14ddda3748SCornelia Huck /* 0x10 reserved for arch-specific use */ 15ddda3748SCornelia Huck /* 0x20 reserved for arch-specific use */ 168cf108c5SZhang Yi #define PROT_NONE 0x0 /* page can not be accessed */ 178cf108c5SZhang Yi #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ 188cf108c5SZhang Yi #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ 198cf108c5SZhang Yi 20d9cb4336SCornelia Huck /* 0x01 - 0x03 are defined in linux/mman.h */ 218cf108c5SZhang Yi #define MAP_TYPE 0x0f /* Mask for type of mapping */ 228cf108c5SZhang Yi #define MAP_FIXED 0x10 /* Interpret addr exactly */ 238cf108c5SZhang Yi #define MAP_ANONYMOUS 0x20 /* don't use a file */ 248cf108c5SZhang Yi 25f363d039SEric Auger /* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */ 26f363d039SEric Auger #define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */ 27f363d039SEric Auger #define MAP_NONBLOCK 0x010000 /* do not block on IO */ 28f363d039SEric Auger #define MAP_STACK 0x020000 /* give out an address that is best suited for process/thread stacks */ 29f363d039SEric Auger #define MAP_HUGETLB 0x040000 /* create a huge page mapping */ 30f363d039SEric Auger #define MAP_SYNC 0x080000 /* perform synchronous page faults for the mapping */ 318cf108c5SZhang Yi #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ 328cf108c5SZhang Yi 33f363d039SEric Auger #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be 34f363d039SEric Auger * uninitialized */ 35f363d039SEric Auger 368cf108c5SZhang Yi /* 378cf108c5SZhang Yi * Flags for mlock 388cf108c5SZhang Yi */ 398cf108c5SZhang Yi #define MLOCK_ONFAULT 0x01 /* Lock pages in range after they are faulted in, do not prefault */ 408cf108c5SZhang Yi 418cf108c5SZhang Yi #define MS_ASYNC 1 /* sync memory asynchronously */ 428cf108c5SZhang Yi #define MS_INVALIDATE 2 /* invalidate the caches */ 438cf108c5SZhang Yi #define MS_SYNC 4 /* synchronous memory sync */ 448cf108c5SZhang Yi 458cf108c5SZhang Yi #define MADV_NORMAL 0 /* no further special treatment */ 468cf108c5SZhang Yi #define MADV_RANDOM 1 /* expect random page references */ 478cf108c5SZhang Yi #define MADV_SEQUENTIAL 2 /* expect sequential page references */ 488cf108c5SZhang Yi #define MADV_WILLNEED 3 /* will need these pages */ 498cf108c5SZhang Yi #define MADV_DONTNEED 4 /* don't need these pages */ 508cf108c5SZhang Yi 518cf108c5SZhang Yi /* common parameters: try to keep these consistent across architectures */ 528cf108c5SZhang Yi #define MADV_FREE 8 /* free pages only if memory pressure */ 538cf108c5SZhang Yi #define MADV_REMOVE 9 /* remove these pages & resources */ 548cf108c5SZhang Yi #define MADV_DONTFORK 10 /* don't inherit across fork */ 558cf108c5SZhang Yi #define MADV_DOFORK 11 /* do inherit across fork */ 568cf108c5SZhang Yi #define MADV_HWPOISON 100 /* poison a page for testing */ 578cf108c5SZhang Yi #define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ 588cf108c5SZhang Yi 598cf108c5SZhang Yi #define MADV_MERGEABLE 12 /* KSM may merge identical pages */ 608cf108c5SZhang Yi #define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ 618cf108c5SZhang Yi 628cf108c5SZhang Yi #define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 638cf108c5SZhang Yi #define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 648cf108c5SZhang Yi 658cf108c5SZhang Yi #define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, 668cf108c5SZhang Yi overrides the coredump filter bits */ 678cf108c5SZhang Yi #define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */ 688cf108c5SZhang Yi 698cf108c5SZhang Yi #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ 708cf108c5SZhang Yi #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ 718cf108c5SZhang Yi 72f363d039SEric Auger #define MADV_COLD 20 /* deactivate these pages */ 73f363d039SEric Auger #define MADV_PAGEOUT 21 /* reclaim these pages */ 74f363d039SEric Auger 75327d4b7fSBharata B Rao #define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */ 76327d4b7fSBharata B Rao #define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */ 77327d4b7fSBharata B Rao 78e4082063SAlex Williamson #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ 79e4082063SAlex Williamson 80*93e0932bSPeter Xu #define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ 81*93e0932bSPeter Xu 828cf108c5SZhang Yi /* compatibility flags */ 838cf108c5SZhang Yi #define MAP_FILE 0 848cf108c5SZhang Yi 858cf108c5SZhang Yi #define PKEY_DISABLE_ACCESS 0x1 868cf108c5SZhang Yi #define PKEY_DISABLE_WRITE 0x2 878cf108c5SZhang Yi #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ 888cf108c5SZhang Yi PKEY_DISABLE_WRITE) 898cf108c5SZhang Yi 908cf108c5SZhang Yi #endif /* __ASM_GENERIC_MMAN_COMMON_H */ 91