18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
48c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
58c2ecf20Sopenharmony_ci * for more details.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (C) 1995, 1999, 2002 by Ralf Baechle
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef _ASM_MMAN_H
108c2ecf20Sopenharmony_ci#define _ASM_MMAN_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*
138c2ecf20Sopenharmony_ci * Protections are chosen from these bits, OR'd together.  The
148c2ecf20Sopenharmony_ci * implementation does not necessarily support PROT_EXEC or PROT_WRITE
158c2ecf20Sopenharmony_ci * without PROT_READ.  The only guarantees are that no writing will be
168c2ecf20Sopenharmony_ci * allowed without PROT_WRITE and no access will be allowed for PROT_NONE.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ci#define PROT_NONE	0x00		/* page can not be accessed */
198c2ecf20Sopenharmony_ci#define PROT_READ	0x01		/* page can be read */
208c2ecf20Sopenharmony_ci#define PROT_WRITE	0x02		/* page can be written */
218c2ecf20Sopenharmony_ci#define PROT_EXEC	0x04		/* page can be executed */
228c2ecf20Sopenharmony_ci/*			0x08		   reserved for PROT_EXEC_NOFLUSH */
238c2ecf20Sopenharmony_ci#define PROT_SEM	0x10		/* page may be used for atomic ops */
248c2ecf20Sopenharmony_ci#define PROT_GROWSDOWN	0x01000000	/* mprotect flag: extend change to start of growsdown vma */
258c2ecf20Sopenharmony_ci#define PROT_GROWSUP	0x02000000	/* mprotect flag: extend change to end of growsup vma */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci/*
288c2ecf20Sopenharmony_ci * Flags for mmap
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci/* 0x01 - 0x03 are defined in linux/mman.h */
318c2ecf20Sopenharmony_ci#define MAP_TYPE	0x00f		/* Mask for type of mapping */
328c2ecf20Sopenharmony_ci#define MAP_FIXED	0x010		/* Interpret addr exactly */
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* not used by linux, but here to make sure we don't clash with ABI defines */
358c2ecf20Sopenharmony_ci#define MAP_RENAME	0x020		/* Assign page to file */
368c2ecf20Sopenharmony_ci#define MAP_AUTOGROW	0x040		/* File may grow by writing */
378c2ecf20Sopenharmony_ci#define MAP_LOCAL	0x080		/* Copy on fork/sproc */
388c2ecf20Sopenharmony_ci#define MAP_AUTORSRV	0x100		/* Logical swap reserved on demand */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* These are linux-specific */
418c2ecf20Sopenharmony_ci#define MAP_NORESERVE	0x0400		/* don't check for reservations */
428c2ecf20Sopenharmony_ci#define MAP_ANONYMOUS	0x0800		/* don't use a file */
438c2ecf20Sopenharmony_ci#define MAP_GROWSDOWN	0x1000		/* stack-like segment */
448c2ecf20Sopenharmony_ci#define MAP_DENYWRITE	0x2000		/* ETXTBSY */
458c2ecf20Sopenharmony_ci#define MAP_EXECUTABLE	0x4000		/* mark it as an executable */
468c2ecf20Sopenharmony_ci#define MAP_LOCKED	0x8000		/* pages are locked */
478c2ecf20Sopenharmony_ci#define MAP_POPULATE	0x10000		/* populate (prefault) pagetables */
488c2ecf20Sopenharmony_ci#define MAP_NONBLOCK	0x20000		/* do not block on IO */
498c2ecf20Sopenharmony_ci#define MAP_STACK	0x40000		/* give out an address that is best suited for process/thread stacks */
508c2ecf20Sopenharmony_ci#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
518c2ecf20Sopenharmony_ci#define MAP_FIXED_NOREPLACE 0x100000	/* MAP_FIXED which doesn't unmap underlying mapping */
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci/*
548c2ecf20Sopenharmony_ci * Flags for msync
558c2ecf20Sopenharmony_ci */
568c2ecf20Sopenharmony_ci#define MS_ASYNC	0x0001		/* sync memory asynchronously */
578c2ecf20Sopenharmony_ci#define MS_INVALIDATE	0x0002		/* invalidate mappings & caches */
588c2ecf20Sopenharmony_ci#define MS_SYNC		0x0004		/* synchronous memory sync */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/*
618c2ecf20Sopenharmony_ci * Flags for mlockall
628c2ecf20Sopenharmony_ci */
638c2ecf20Sopenharmony_ci#define MCL_CURRENT	1		/* lock all current mappings */
648c2ecf20Sopenharmony_ci#define MCL_FUTURE	2		/* lock all future mappings */
658c2ecf20Sopenharmony_ci#define MCL_ONFAULT	4		/* lock all pages that are faulted in */
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci/*
688c2ecf20Sopenharmony_ci * Flags for mlock
698c2ecf20Sopenharmony_ci */
708c2ecf20Sopenharmony_ci#define MLOCK_ONFAULT	0x01		/* Lock pages in range after they are faulted in, do not prefault */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define MADV_NORMAL	0		/* no further special treatment */
738c2ecf20Sopenharmony_ci#define MADV_RANDOM	1		/* expect random page references */
748c2ecf20Sopenharmony_ci#define MADV_SEQUENTIAL 2		/* expect sequential page references */
758c2ecf20Sopenharmony_ci#define MADV_WILLNEED	3		/* will need these pages */
768c2ecf20Sopenharmony_ci#define MADV_DONTNEED	4		/* don't need these pages */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/* common parameters: try to keep these consistent across architectures */
798c2ecf20Sopenharmony_ci#define MADV_FREE	8		/* free pages only if memory pressure */
808c2ecf20Sopenharmony_ci#define MADV_REMOVE	9		/* remove these pages & resources */
818c2ecf20Sopenharmony_ci#define MADV_DONTFORK	10		/* don't inherit across fork */
828c2ecf20Sopenharmony_ci#define MADV_DOFORK	11		/* do inherit across fork */
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci#define MADV_MERGEABLE	 12		/* KSM may merge identical pages */
858c2ecf20Sopenharmony_ci#define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
868c2ecf20Sopenharmony_ci#define MADV_HWPOISON	 100		/* poison a page for testing */
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#define MADV_HUGEPAGE	14		/* Worth backing with hugepages */
898c2ecf20Sopenharmony_ci#define MADV_NOHUGEPAGE 15		/* Not worth backing with hugepages */
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define MADV_DONTDUMP	16		/* Explicity exclude from the core dump,
928c2ecf20Sopenharmony_ci					   overrides the coredump filter bits */
938c2ecf20Sopenharmony_ci#define MADV_DODUMP	17		/* Clear the MADV_NODUMP flag */
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define MADV_WIPEONFORK 18		/* Zero memory on fork, child only */
968c2ecf20Sopenharmony_ci#define MADV_KEEPONFORK 19		/* Undo MADV_WIPEONFORK */
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define MADV_COLD	20		/* deactivate these pages */
998c2ecf20Sopenharmony_ci#define MADV_PAGEOUT	21		/* reclaim these pages */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci/* compatibility flags */
1028c2ecf20Sopenharmony_ci#define MAP_FILE	0
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci#define PKEY_DISABLE_ACCESS	0x1
1058c2ecf20Sopenharmony_ci#define PKEY_DISABLE_WRITE	0x2
1068c2ecf20Sopenharmony_ci#define PKEY_ACCESS_MASK	(PKEY_DISABLE_ACCESS |\
1078c2ecf20Sopenharmony_ci				 PKEY_DISABLE_WRITE)
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#endif /* _ASM_MMAN_H */
110