1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/// page can be read
pub const PROT_READ: i32 = 0x1;
/// page can be written
pub const PROT_WRITE: i32 = 0x2;
/// page can be executed
pub const PROT_EXEC: i32 = 0x4;
/// page may be used for atomic ops
pub const PROT_SEM: i32 = 0x8;
/// page can not be accessed
pub const PROT_NONE: i32 = 0x0;
/// mprotect flag: extend change to start of growsdown vma
pub const PROT_GROWSDOWN: i32 = 0x01000000;
/// mprotect flag: extend change to end of growsup vma
pub const PROT_GROWSUP: i32 = 0x02000000;

/// 0x01 - 0x03 are defined in linux/mman.h
/// Mask for type of mapping
pub const MAP_TYPE: i32 = 0x0f;
/// Interpret addr exactly
pub const MAP_FIXED: i32 = 0x10;
/// don't use a file
pub const MAP_ANONYMOUS: i32 = 0x20;
// TODO(Shaohua): CONFIG_MMAP_ALLOW_UNINITIALIZED
/// For anonymous mmap, memory could be uninitialized
pub const MAP_UNINITIALIZED: i32 = 0x4000000;

/// 0x0100 - 0x80000 flags are defined in asm-generic/mman.h
/// MAP_FIXED which doesn't unmap underlying mapping
pub const MAP_FIXED_NOREPLACE: i32 = 0x100000;

/// Flags for mlock
/// Lock pages in range after they are faulted in, do not prefault
pub const MLOCK_ONFAULT: i32 = 0x01;

/// sync memory asynchronously
pub const MS_ASYNC: i32 = 1;
/// invalidate the caches
pub const MS_INVALIDATE: i32 = 2;
/// synchronous memory sync
pub const MS_SYNC: i32 = 4;

/// no further special treatment
pub const MADV_NORMAL: i32 = 0;
/// expect random page references
pub const MADV_RANDOM: i32 = 1;
/// expect sequential page references
pub const MADV_SEQUENTIAL: i32 = 2;
/// will need these pages
pub const MADV_WILLNEED: i32 = 3;
/// don't need these pages
pub const MADV_DONTNEED: i32 = 4;

/// common parameters: try to keep these consistent across architectures
/// free pages only if memory pressure
pub const MADV_FREE: i32 = 8;
/// remove these pages & resources
pub const MADV_REMOVE: i32 = 9;
/// don't inherit across fork
pub const MADV_DONTFORK: i32 = 10;
/// do inherit across fork
pub const MADV_DOFORK: i32 = 11;
/// poison a page for testing
pub const MADV_HWPOISON: i32 = 100;
/// soft offline page for testing
pub const MADV_SOFT_OFFLINE: i32 = 101;

/// KSM may merge identical pages
pub const MADV_MERGEABLE: i32 = 12;
/// KSM may not merge identical pages
pub const MADV_UNMERGEABLE: i32 = 13;

/// Worth backing with hugepages
pub const MADV_HUGEPAGE: i32 = 14;
/// Not worth backing with hugepages
pub const MADV_NOHUGEPAGE: i32 = 15;

/// Explicity exclude from the core dump, overrides the coredump filter bits
pub const MADV_DONTDUMP: i32 = 16;
/// Clear the MADV_DONTDUMP flag
pub const MADV_DODUMP: i32 = 17;

/// Zero memory on fork, child only
pub const MADV_WIPEONFORK: i32 = 18;
/// Undo MADV_WIPEONFORK
pub const MADV_KEEPONFORK: i32 = 19;

/// compatibility flags
pub const MAP_FILE: i32 = 0;

pub const PKEY_DISABLE_ACCESS: i32 = 0x1;
pub const PKEY_DISABLE_WRITE: i32 = 0x2;
pub const PKEY_ACCESS_MASK: i32 = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE);