From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id CE93E3858409; Mon, 25 Mar 2024 17:19:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE93E3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711387141; bh=/UrhKhPn8zROQ+aNikyYHCQNLBRYP1PlpZjKqXCYFVI=; h=From:To:Subject:Date:From; b=AldZbeJE9IBBmmMiJ/kStsmAcLgDWALvnLJ29++eH5g1E0E9zcznnmHBgzw+a6KeO ep0zPw0LY2+fLP18Le+V8gaduD9WZtyLRFeQNmW9R+NbMx5BbmiF1O8RieVyjAEGXI ORNv1u68WoqW3qp3pKaJTgI69WvAZmYS+VsVOJRg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/arch: assert that X86_XSTATE_MPX is not set for x32 X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: cd9b374ffe372dcaf7e4c15548cf53a301d8dcdd X-Git-Newrev: efba976d9713a92b4507ccfef2257e4589da2798 Message-Id: <20240325171901.CE93E3858409@sourceware.org> Date: Mon, 25 Mar 2024 17:19:01 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Defba976d9713= a92b4507ccfef2257e4589da2798 commit efba976d9713a92b4507ccfef2257e4589da2798 Author: Andrew Burgess Date: Sat Mar 23 16:17:36 2024 +0000 gdb/arch: assert that X86_XSTATE_MPX is not set for x32 =20 While trying to merge this commit: =20 commit 4bb20a6244b7091a9a7a2ae35dfbd7e8db27550a Date: Wed Mar 20 04:13:18 2024 -0700 =20 gdbserver: Clear X86_XSTATE_MPX bits in xcr0 on x32 =20 With this patch series of mine: =20 https://inbox.sourceware.org/gdb-patches/cover.1706801009.git.aburges= s@redhat.com =20 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. =20 I'm not currently able to build/run any x32 binaries, so I have no way to test this. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31511 Diff: --- gdb/arch/amd64.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c index b8ff4270079..f182e686dda 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 =3D create_feature_i386_64bit_avx (tdesc.get (), regnum); =20 - if ((xcr0 & X86_XSTATE_MPX) && !is_x32) - regnum =3D create_feature_i386_64bit_mpx (tdesc.get (), regnum); + if (xcr0 & X86_XSTATE_MPX) + { + /* MPX is not available on x32. */ + gdb_assert (!is_x32); + regnum =3D create_feature_i386_64bit_mpx (tdesc.get (), regnum); + } =20 if (xcr0 & X86_XSTATE_AVX512) regnum =3D create_feature_i386_64bit_avx512 (tdesc.get (), regnum);