aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2024-03-23 16:17:36 +0000
committerAndrew Burgess <aburgess@redhat.com>2024-03-25 17:14:19 +0000
commitefba976d9713a92b4507ccfef2257e4589da2798 (patch)
treebdb17a8473d76229373c6084a097d37a2ff9b5ab
parentcd9b374ffe372dcaf7e4c15548cf53a301d8dcdd (diff)
downloadgdb-efba976d9713a92b4507ccfef2257e4589da2798.zip
gdb-efba976d9713a92b4507ccfef2257e4589da2798.tar.gz
gdb-efba976d9713a92b4507ccfef2257e4589da2798.tar.bz2
gdb/arch: assert that X86_XSTATE_MPX is not set for x32
While trying to merge this commit: commit 4bb20a6244b7091a9a7a2ae35dfbd7e8db27550a Date: Wed Mar 20 04:13:18 2024 -0700 gdbserver: Clear X86_XSTATE_MPX bits in xcr0 on x32 With this patch series of mine: https://inbox.sourceware.org/gdb-patches/cover.1706801009.git.aburgess@redhat.com I worried that there could be other paths that could result in an xcr0 value that has X86_XSTATE_MPX set in x32 mode. As everyone eventually calls amd64_create_target_description to build their target description, I figured we could assert in here that if X86_XSTATE_MPX is set then we should not be an x32 target, this should uncover any other bugs in this area. I'm not currently able to build/run any x32 binaries, so I have no way to test this. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31511
-rw-r--r--gdb/arch/amd64.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index b8ff427..f182e68 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -66,8 +66,12 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
if (xcr0 & X86_XSTATE_AVX)
regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
- if ((xcr0 & X86_XSTATE_MPX) && !is_x32)
- regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
+ if (xcr0 & X86_XSTATE_MPX)
+ {
+ /* MPX is not available on x32. */
+ gdb_assert (!is_x32);
+ regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
+ }
if (xcr0 & X86_XSTATE_AVX512)
regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);