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
| | #ifndef _SYS_PRCTL_H
#define _SYS_PRCTL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <linux/prctl.h>
// Forward declaring newer prctls, if we have an outdated kernel...
// 2023: mm: implement memory-deny-write-execute as a prctl
#ifndef PR_SET_MDWE
# define PR_SET_MDWE 65
# define PR_MDWE_REFUSE_EXEC_GAIN 1
# define PR_GET_MDWE 66
#endif
// 2023: prctl: add PR_GET_AUXV to copy auxv to userspace
#ifndef PR_GET_AUXV
# define PR_GET_AUXV 0x41555856
#endif
// 2023: mm: add new api to enable ksm per process
#ifndef PR_SET_MEMORY_MERGE
# define PR_SET_MEMORY_MERGE 67
# define PR_GET_MEMORY_MERGE 68
#endif
// 2023: riscv: Add prctl controls for userspace vector management
#ifndef PR_RISCV_V_SET_CONTROL
# define PR_RISCV_V_SET_CONTROL 69
# define PR_RISCV_V_GET_CONTROL 70
# define PR_RISCV_V_VSTATE_CTRL_DEFAULT 0
# define PR_RISCV_V_VSTATE_CTRL_OFF 1
# define PR_RISCV_V_VSTATE_CTRL_ON 2
# define PR_RISCV_V_VSTATE_CTRL_INHERIT (1 << 4)
# define PR_RISCV_V_VSTATE_CTRL_CUR_MASK 0x3
# define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK 0xc
# define PR_RISCV_V_VSTATE_CTRL_MASK 0x1f
#endif
// 2023: mm: add a NO_INHERIT flag to the PR_SET_MDWE prctl
#ifndef PR_MDWE_NO_INHERIT
# define PR_MDWE_NO_INHERIT (1UL << 1)
#endif
// 2024: riscv+ppc extensions from riscv-for-linus-6.10-mw1 merged into mainline
#ifndef PR_RISCV_SET_ICACHE_FLUSH_CTX
# define PR_RISCV_SET_ICACHE_FLUSH_CTX 71
# define PR_RISCV_CTX_SW_FENCEI_ON 0
# define PR_RISCV_CTX_SW_FENCEI_OFF 1
# define PR_RISCV_SCOPE_PER_PROCESS 0
# define PR_RISCV_SCOPE_PER_THREAD 1
#endif
#ifdef PR_PPC_GET_DEXCR
# define PR_PPC_GET_DEXCR 72
# define PR_PPC_SET_DEXCR 73
# define PR_PPC_DEXCR_SBHE 0
# define PR_PPC_DEXCR_IBRTPD 1
# define PR_PPC_DEXCR_SRAPD 2
# define PR_PPC_DEXCR_NPHIE 3
# define PR_PPC_DEXCR_CTRL_EDITABLE 0x1
# define PR_PPC_DEXCR_CTRL_SET 0x2
# define PR_PPC_DEXCR_CTRL_CLEAR 0x4
# define PR_PPC_DEXCR_CTRL_SET_ONEXEC 0x8
# define PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC 0x10
# define PR_PPC_DEXCR_CTRL_MASK 0x1f
#endif
int prctl (int, ...);
#ifdef __cplusplus
}
#endif
#endif
|