[PATCH] x86-64: make SYSEXIT handling similar to SYSRET's
Jan Beulich
jbeulich@suse.com
Mon Mar 8 13:53:11 GMT 2021
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.
gas/
2021-03-XX Jan Beulich <jbeulich@suse.com>
* 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.
opcodes/
2021-03-XX Jan Beulich <jbeulich@suse.com>
* 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.
---
SYSRET also allows for an 'l' suffix outside of 64-bit mode. I wasn't
sure whether to also mirror this here.
--- 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'
--- 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\)
--- 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.*
--- 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\)
--- 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\)
--- 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'
--- 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)
--- 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
--- 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: .*
--- 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
--- 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
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -2180,7 +2180,7 @@ static const struct dis386 dis386_twobyt
{ "rdmsr", { XX }, 0 },
{ "rdpmc", { XX }, 0 },
{ "sysenter", { SEP }, 0 },
- { "sysexit", { SEP }, 0 },
+ { "sysexit%LQ", { SEP }, 0 },
{ Bad_Opcode },
{ "getsec", { XX }, 0 },
/* 38 */
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -877,7 +877,7 @@ cmpxchg8b, 0xfc7, 0x1, 2, Cpu586, Modrm|
// 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 }
More information about the Binutils
mailing list