162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * include/asm-xtensa/mman.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Xtensa Processor memory-manager definitions 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 862306a36Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 962306a36Sopenharmony_ci * for more details. 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * Copyright (C) 1995 by Ralf Baechle 1262306a36Sopenharmony_ci * Copyright (C) 2001 - 2005 Tensilica Inc. 1362306a36Sopenharmony_ci */ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#ifndef _XTENSA_MMAN_H 1662306a36Sopenharmony_ci#define _XTENSA_MMAN_H 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* 1962306a36Sopenharmony_ci * Protections are chosen from these bits, OR'd together. The 2062306a36Sopenharmony_ci * implementation does not necessarily support PROT_EXEC or PROT_WRITE 2162306a36Sopenharmony_ci * without PROT_READ. The only guarantees are that no writing will be 2262306a36Sopenharmony_ci * allowed without PROT_WRITE and no access will be allowed for PROT_NONE. 2362306a36Sopenharmony_ci */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define PROT_NONE 0x0 /* page can not be accessed */ 2662306a36Sopenharmony_ci#define PROT_READ 0x1 /* page can be read */ 2762306a36Sopenharmony_ci#define PROT_WRITE 0x2 /* page can be written */ 2862306a36Sopenharmony_ci#define PROT_EXEC 0x4 /* page can be executed */ 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define PROT_SEM 0x10 /* page may be used for atomic ops */ 3162306a36Sopenharmony_ci#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ 3262306a36Sopenharmony_ci#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end fo growsup vma */ 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci/* 3562306a36Sopenharmony_ci * Flags for mmap 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_ci/* 0x01 - 0x03 are defined in linux/mman.h */ 3862306a36Sopenharmony_ci#define MAP_TYPE 0x00f /* Mask for type of mapping */ 3962306a36Sopenharmony_ci#define MAP_FIXED 0x010 /* Interpret addr exactly */ 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* not used by linux, but here to make sure we don't clash with ABI defines */ 4262306a36Sopenharmony_ci#define MAP_RENAME 0x020 /* Assign page to file */ 4362306a36Sopenharmony_ci#define MAP_AUTOGROW 0x040 /* File may grow by writing */ 4462306a36Sopenharmony_ci#define MAP_LOCAL 0x080 /* Copy on fork/sproc */ 4562306a36Sopenharmony_ci#define MAP_AUTORSRV 0x100 /* Logical swap reserved on demand */ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* These are linux-specific */ 4862306a36Sopenharmony_ci#define MAP_NORESERVE 0x0400 /* don't check for reservations */ 4962306a36Sopenharmony_ci#define MAP_ANONYMOUS 0x0800 /* don't use a file */ 5062306a36Sopenharmony_ci#define MAP_GROWSDOWN 0x1000 /* stack-like segment */ 5162306a36Sopenharmony_ci#define MAP_DENYWRITE 0x2000 /* ETXTBSY */ 5262306a36Sopenharmony_ci#define MAP_EXECUTABLE 0x4000 /* mark it as an executable */ 5362306a36Sopenharmony_ci#define MAP_LOCKED 0x8000 /* pages are locked */ 5462306a36Sopenharmony_ci#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */ 5562306a36Sopenharmony_ci#define MAP_NONBLOCK 0x20000 /* do not block on IO */ 5662306a36Sopenharmony_ci#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ 5762306a36Sopenharmony_ci#define MAP_HUGETLB 0x80000 /* create a huge page mapping */ 5862306a36Sopenharmony_ci#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ 5962306a36Sopenharmony_ci#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be 6062306a36Sopenharmony_ci * uninitialized */ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * Flags for msync 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_ci#define MS_ASYNC 0x0001 /* sync memory asynchronously */ 6662306a36Sopenharmony_ci#define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */ 6762306a36Sopenharmony_ci#define MS_SYNC 0x0004 /* synchronous memory sync */ 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* 7062306a36Sopenharmony_ci * Flags for mlockall 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci#define MCL_CURRENT 1 /* lock all current mappings */ 7362306a36Sopenharmony_ci#define MCL_FUTURE 2 /* lock all future mappings */ 7462306a36Sopenharmony_ci#define MCL_ONFAULT 4 /* lock all pages that are faulted in */ 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* 7762306a36Sopenharmony_ci * Flags for mlock 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci#define MLOCK_ONFAULT 0x01 /* Lock pages in range after they are faulted in, do not prefault */ 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define MADV_NORMAL 0 /* no further special treatment */ 8262306a36Sopenharmony_ci#define MADV_RANDOM 1 /* expect random page references */ 8362306a36Sopenharmony_ci#define MADV_SEQUENTIAL 2 /* expect sequential page references */ 8462306a36Sopenharmony_ci#define MADV_WILLNEED 3 /* will need these pages */ 8562306a36Sopenharmony_ci#define MADV_DONTNEED 4 /* don't need these pages */ 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* common parameters: try to keep these consistent across architectures */ 8862306a36Sopenharmony_ci#define MADV_FREE 8 /* free pages only if memory pressure */ 8962306a36Sopenharmony_ci#define MADV_REMOVE 9 /* remove these pages & resources */ 9062306a36Sopenharmony_ci#define MADV_DONTFORK 10 /* don't inherit across fork */ 9162306a36Sopenharmony_ci#define MADV_DOFORK 11 /* do inherit across fork */ 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define MADV_MERGEABLE 12 /* KSM may merge identical pages */ 9462306a36Sopenharmony_ci#define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 9762306a36Sopenharmony_ci#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, 10062306a36Sopenharmony_ci overrides the coredump filter bits */ 10162306a36Sopenharmony_ci#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */ 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci#define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ 10462306a36Sopenharmony_ci#define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#define MADV_COLD 20 /* deactivate these pages */ 10762306a36Sopenharmony_ci#define MADV_PAGEOUT 21 /* reclaim these pages */ 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */ 11062306a36Sopenharmony_ci#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */ 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci#define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* compatibility flags */ 11762306a36Sopenharmony_ci#define MAP_FILE 0 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci#define PKEY_DISABLE_ACCESS 0x1 12062306a36Sopenharmony_ci#define PKEY_DISABLE_WRITE 0x2 12162306a36Sopenharmony_ci#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ 12262306a36Sopenharmony_ci PKEY_DISABLE_WRITE) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#endif /* _XTENSA_MMAN_H */ 125