Skip to content

Commit fc14343

Browse files
committed
gdb, gdbserver, python, testsuite: Remove MPX.
GDB deprecated the commands "show/set mpx bound" in GDB 15.1, as Intel listed Intel(R) Memory Protection Extensions (MPX) as removed in 2019. MPX is also deprecated in gcc (since v9.1), the linux kernel (since v5.6) and glibc (since v2.35). Let's now remove MPX support in GDB completely. This includes the removal of: - MPX functionality including register support - deprecated mpx commands - i386 and amd64 implementation of the hooks report_signal_info and get_siginfo_type - tests - and pretty printer. We keep MPX register numbers to not break compatibility with old gdbservers. Approved-By: Felix Willgerodt <[email protected]>
1 parent ee06c79 commit fc14343

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+61
-2528
lines changed

gdb/NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33

44
*** Changes since GDB 15
55

6+
* Debugging support for Intel MPX has been removed. This includes the
7+
removal of
8+
** MPX register support
9+
** the commands "show/set mpx bound" (deprecated since GDB 15)
10+
** i386 and amd64 implementation of the hooks report_signal_info and
11+
get_siginfo_type.
12+
613
* GDB now supports printing of asynchronous events from the Intel Processor
714
Trace during 'record instruction-history', 'record function-call-history'
815
and all stepping commands. This can be controlled with the new

gdb/amd64-linux-nat.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ static int amd64_linux_gregset32_reg_offset[] =
7979
-1, -1, -1, -1, -1, -1, -1, -1,
8080
-1, -1, -1, -1, -1, -1, -1, -1, -1,
8181
-1, -1, -1, -1, -1, -1, -1, -1,
82+
/* MPX is deprecated. Yet we keep this to not give the registers below
83+
a new number. That could break older gdbservers. */
8284
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
8385
-1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
8486
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */

gdb/amd64-linux-tdep.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ int amd64_linux_gregset_reg_offset[] =
8686
-1, -1, -1, -1, -1, -1, -1, -1, -1,
8787
-1, -1, -1, -1, -1, -1, -1, -1,
8888
-1, -1, -1, -1, -1, -1, -1, -1,
89+
/* MPX is deprecated. Yet we keep this to not give the registers below
90+
a new number. That could break older gdbservers. */
8991
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
9092
-1, -1, /* MPX registers BNDCFGU and BNDSTATUS. */
9193
-1, -1, -1, -1, -1, -1, -1, -1, /* xmm16 ... xmm31 (AVX512) */
@@ -1816,9 +1818,6 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch,
18161818

18171819
set_gdbarch_process_record (gdbarch, i386_process_record);
18181820
set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
1819-
1820-
set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type);
1821-
set_gdbarch_report_signal_info (gdbarch, i386_linux_report_signal_info);
18221821
}
18231822

18241823
static void

gdb/amd64-tdep.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ static const char * const amd64_ymmh_avx512_names[] =
110110
"ymm28h", "ymm29h", "ymm30h", "ymm31h"
111111
};
112112

113-
static const char * const amd64_mpx_names[] =
114-
{
115-
"bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus"
116-
};
117-
118113
static const char * const amd64_k_names[] =
119114
{
120115
"k0", "k1", "k2", "k3",
@@ -1039,13 +1034,6 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
10391034
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
10401035
gdb_byte buf[8];
10411036

1042-
/* BND registers can be in arbitrary values at the moment of the
1043-
inferior call. This can cause boundary violations that are not
1044-
due to a real bug or even desired by the user. The best to be done
1045-
is set the BND registers to allow access to the whole memory, INIT
1046-
state, before pushing the inferior call. */
1047-
i387_reset_bnd_regs (gdbarch, regcache);
1048-
10491037
/* Pass arguments. */
10501038
sp = amd64_push_arguments (regcache, nargs, args, sp, return_method);
10511039

@@ -3196,13 +3184,6 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
31963184
tdep->ymm0h_regnum = AMD64_YMM0H_REGNUM;
31973185
}
31983186

3199-
if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL)
3200-
{
3201-
tdep->mpx_register_names = amd64_mpx_names;
3202-
tdep->bndcfgu_regnum = AMD64_BNDCFGU_REGNUM;
3203-
tdep->bnd0r_regnum = AMD64_BND0R_REGNUM;
3204-
}
3205-
32063187
if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments") != NULL)
32073188
{
32083189
tdep->fsbase_regnum = AMD64_FSBASE_REGNUM;
@@ -3377,11 +3358,10 @@ const struct target_desc *
33773358
amd64_target_description (uint64_t xcr0, bool segments)
33783359
{
33793360
static target_desc *amd64_tdescs \
3380-
[2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
3361+
[2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
33813362
target_desc **tdesc;
33823363

33833364
tdesc = &amd64_tdescs[(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
3384-
[(xcr0 & X86_XSTATE_MPX) ? 1 : 0]
33853365
[(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
33863366
[(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
33873367
[segments ? 1 : 0];

gdb/amd64-tdep.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ enum amd64_regnum
6666
AMD64_MXCSR_REGNUM = AMD64_XMM0_REGNUM + 16,
6767
AMD64_YMM0H_REGNUM, /* %ymm0h */
6868
AMD64_YMM15H_REGNUM = AMD64_YMM0H_REGNUM + 15,
69+
/* MPX is deprecated. Yet we keep this to not give the registers below
70+
a new number. That could break older gdbservers. */
6971
AMD64_BND0R_REGNUM = AMD64_YMM15H_REGNUM + 1,
7072
AMD64_BND3R_REGNUM = AMD64_BND0R_REGNUM + 3,
7173
AMD64_BNDCFGU_REGNUM,

gdb/arch/amd64.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "../features/i386/64bit-avx512.c"
2424
#include "../features/i386/64bit-core.c"
2525
#include "../features/i386/64bit-linux.c"
26-
#include "../features/i386/64bit-mpx.c"
2726
#include "../features/i386/64bit-segments.c"
2827
#include "../features/i386/64bit-sse.c"
2928
#include "../features/i386/pkeys.c"
@@ -65,13 +64,6 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
6564
if (xcr0 & X86_XSTATE_AVX)
6665
regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
6766

68-
if (xcr0 & X86_XSTATE_MPX)
69-
{
70-
/* MPX is not available on x32. */
71-
gdb_assert (!is_x32);
72-
regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
73-
}
74-
7567
if (xcr0 & X86_XSTATE_AVX512)
7668
regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
7769

gdb/arch/i386.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "../features/i386/32bit-sse.c"
2626
#include "../features/i386/32bit-avx.c"
2727
#include "../features/i386/32bit-avx512.c"
28-
#include "../features/i386/32bit-mpx.c"
2928
#include "../features/i386/32bit-segments.c"
3029
#include "../features/i386/pkeys.c"
3130

@@ -59,9 +58,6 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
5958
if (xcr0 & X86_XSTATE_AVX)
6059
regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum);
6160

62-
if (xcr0 & X86_XSTATE_MPX)
63-
regnum = create_feature_i386_32bit_mpx (tdesc.get (), regnum);
64-
6561
if (xcr0 & X86_XSTATE_AVX512)
6662
regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
6763

gdb/arch/x86-linux-tdesc-features.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
6565
{ X86_XSTATE_PKRU, true, true, true },
6666
{ X86_XSTATE_AVX512, true, true, true },
6767
{ X86_XSTATE_AVX, true, true, true },
68-
{ X86_XSTATE_MPX, true, true, false },
6968
{ X86_XSTATE_SSE, true, false, false },
7069
{ X86_XSTATE_X87, true, false, false }
7170
};
@@ -150,9 +149,9 @@ x86_linux_xcr0_to_tdesc_idx (uint64_t xcr0)
150149
the target descriptions (see nat/x86-linux-tdesc.c), the feature order
151150
represents the bit order within the generated index number.
152151
153-
i386 | x87 sse mpx avx avx512 pkru
154-
amd64 | mpx avx avx512 pkru
155-
i32 | avx avx512 pkru
152+
i386 | x87 sse avx avx512 pkru
153+
amd64 | avx avx512 pkru
154+
i32 | avx avx512 pkru
156155
157156
The features are ordered so that for each mode (i386, amd64, i32) the
158157
generated index will form a continuous range. */

gdb/data-directory/Makefile.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ PYTHON_FILE_LIST = \
120120
gdb/function/as_string.py \
121121
gdb/function/caller_is.py \
122122
gdb/function/strfns.py \
123-
gdb/printer/__init__.py \
124-
gdb/printer/bound_registers.py
123+
gdb/printer/__init__.py
125124

126125
@HAVE_PYTHON_TRUE@PYTHON_FILES = $(PYTHON_FILE_LIST)
127126
@HAVE_PYTHON_FALSE@PYTHON_FILES =

gdb/doc/gdb.texinfo

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -7077,33 +7077,6 @@ $1 = (void *) 0x7ffff7ff7000
70777077

70787078
Depending on target support, @code{$_siginfo} may also be writable.
70797079

7080-
@cindex Intel MPX boundary violations
7081-
@cindex boundary violations, Intel MPX
7082-
On some targets, a @code{SIGSEGV} can be caused by a boundary
7083-
violation, i.e., accessing an address outside of the allowed range.
7084-
In those cases @value{GDBN} may displays additional information,
7085-
depending on how @value{GDBN} has been told to handle the signal.
7086-
With @code{handle stop SIGSEGV}, @value{GDBN} displays the violation
7087-
kind: "Upper" or "Lower", the memory address accessed and the
7088-
bounds, while with @code{handle nostop SIGSEGV} no additional
7089-
information is displayed.
7090-
7091-
The usual output of a segfault is:
7092-
@smallexample
7093-
Program received signal SIGSEGV, Segmentation fault
7094-
0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
7095-
68 value = *(p + len);
7096-
@end smallexample
7097-
7098-
While a bound violation is presented as:
7099-
@smallexample
7100-
Program received signal SIGSEGV, Segmentation fault
7101-
Upper bound violation while accessing address 0x7fffffffc3b3
7102-
Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
7103-
0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
7104-
68 value = *(p + len);
7105-
@end smallexample
7106-
71077080
@node Thread Stops
71087081
@section Stopping and Starting Multi-thread Programs
71097082

@@ -26803,91 +26776,6 @@ Show the current setting of the convention to return @code{struct}s
2680326776
from functions.
2680426777
@end table
2680526778

26806-
26807-
@subsubsection Intel @dfn{Memory Protection Extensions} (MPX).
26808-
@cindex Intel Memory Protection Extensions (MPX).
26809-
26810-
Memory Protection Extension (MPX) adds the bound registers @samp{BND0}
26811-
@footnote{The register named with capital letters represent the architecture
26812-
registers.} through @samp{BND3}. Bound registers store a pair of 64-bit values
26813-
which are the lower bound and upper bound. Bounds are effective addresses or
26814-
memory locations. The upper bounds are architecturally represented in 1's
26815-
complement form. A bound having lower bound = 0, and upper bound = 0
26816-
(1's complement of all bits set) will allow access to the entire address space.
26817-
26818-
@samp{BND0} through @samp{BND3} are represented in @value{GDBN} as @samp{bnd0raw}
26819-
through @samp{bnd3raw}. Pseudo registers @samp{bnd0} through @samp{bnd3}
26820-
display the upper bound performing the complement of one operation on the
26821-
upper bound value, i.e.@ when upper bound in @samp{bnd0raw} is 0 in the
26822-
@value{GDBN} @samp{bnd0} it will be @code{0xfff@dots{}}. In this sense it
26823-
can also be noted that the upper bounds are inclusive.
26824-
26825-
As an example, assume that the register BND0 holds bounds for a pointer having
26826-
access allowed for the range between 0x32 and 0x71. The values present on
26827-
bnd0raw and bnd registers are presented as follows:
26828-
26829-
@smallexample
26830-
bnd0raw = @{0x32, 0xffffffff8e@}
26831-
bnd0 = @{lbound = 0x32, ubound = 0x71@} : size 64
26832-
@end smallexample
26833-
26834-
This way the raw value can be accessed via bnd0raw@dots{}bnd3raw. Any
26835-
change on bnd0@dots{}bnd3 or bnd0raw@dots{}bnd3raw is reflect on its
26836-
counterpart. When the bnd0@dots{}bnd3 registers are displayed via
26837-
Python, the display includes the memory size, in bits, accessible to
26838-
the pointer.
26839-
26840-
Bounds can also be stored in bounds tables, which are stored in
26841-
application memory. These tables store bounds for pointers by specifying
26842-
the bounds pointer's value along with its bounds. Evaluating and changing
26843-
bounds located in bound tables is therefore interesting while investigating
26844-
bugs on MPX context. @value{GDBN} provides commands for this purpose:
26845-
26846-
@table @code
26847-
@item show mpx bound @var{pointer}
26848-
@kindex show mpx bound
26849-
Display bounds of the given @var{pointer}.
26850-
26851-
@item set mpx bound @var{pointer}, @var{lbound}, @var{ubound}
26852-
@kindex set mpx bound
26853-
Set the bounds of a pointer in the bound table.
26854-
This command takes three parameters: @var{pointer} is the pointers
26855-
whose bounds are to be changed, @var{lbound} and @var{ubound} are new values
26856-
for lower and upper bounds respectively.
26857-
@end table
26858-
26859-
Both commands are deprecated and will be removed in future versions of
26860-
@value{GDBN}. MPX itself was listed as removed by Intel in 2019.
26861-
26862-
When you call an inferior function on an Intel MPX enabled program,
26863-
GDB sets the inferior's bound registers to the init (disabled) state
26864-
before calling the function. As a consequence, bounds checks for the
26865-
pointer arguments passed to the function will always pass.
26866-
26867-
This is necessary because when you call an inferior function, the
26868-
program is usually in the middle of the execution of other function.
26869-
Since at that point bound registers are in an arbitrary state, not
26870-
clearing them would lead to random bound violations in the called
26871-
function.
26872-
26873-
You can still examine the influence of the bound registers on the
26874-
execution of the called function by stopping the execution of the
26875-
called function at its prologue, setting bound registers, and
26876-
continuing the execution. For example:
26877-
26878-
@smallexample
26879-
$ break *upper
26880-
Breakpoint 2 at 0x4009de: file i386-mpx-call.c, line 47.
26881-
$ print upper (a, b, c, d, 1)
26882-
Breakpoint 2, upper (a=0x0, b=0x6e0000005b, c=0x0, d=0x0, len=48)....
26883-
$ print $bnd0
26884-
@{lbound = 0x0, ubound = ffffffff@} : size -1
26885-
@end smallexample
26886-
26887-
At this last step the value of bnd0 can be changed for investigation of bound
26888-
violations caused along the execution of the call. In order to know how to
26889-
set the bound registers or bound table for the call consult the ABI.
26890-
2689126779
@subsubsection x87 registers
2689226780

2689326781
@value{GDBN} provides access to the x87 state through the following registers:
@@ -49746,16 +49634,6 @@ describe the upper 128 bits of @sc{ymm} registers:
4974649634
@samp{ymm0h} through @samp{ymm15h} for amd64
4974749635
@end itemize
4974849636

49749-
The @samp{org.gnu.gdb.i386.mpx} is an optional feature representing Intel
49750-
Memory Protection Extension (MPX). It should describe the following registers:
49751-
49752-
@itemize @minus
49753-
@item
49754-
@samp{bnd0raw} through @samp{bnd3raw} for i386 and amd64.
49755-
@item
49756-
@samp{bndcfgu} and @samp{bndstatus} for i386 and amd64.
49757-
@end itemize
49758-
4975949637
The @samp{org.gnu.gdb.i386.linux} feature is optional. It should
4976049638
describe a single register, @samp{orig_eax}.
4976149639

gdb/features/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,10 @@ FEATURE_XMLFILES = aarch64-core.xml \
222222
i386/32bit-sse.xml \
223223
i386/32bit-linux.xml \
224224
i386/32bit-avx.xml \
225-
i386/32bit-mpx.xml \
226225
i386/32bit-avx512.xml \
227226
i386/32bit-segments.xml \
228227
i386/64bit-avx512.xml \
229228
i386/64bit-core.xml \
230-
i386/64bit-mpx.xml \
231229
i386/64bit-segments.xml \
232230
i386/64bit-avx.xml \
233231
i386/64bit-linux.xml \

gdb/features/i386/32bit-mpx.c

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)