Debian Codegraph @

upstream/debian-unstable/man2/PR_MPX_ENABLE_MANAGEMENT.2const

raw
1 .\" Copyright 2014, Dave Hansen <[email protected]>
2 .\" Copyright 2014, Intel Corp.
3 .\" Copyright 2015, Michael Kerrisk <[email protected]>
4 .\" Copyright, the authors of the Linux man-pages project
5 .\"
6 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
7 .\"
8 .TH PR_MPX_ENABLE_MANAGEMENT 2const 2026-02-08 "Linux man-pages 6.18"
9 .SH NAME
10 PR_MPX_ENABLE_MANAGEMENT,
11 PR_MPX_DISABLE_MANAGEMENT
12 \-
13 enable or disable kernel management of Memory Protection eXtensions (MPX)
14 .SH LIBRARY
15 Standard C library
16 .RI ( libc ,\~ \-lc )
17 .SH SYNOPSIS
18 .nf
19 .BR "#include <linux/prctl.h>" " /* Definition of " PR_* " constants */"
20 .B #include <sys/prctl.h>
21 .P
22 .B [[deprecated]] int prctl(PR_MPX_ENABLE_MANAGEMENT, 0L, 0L, 0L, 0L);
23 .B [[deprecated]] int prctl(PR_MPX_DISABLE_MANAGEMENT, 0L, 0L, 0L, 0L);
24 .fi
25 .SH DESCRIPTION
26 Enable or disable kernel management of Memory Protection eXtensions (MPX)
27 bounds tables.
28 .P
29 MPX is a hardware-assisted mechanism for
30 performing bounds checking on pointers.
31 It consists of a set of registers storing bounds information
32 and a set of special instruction prefixes that tell the CPU
33 on which instructions it should do bounds enforcement.
34 There is a limited number of these registers and
35 when there are more pointers than registers,
36 their contents must be "spilled" into a set of tables.
37 These tables are called "bounds tables" and the MPX
38 .BR prctl ()
39 operations control
40 whether the kernel manages their allocation and freeing.
41 .P
42 When management is enabled,
43 the kernel will take over
44 allocation and freeing of the bounds tables.
45 It does this by trapping the #BR exceptions that result
46 at first use of missing bounds tables and
47 instead of delivering the exception to user space,
48 it allocates the table and populates the bounds directory
49 with the location of the new table.
50 For freeing,
51 the kernel checks to see if bounds tables are
52 present for memory which is not allocated,
53 and frees them if so.
54 .P
55 Before enabling MPX management using
56 .BR PR_MPX_ENABLE_MANAGEMENT ,
57 the application must first have allocated
58 a user-space buffer for the bounds directory and
59 placed the location of that directory in the
60 .I bndcfgu
61 register.
62 .P
63 These calls fail if the CPU or kernel does not support MPX.
64 Kernel support for MPX is enabled via the
65 .B CONFIG_X86_INTEL_MPX
66 configuration option.
67 You can check whether the CPU supports MPX by looking for the
68 .I mpx
69 CPUID bit, like with the following command:
70 .P
71 .in +4n
72 .EX
73 cat /proc/cpuinfo | grep \[aq] mpx \[aq]
74 .EE
75 .in
76 .P
77 A thread may not switch in or out of long (64-bit) mode
78 while MPX is enabled.
79 .P
80 All threads in a process are affected by these calls.
81 .P
82 The child of a
83 .BR fork (2)
84 inherits the state of MPX management.
85 During
86 .BR execve (2),
87 MPX management is reset to a state as if
88 .B PR_MPX_DISABLE_MANAGEMENT
89 had been called.
90 .SH RETURN VALUE
91 On success,
92 0 is returned.
93 On error, \-1 is returned, and
94 .I errno
95 is set to indicate the error.
96 .SH ERRORS
97 .TP
98 .B ENXIO
99 The kernel or the CPU does not support MPX management.
100 Check that the kernel and processor have MPX support.
101 .SH STANDARDS
102 None.
103 .SH HISTORY
104 Linux 3.19.
105 Removed in Linux 5.4.
106 Only on x86.
107 .\" commit fe3d197f84319d3bce379a9c0dc17b1f48ad358c
108 .\" See also http://lwn.net/Articles/582712/
109 .\" See also https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler
110 .P
111 .\" commit f240652b6032b48ad7fa35c5e701cc4c8d697c0b
112 .\" See also https://lkml.kernel.org/r/[email protected]
113 Due to a lack of toolchain support,
114 .B PR_MPX_ENABLE_MANAGEMENT
115 and
116 .B PR_MPX_DISABLE_MANAGEMENT
117 are not supported in Linux 5.4 and later.
118 .SH SEE ALSO
119 .BR prctl (2)
120 .P
121 For further information on Intel MPX, see the kernel source file
122 .IR Documentation/\:x86/\:intel_mpx.rst .