From: Jan Beulich Date: Tue, 9 Mar 2021 07:53:38 +0000 (+0100) Subject: x86-64: make SYSEXIT handling similar to SYSRET's X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e93a3b27b23ca2850c01dfc8fdf1aa237d819193;p=binutils-gdb.git x86-64: make SYSEXIT handling similar to SYSRET's Despite SYSEXIT being an Intel-only insn in long mode, its behavior there is similar to SYSRET's: Depending on REX.W execution continues in either 64-bit or compatibility mode. Hence distinguishing by suffix is as necessary here as it is there. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 8dd9a59d072..ee553fbb0c2 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,18 @@ +2021-03-09 Jan Beulich + + * testsuite/gas/i386/noreg64.s: Add sysexit. + * testsuite/gas/i386/x86-64-sysenter-amd.s: Split sysexit into + sysexitl and sysexitq. + * testsuite/gas/i386/noreg-intel64.l, + testsuite/gas/i386/noreg64-data16.d, + testsuite/gas/i386/noreg64-data16.e, + testsuite/gas/i386/noreg64-rex64.d, + testsuite/gas/i386/noreg64.d, + testsuite/gas/i386/noreg64.l, + testsuite/gas/i386/x86-64-sysenter-amd.d, + testsuite/gas/i386/x86-64-sysenter-amd.l, + testsuite/gas/i386/x86-64-sysenter-intel.d: Adjust expectations. + 2021-02-26 Nick Clifton PR 27411 diff --git a/gas/testsuite/gas/i386/noreg-intel64.l b/gas/testsuite/gas/i386/noreg-intel64.l index 4bcec14e1a3..9b9226d6d4e 100644 --- a/gas/testsuite/gas/i386/noreg-intel64.l +++ b/gas/testsuite/gas/i386/noreg-intel64.l @@ -124,6 +124,7 @@ .*:[1-9][0-9]*: Warning: .* `sub' .*:[1-9][0-9]*: Warning: .* `sub' .*:[1-9][0-9]*: Warning: .* `sub' +.*:[1-9][0-9]*: Warning: .* `sysexit' .*:[1-9][0-9]*: Warning: .* `sysret' .*:[1-9][0-9]*: Warning: .* `test' .*:[1-9][0-9]*: Warning: .* `test' diff --git a/gas/testsuite/gas/i386/noreg64-data16.d b/gas/testsuite/gas/i386/noreg64-data16.d index 881043df61e..f5e921c14fc 100644 --- a/gas/testsuite/gas/i386/noreg64-data16.d +++ b/gas/testsuite/gas/i386/noreg64-data16.d @@ -150,6 +150,7 @@ Disassembly of section .text: *[a-f0-9]+: 66 81 28 89 00 subw \$0x89,\(%rax\) *[a-f0-9]+: 66 81 28 34 12 subw \$0x1234,\(%rax\) *[a-f0-9]+: 66 81 28 78 56 subw \$0x5678,\(%rax\) + *[a-f0-9]+: 66 0f 35 data16 sysexitl * *[a-f0-9]+: 66 0f 07 data16 sysretl * *[a-f0-9]+: 66 f7 00 89 00 testw \$0x89,\(%rax\) *[a-f0-9]+: 66 f7 00 34 12 testw \$0x1234,\(%rax\) diff --git a/gas/testsuite/gas/i386/noreg64-data16.e b/gas/testsuite/gas/i386/noreg64-data16.e index 24c595a7b2b..5b37033f959 100644 --- a/gas/testsuite/gas/i386/noreg64-data16.e +++ b/gas/testsuite/gas/i386/noreg64-data16.e @@ -7,5 +7,5 @@ .*:117: Warning: .*shortened.* .*:146: Warning: .*shortened.* .*:170: Warning: .*shortened.* -.*:174: Warning: .*shortened.* -.*:178: Warning: .*shortened.* +.*:175: Warning: .*shortened.* +.*:179: Warning: .*shortened.* diff --git a/gas/testsuite/gas/i386/noreg64-rex64.d b/gas/testsuite/gas/i386/noreg64-rex64.d index db36de483c5..bf16ab7e417 100644 --- a/gas/testsuite/gas/i386/noreg64-rex64.d +++ b/gas/testsuite/gas/i386/noreg64-rex64.d @@ -149,6 +149,7 @@ Disassembly of section .text: *[a-f0-9]+: 48 81 28 89 00 00 00 subq \$0x89,\(%rax\) *[a-f0-9]+: 48 81 28 34 12 00 00 subq \$0x1234,\(%rax\) *[a-f0-9]+: 48 81 28 78 56 34 12 subq \$0x12345678,\(%rax\) + *[a-f0-9]+: 48 0f 35 sysexitq * *[a-f0-9]+: 48 0f 07 sysretq * *[a-f0-9]+: 48 f7 00 89 00 00 00 testq \$0x89,\(%rax\) *[a-f0-9]+: 48 f7 00 34 12 00 00 testq \$0x1234,\(%rax\) diff --git a/gas/testsuite/gas/i386/noreg64.d b/gas/testsuite/gas/i386/noreg64.d index 6cc461f485b..e73caeed893 100644 --- a/gas/testsuite/gas/i386/noreg64.d +++ b/gas/testsuite/gas/i386/noreg64.d @@ -151,6 +151,7 @@ Disassembly of section .text: *[a-f0-9]+: 81 28 89 00 00 00 subl \$0x89,\(%rax\) *[a-f0-9]+: 81 28 34 12 00 00 subl \$0x1234,\(%rax\) *[a-f0-9]+: 81 28 78 56 34 12 subl \$0x12345678,\(%rax\) + *[a-f0-9]+: 0f 35 sysexitl * *[a-f0-9]+: 0f 07 sysretl * *[a-f0-9]+: f7 00 89 00 00 00 testl \$0x89,\(%rax\) *[a-f0-9]+: f7 00 34 12 00 00 testl \$0x1234,\(%rax\) diff --git a/gas/testsuite/gas/i386/noreg64.l b/gas/testsuite/gas/i386/noreg64.l index c4e8b05c595..23baa2606c2 100644 --- a/gas/testsuite/gas/i386/noreg64.l +++ b/gas/testsuite/gas/i386/noreg64.l @@ -122,6 +122,7 @@ .*:[1-9][0-9]*: Warning: .* `sub' .*:[1-9][0-9]*: Warning: .* `sub' .*:[1-9][0-9]*: Warning: .* `sub' +.*:[1-9][0-9]*: Warning: .* `sysexit' .*:[1-9][0-9]*: Warning: .* `sysret' .*:[1-9][0-9]*: Warning: .* `test' .*:[1-9][0-9]*: Warning: .* `test' diff --git a/gas/testsuite/gas/i386/noreg64.s b/gas/testsuite/gas/i386/noreg64.s index 6845bb73487..c067f88ce17 100644 --- a/gas/testsuite/gas/i386/noreg64.s +++ b/gas/testsuite/gas/i386/noreg64.s @@ -168,6 +168,7 @@ noreg: pfx sub $0x89, (%rax) pfx sub $0x1234, (%rax) pfx sub $0x12345678, (%rax) + pfx sysexit pfx sysret pfx test $0x89, (%rax) pfx test $0x1234, (%rax) diff --git a/gas/testsuite/gas/i386/x86-64-sysenter-amd.d b/gas/testsuite/gas/i386/x86-64-sysenter-amd.d index 5b2fc37a64e..b3fa23cad86 100644 --- a/gas/testsuite/gas/i386/x86-64-sysenter-amd.d +++ b/gas/testsuite/gas/i386/x86-64-sysenter-amd.d @@ -9,6 +9,8 @@ Disassembly of section .text: 0+ <.text>: [ ]*[a-f0-9]+:[ ]+0f 34[ ]+\(bad\)[ ]* [ ]*[a-f0-9]+:[ ]+0f 35[ ]+\(bad\)[ ]* +[ ]*[a-f0-9]+:[ ]+48 0f 35[ ]+\(bad\)[ ]* [ ]*[a-f0-9]+:[ ]+0f 34[ ]+\(bad\)[ ]* [ ]*[a-f0-9]+:[ ]+0f 35[ ]+\(bad\)[ ]* +[ ]*[a-f0-9]+:[ ]+48 0f 35[ ]+\(bad\)[ ]* #pass diff --git a/gas/testsuite/gas/i386/x86-64-sysenter-amd.l b/gas/testsuite/gas/i386/x86-64-sysenter-amd.l index faa2562335d..c7d30e2c7f8 100644 --- a/gas/testsuite/gas/i386/x86-64-sysenter-amd.l +++ b/gas/testsuite/gas/i386/x86-64-sysenter-amd.l @@ -1,5 +1,7 @@ .*: Assembler messages: .*:2: Error: .* .*:3: Error: .* -.*:6: Error: .* +.*:4: Error: .* .*:7: Error: .* +.*:8: Error: .* +.*:9: Error: .* diff --git a/gas/testsuite/gas/i386/x86-64-sysenter-amd.s b/gas/testsuite/gas/i386/x86-64-sysenter-amd.s index b6d31f99ceb..bf9bddaedd4 100644 --- a/gas/testsuite/gas/i386/x86-64-sysenter-amd.s +++ b/gas/testsuite/gas/i386/x86-64-sysenter-amd.s @@ -1,7 +1,9 @@ .text sysenter - sysexit + sysexitl + sysexitq .intel_syntax noprefix sysenter - sysexit + sysexitd + sysexitq diff --git a/gas/testsuite/gas/i386/x86-64-sysenter-intel.d b/gas/testsuite/gas/i386/x86-64-sysenter-intel.d index ffd5e3e96a8..451cd91d5de 100644 --- a/gas/testsuite/gas/i386/x86-64-sysenter-intel.d +++ b/gas/testsuite/gas/i386/x86-64-sysenter-intel.d @@ -9,7 +9,9 @@ Disassembly of section .text: 0+ <.text>: [ ]*[a-f0-9]+: 0f 34 sysenter * -[ ]*[a-f0-9]+: 0f 35 sysexit * +[ ]*[a-f0-9]+: 0f 35 sysexitl * +[ ]*[a-f0-9]+: 48 0f 35 sysexitq * [ ]*[a-f0-9]+: 0f 34 sysenter * -[ ]*[a-f0-9]+: 0f 35 sysexit * +[ ]*[a-f0-9]+: 0f 35 sysexitl * +[ ]*[a-f0-9]+: 48 0f 35 sysexitq * #pass diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index d15907029da..1b689f32e2f 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,10 @@ +2021-03-09 Jan Beulich + + * opcodes/i386-dis.c (dis386_twobyte): Add %LQ to sysexit. + * opcodes/i386-opc.tbl (sysexit): Drop No_lSuf and No_qSuf from + 64-bit form. + * opcodes/i386-tbl.h: Re-generate. + 2021-03-03 Jan Beulich * i386-gen.c (output_i386_opcode): Don't get operand count. Look diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 59888c8c536..6a34ce534f6 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -2180,7 +2180,7 @@ static const struct dis386 dis386_twobyte[] = { { "rdmsr", { XX }, 0 }, { "rdpmc", { XX }, 0 }, { "sysenter", { SEP }, 0 }, - { "sysexit", { SEP }, 0 }, + { "sysexit%LQ", { SEP }, 0 }, { Bad_Opcode }, { "getsec", { XX }, 0 }, /* 38 */ diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl index 87f69af37d9..e792cedf969 100644 --- a/opcodes/i386-opc.tbl +++ b/opcodes/i386-opc.tbl @@ -877,7 +877,7 @@ cmpxchg8b, 0xfc7, 0x1, 2, Cpu586, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_ldSuf // Pentium II/Pentium Pro extensions. sysenter, 0xf34, None, 2, Cpu64, Intel64Only|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {} sysenter, 0xf34, None, 2, Cpu686|CpuNo64, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {} -sysexit, 0xf35, None, 2, Cpu64, Intel64Only|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {} +sysexit, 0xf35, None, 2, Cpu64, Intel64Only|No_bSuf|No_wSuf|No_sSuf|No_ldSuf, {} sysexit, 0xf35, None, 2, Cpu686|CpuNo64, No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {} fxsave, 0xfae, 0x0, 2, CpuFXSR, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_ldSuf, { Unspecified|BaseIndex } fxsave64, 0xfae, 0x0, 2, CpuFXSR|Cpu64, Modrm|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf|Size64, { Unspecified|BaseIndex } diff --git a/opcodes/i386-tbl.h b/opcodes/i386-tbl.h index b2457c6f4c3..12b049e16d7 100644 --- a/opcodes/i386-tbl.h +++ b/opcodes/i386-tbl.h @@ -8508,7 +8508,7 @@ const insn_template i386_optab[] = 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, 1, 0, 0 } }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 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, 3 }, { { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,