16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28a1ab315SDavid Howells #ifndef __ASM_GENERIC_MMAN_COMMON_H
38a1ab315SDavid Howells #define __ASM_GENERIC_MMAN_COMMON_H
48a1ab315SDavid Howells 
58a1ab315SDavid Howells /*
68a1ab315SDavid Howells  Author: Michael S. Tsirkin <mst@mellanox.co.il>, Mellanox Technologies Ltd.
78a1ab315SDavid Howells  Based on: asm-xxx/mman.h
88a1ab315SDavid Howells */
98a1ab315SDavid Howells 
108a1ab315SDavid Howells #define PROT_READ	0x1		/* page can be read */
118a1ab315SDavid Howells #define PROT_WRITE	0x2		/* page can be written */
128a1ab315SDavid Howells #define PROT_EXEC	0x4		/* page can be executed */
138a1ab315SDavid Howells #define PROT_SEM	0x8		/* page may be used for atomic ops */
14d41938d2SDave Martin /*			0x10		   reserved for arch-specific use */
15d41938d2SDave Martin /*			0x20		   reserved for arch-specific use */
168a1ab315SDavid Howells #define PROT_NONE	0x0		/* page can not be accessed */
178a1ab315SDavid Howells #define PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
188a1ab315SDavid Howells #define PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
198a1ab315SDavid Howells 
20746c9398SMichael S. Tsirkin /* 0x01 - 0x03 are defined in linux/mman.h */
218a1ab315SDavid Howells #define MAP_TYPE	0x0f		/* Mask for type of mapping */
228a1ab315SDavid Howells #define MAP_FIXED	0x10		/* Interpret addr exactly */
238a1ab315SDavid Howells #define MAP_ANONYMOUS	0x20		/* don't use a file */
244ed28639SMichal Hocko 
258aa3c927SAneesh Kumar K.V /* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */
268aa3c927SAneesh Kumar K.V #define MAP_POPULATE		0x008000	/* populate (prefault) pagetables */
278aa3c927SAneesh Kumar K.V #define MAP_NONBLOCK		0x010000	/* do not block on IO */
288aa3c927SAneesh Kumar K.V #define MAP_STACK		0x020000	/* give out an address that is best suited for process/thread stacks */
298aa3c927SAneesh Kumar K.V #define MAP_HUGETLB		0x040000	/* create a huge page mapping */
3022fcea6fSAneesh Kumar K.V #define MAP_SYNC		0x080000 /* perform synchronous page faults for the mapping */
314ed28639SMichal Hocko #define MAP_FIXED_NOREPLACE	0x100000	/* MAP_FIXED which doesn't unmap underlying mapping */
328a1ab315SDavid Howells 
330bf5f949SChristoph Hellwig #define MAP_UNINITIALIZED 0x4000000	/* For anonymous mmap, memory could be
340bf5f949SChristoph Hellwig 					 * uninitialized */
350bf5f949SChristoph Hellwig 
36b0f205c2SEric B Munson /*
37b0f205c2SEric B Munson  * Flags for mlock
38b0f205c2SEric B Munson  */
39b0f205c2SEric B Munson #define MLOCK_ONFAULT	0x01		/* Lock pages in range after they are faulted in, do not prefault */
40b0f205c2SEric B Munson 
418a1ab315SDavid Howells #define MS_ASYNC	1		/* sync memory asynchronously */
428a1ab315SDavid Howells #define MS_INVALIDATE	2		/* invalidate the caches */
438a1ab315SDavid Howells #define MS_SYNC		4		/* synchronous memory sync */
448a1ab315SDavid Howells 
458a1ab315SDavid Howells #define MADV_NORMAL	0		/* no further special treatment */
468a1ab315SDavid Howells #define MADV_RANDOM	1		/* expect random page references */
478a1ab315SDavid Howells #define MADV_SEQUENTIAL	2		/* expect sequential page references */
488a1ab315SDavid Howells #define MADV_WILLNEED	3		/* will need these pages */
498a1ab315SDavid Howells #define MADV_DONTNEED	4		/* don't need these pages */
508a1ab315SDavid Howells 
518a1ab315SDavid Howells /* common parameters: try to keep these consistent across architectures */
5221f55b01SChen Gang #define MADV_FREE	8		/* free pages only if memory pressure */
538a1ab315SDavid Howells #define MADV_REMOVE	9		/* remove these pages & resources */
548a1ab315SDavid Howells #define MADV_DONTFORK	10		/* don't inherit across fork */
558a1ab315SDavid Howells #define MADV_DOFORK	11		/* do inherit across fork */
568a1ab315SDavid Howells #define MADV_HWPOISON	100		/* poison a page for testing */
578a1ab315SDavid Howells #define MADV_SOFT_OFFLINE 101		/* soft offline page for testing */
588a1ab315SDavid Howells 
598a1ab315SDavid Howells #define MADV_MERGEABLE   12		/* KSM may merge identical pages */
608a1ab315SDavid Howells #define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
618a1ab315SDavid Howells 
628a1ab315SDavid Howells #define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
638a1ab315SDavid Howells #define MADV_NOHUGEPAGE	15		/* Not worth backing with hugepages */
648a1ab315SDavid Howells 
658a1ab315SDavid Howells #define MADV_DONTDUMP   16		/* Explicity exclude from the core dump,
668a1ab315SDavid Howells 					   overrides the coredump filter bits */
6785892f19SZhang Yanfei #define MADV_DODUMP	17		/* Clear the MADV_DONTDUMP flag */
688a1ab315SDavid Howells 
69d2cd9edeSRik van Riel #define MADV_WIPEONFORK 18		/* Zero memory on fork, child only */
70d2cd9edeSRik van Riel #define MADV_KEEPONFORK 19		/* Undo MADV_WIPEONFORK */
71d2cd9edeSRik van Riel 
729c276cc6SMinchan Kim #define MADV_COLD	20		/* deactivate these pages */
731a4e58ccSMinchan Kim #define MADV_PAGEOUT	21		/* reclaim these pages */
749c276cc6SMinchan Kim 
754ca9b385SDavid Hildenbrand #define MADV_POPULATE_READ	22	/* populate (prefault) page tables readable */
764ca9b385SDavid Hildenbrand #define MADV_POPULATE_WRITE	23	/* populate (prefault) page tables writable */
774ca9b385SDavid Hildenbrand 
789457056aSJohannes Weiner #define MADV_DONTNEED_LOCKED	24	/* like DONTNEED, but drop locked pages too */
799457056aSJohannes Weiner 
80*7d8faaf1SZach O'Keefe #define MADV_COLLAPSE	25		/* Synchronous hugepage collapse */
81*7d8faaf1SZach O'Keefe 
828a1ab315SDavid Howells /* compatibility flags */
838a1ab315SDavid Howells #define MAP_FILE	0
848a1ab315SDavid Howells 
85e8c24d3aSDave Hansen #define PKEY_DISABLE_ACCESS	0x1
86e8c24d3aSDave Hansen #define PKEY_DISABLE_WRITE	0x2
87e8c24d3aSDave Hansen #define PKEY_ACCESS_MASK	(PKEY_DISABLE_ACCESS |\
88e8c24d3aSDave Hansen 				 PKEY_DISABLE_WRITE)
89e8c24d3aSDave Hansen 
908a1ab315SDavid Howells #endif /* __ASM_GENERIC_MMAN_COMMON_H */
91