From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 6F2163858D38; Fri, 17 Nov 2023 10:24:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F2163858D38 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] x86: CPU-qualify {disp16} / {disp32} X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: ed049bd6d8108f0e762c58b9c90334ea1f2cb0e9 X-Git-Newrev: 3086ed9a458f9bc3a52633fc2a10ffc3f21753f4 Message-Id: <20231117102420.6F2163858D38@sourceware.org> Date: Fri, 17 Nov 2023 10:24:20 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Nov 2023 10:24:20 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3086ed9a458f= 9bc3a52633fc2a10ffc3f21753f4 commit 3086ed9a458f9bc3a52633fc2a10ffc3f21753f4 Author: Jan Beulich Date: Fri Nov 17 11:23:20 2023 +0100 x86: CPU-qualify {disp16} / {disp32} =20 {disp16} is invalid to use in 64-bit mode, while {disp32} is invalid to use on pre-386 CPUs. The latter, also affecting other (real) prefixes, further requires that like for insns we fully check the CPU flags; till now only Cpu64/CpuNo64 were taken into consideration. Diff: --- gas/config/tc-i386.c | 11 ++++++++++- gas/testsuite/gas/i386/prefix32.l | 21 +++++++++++++++++++++ gas/testsuite/gas/i386/prefix32.s | 14 ++++++++++++++ gas/testsuite/gas/i386/prefix64.l | 39 +++++++++++++++++++++--------------= ---- gas/testsuite/gas/i386/prefix64.s | 2 ++ opcodes/i386-opc.tbl | 2 +- opcodes/i386-tbl.h | 4 ++-- 7 files changed, 71 insertions(+), 22 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 96065ae3b71..6e788d8ee97 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5769,7 +5769,8 @@ parse_insn (const char *line, char *mnemonic, bool pr= efix_only) && current_templates && current_templates->start->opcode_modifier.isprefix) { - if (!cpu_flags_check_cpu64 (current_templates->start)) + supported =3D cpu_flags_match (current_templates->start); + if (!(supported & CPU_FLAGS_64BIT_MATCH)) { as_bad ((flag_code !=3D CODE_64BIT ? _("`%s' is only supported in 64-bit mode") @@ -5777,6 +5778,14 @@ parse_insn (const char *line, char *mnemonic, bool p= refix_only) insn_name (current_templates->start)); return NULL; } + if (supported !=3D CPU_FLAGS_PERFECT_MATCH) + { + as_bad (_("`%s' is not supported on `%s%s'"), + insn_name (current_templates->start), + cpu_arch_name ? cpu_arch_name : default_arch, + cpu_sub_arch_name ? cpu_sub_arch_name : ""); + return NULL; + } /* If we are in 16-bit mode, do not allow addr16 or data16. Similarly, in 32-bit mode, do not allow addr32 or data32. */ if ((current_templates->start->opcode_modifier.size =3D=3D SIZE16 diff --git a/gas/testsuite/gas/i386/prefix32.l b/gas/testsuite/gas/i386/pre= fix32.l index e43abbdc292..72d7972f1eb 100644 --- a/gas/testsuite/gas/i386/prefix32.l +++ b/gas/testsuite/gas/i386/prefix32.l @@ -10,6 +10,13 @@ .*:20: Error: data size .* `vaddps' .*:21: Error: data size .* `vaddpd' .*:25: Error: same type of prefix .* +.*:31: Error: `xacquire' is not supported on `i386' +.*:32: Error: `notrack' is not supported on `i386' +.*:33: Error: `bnd' is not supported on `i386' +.*:38: Error: `gs' is not supported on `i286' +.*:39: Error: `data32' is not supported on `i286' +.*:40: Error: `addr32' is not supported on `i286' +.*:41: Error: .*disp32.* is not supported on `i286' GAS LISTING .* #... [ ]*1[ ]+\.text @@ -40,4 +47,18 @@ GAS LISTING .* [ ]*26[ ]+\?\?\?\? 3E8B4500[ ]+ds mov %ss:\(%ebp\), %eax [ ]*27[ ]+\?\?\?\? 3E8B4500[ ]+ds mov %ds:\(%ebp\), %eax [ ]*28[ ]* +[ ]*[0-9]+[ ]+\.L386: +[ ]*[0-9]+[ ]+\.arch i386 +[ ]*[0-9]+[ ]+xacquire lock add \[esi\], eax +[ ]*[0-9]+[ ]+notrack call eax +[ ]*[0-9]+[ ]+bnd call eax +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+\.L286: +[ ]*[0-9]+[ ]+\.code16 +[ ]*[0-9]+[ ]+\.arch i286 +[ ]*[0-9]+[ ]+gs inc word ptr \[si\] +[ ]*[0-9]+[ ]+data32 nop +[ ]*[0-9]+[ ]+addr32 nop +[ ]*[0-9]+[ ]+\{disp32\} nop +[ ]*[0-9]+[ ]* #pass diff --git a/gas/testsuite/gas/i386/prefix32.s b/gas/testsuite/gas/i386/pre= fix32.s index 598b0a775b6..9274f662d28 100644 --- a/gas/testsuite/gas/i386/prefix32.s +++ b/gas/testsuite/gas/i386/prefix32.s @@ -26,4 +26,18 @@ prefix: ds mov %ss:(%ebp), %eax ds mov %ds:(%ebp), %eax =20 +.L386: + .arch i386 + xacquire lock add [esi], eax + notrack call eax + bnd call eax + +.L286: + .code16 + .arch i286 + gs inc word ptr [si] + data32 nop + addr32 nop + {disp32} nop + .p2align 4,0 diff --git a/gas/testsuite/gas/i386/prefix64.l b/gas/testsuite/gas/i386/pre= fix64.l index 712f4e0d688..9bf85035af1 100644 --- a/gas/testsuite/gas/i386/prefix64.l +++ b/gas/testsuite/gas/i386/prefix64.l @@ -3,12 +3,13 @@ .*:7: Error: invalid .* `addss' after `repne' .*:8: Error: invalid .* `vaddss' after `repe' .*:9: Error: invalid .* `vaddss' after `repne' -.*:14: Error: same type of prefix .* -.*:15: Error: same type of prefix .* -.*:18: Error: data size .* `addps' -.*:19: Error: data size .* `addpd' -.*:20: Error: data size .* `vaddps' -.*:21: Error: data size .* `vaddpd' +.*:11: Error: .*disp16.* is not supported .* +.*:16: Error: same type of prefix .* +.*:17: Error: same type of prefix .* +.*:20: Error: data size .* `addps' +.*:21: Error: data size .* `addpd' +.*:22: Error: data size .* `vaddps' +.*:23: Error: data size .* `vaddpd' GAS LISTING .* #... [ ]*1[ ]+\.text @@ -21,16 +22,18 @@ GAS LISTING .* [ ]*8[ ]+repe vaddss %xmm0, %xmm0, %xmm0 [ ]*9[ ]+repne vaddss %xmm0, %xmm0, %xmm0 [ ]*10[ ]* -[ ]*11[ ]+\.Lrep_ret: -[ ]*12[ ]+\?\?\?\? F2C3[ ]+bnd ret -[ ]*13[ ]+\?\?\?\? F3C3[ ]+rep ret -[ ]*14[ ]+bnd rep ret -[ ]*15[ ]+rep bnd ret -[ ]*16[ ]* -[ ]*17[ ]+\.Ldata16: -[ ]*18[ ]+data16 addps %xmm0, %xmm0 -[ ]*19[ ]+data16 addpd %xmm0, %xmm0 -[ ]*20[ ]+data16 vaddps %xmm0, %xmm0, %xmm0 -[ ]*21[ ]+data16 vaddpd %xmm0, %xmm0, %xmm0 -[ ]*22[ ]* +[ ]*[0-9]+[ ]+\{disp16\} nop +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+\.Lrep_ret: +[ ]*[0-9]+[ ]+\?\?\?\? F2C3[ ]+bnd ret +[ ]*[0-9]+[ ]+\?\?\?\? F3C3[ ]+rep ret +[ ]*[0-9]+[ ]+bnd rep ret +[ ]*[0-9]+[ ]+rep bnd ret +[ ]*[0-9]+[ ]* +[ ]*[0-9]+[ ]+\.Ldata16: +[ ]*[0-9]+[ ]+data16 addps %xmm0, %xmm0 +[ ]*[0-9]+[ ]+data16 addpd %xmm0, %xmm0 +[ ]*[0-9]+[ ]+data16 vaddps %xmm0, %xmm0, %xmm0 +[ ]*[0-9]+[ ]+data16 vaddpd %xmm0, %xmm0, %xmm0 +[ ]*[0-9]+[ ]* #pass diff --git a/gas/testsuite/gas/i386/prefix64.s b/gas/testsuite/gas/i386/pre= fix64.s index 32091c7c05a..4a0ec6a6851 100644 --- a/gas/testsuite/gas/i386/prefix64.s +++ b/gas/testsuite/gas/i386/prefix64.s @@ -8,6 +8,8 @@ prefix: repe vaddss %xmm0, %xmm0, %xmm0 repne vaddss %xmm0, %xmm0, %xmm0 =20 + {disp16} nop + .Lrep_ret: bnd ret rep ret diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl index c31bf20f2e6..167c0a0249f 100644 --- a/opcodes/i386-opc.tbl +++ b/opcodes/i386-opc.tbl @@ -892,7 +892,7 @@ rex.wrxb, 0x4f, x64, NoSuf|IsPrefix, {} =20 // Pseudo prefixes (base_opcode =3D=3D PSEUDO_PREFIX) =20 - diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h index 527793c5bf6..e662a5017f0 100644 --- a/opcodes/i386-tbl.h +++ b/opcodes/i386-tbl.h @@ -5164,7 +5164,7 @@ static const insn_template i386_optab[] =3D { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 } }, { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } } }, @@ -5172,7 +5172,7 @@ static const insn_template i386_optab[] =3D { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, + { { 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } } },