From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7804) id 806613858D1E; Mon, 22 Apr 2024 01:28:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 806613858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713749308; bh=IFfzIWhDsGNciTq1ezwyRGKYQyZvvoiRiJ+DlAYIogY=; h=From:To:Subject:Date:From; b=ZMGnxKrM++yWh28zoM7lYtxZmvHi35TF1rCSAGB49P+Boyj98gO2cRwb4+87mjKPc 6hcQC75rxylxRXl63wFx1zzzsJlfdKRiJWHu5Ve259cWref9UWd3ixe2/fyGkMtv3A lKzjc7KxulrUI3zjPu1/2o/MZIahTuKj+9jHdCZA= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Lili Cui To: binutils-cvs@sourceware.org Subject: [binutils-gdb] x86/APX: Add invalid check for APX EVEX.X4. X-Act-Checkin: binutils-gdb X-Git-Author: Cui, Lili X-Git-Refname: refs/heads/master X-Git-Oldrev: 80fa407f9fb8df8b4d4ac3d5db8cc7bdc07eab7f X-Git-Newrev: b5247082c4a71f69ba53e5b076409f25918d953f Message-Id: <20240422012828.806613858D1E@sourceware.org> Date: Mon, 22 Apr 2024 01:28:28 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db5247082c4a7= 1f69ba53e5b076409f25918d953f commit b5247082c4a71f69ba53e5b076409f25918d953f Author: Cui, Lili Date: Mon Apr 22 09:25:56 2024 +0800 x86/APX: Add invalid check for APX EVEX.X4. =20 gas/ChangeLog: =20 * config/tc-i386.c (build_apx_evex_prefix): Added invalid check= for APX X4. * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Added inva= lid testcase. * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto. =20 opcodes/ChangeLog: =20 * i386-dis.c (get_valid_dis386): Added invalid check for APX X4. Diff: --- gas/config/tc-i386.c | 5 ++++- gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d | 2 ++ gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s | 3 +++ opcodes/i386-dis.c | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 1637f55759c..b03746852d6 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4276,7 +4276,10 @@ build_apx_evex_prefix (void) if (i.rex2 & REX_B) i.vex.bytes[1] |=3D 0x08; if (i.rex2 & REX_X) - i.vex.bytes[2] &=3D ~0x04; + { + gas_assert (i.rm.mode !=3D 3); + i.vex.bytes[2] &=3D ~0x04; + } if (i.vex.register_specifier && i.vex.register_specifier->reg_flags & RegRex2) i.vex.bytes[3] &=3D ~0x08; diff --git a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d b/gas/te= stsuite/gas/i386/x86-64-apx-evex-promoted-bad.d index 1a6b6656ff7..6330367194c 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d +++ b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d @@ -39,4 +39,6 @@ Disassembly of section .text: [ ]*[a-f0-9]+:[ ]+62 d4 24 18 8f[ ]+\(bad\) [ ]*[a-f0-9]+:[ ]+c3[ ]+.* [ ]*[a-f0-9]+:[ ]+62 fc 7d 0c 60 c7[ ]+movbe \{bad-nf\},%r23w,%ax +[ ]*[a-f0-9]+:[ ]+62 fc 79 08 60[ ]+\(bad\) +[ ]*[a-f0-9]+:[ ]+c2[ ]+.* #pass diff --git a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s b/gas/te= stsuite/gas/i386/x86-64-apx-evex-promoted-bad.s index bc55b5e726a..cbf34515bab 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s +++ b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s @@ -53,3 +53,6 @@ _start: =20 #EVEX_MAP4 movbe %r18w,%ax set EVEX.nf =3D 1. .insn EVEX.L0.66.M12.W0 0x60, %di, %ax {%k4} + + # EVEX_MAP4 movbe %r18w,%ax set EVEX.P[10] =3D 0. + .byte 0x62, 0xfc, 0x79, 0x08, 0x60, 0xc2 diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index b9fdda1b578..53f2d6cf6d8 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -9192,6 +9192,9 @@ get_valid_dis386 (const struct dis386 *dp, instr_info= *ins) if (!fetch_modrm (ins)) return &err_opcode; =20 + if (ins->modrm.mod =3D=3D 3 && (ins->rex2 & REX_X)) + return &bad_opcode; + /* Set vector length. For EVEX-promoted instructions, evex.ll =3D=3D= 0b00, which has the same encoding as vex.length =3D=3D 128 and they can share the same processing with vex.length in OP_VEX. */