This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fix disassembly of spurious REX prefix before FWAIT


On Wed, Oct 24, 2012 at 3:32 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> Have you verified that REX is ignored in hardware?

I've verified that the REX prefix is part of the FWAIT instruction rather
than the FNSAVE instruction (FSAVE is shorthand for FWAIT;FNSAVE).  I can't
tell what it would mean for the REX prefix to be used or not by FWAIT.  I
don't know how to test that FWAIT actually does its work when it has a REX
prefix.  It's certainly the case that single-step at REX FWAIT leaves the
PC after the FWAIT (at the FNSAVE) just like single-step at plain FWAIT does.

> Please put the new tests in rex.s.
[...]
> Please use "fsave  (%r8)" instead.

Done.


Thanks,
Roland


gas/testsuite/
2012-10-24  Roland McGrath  <mcgrathr@google.com>

	* gas/i386/rex.s: Add test of REX prefix before fsave (i.e. fwait).
	* gas/i386/rex.d: Update.

opcodes/
2012-10-24  Roland McGrath  <mcgrathr@google.com>

	* i386-dis.c (ckprefix): When bailing out for fwait with prefixes,
	set rex_used to rex.


diff --git a/gas/testsuite/gas/i386/ilp32/rex.d
b/gas/testsuite/gas/i386/ilp32/rex.d
index 50eb22c..7c704c9 100644
--- a/gas/testsuite/gas/i386/ilp32/rex.d
+++ b/gas/testsuite/gas/i386/ilp32/rex.d
@@ -15,6 +15,9 @@ Disassembly of section .text:
 [	 ]*[0-9a-f]+:[	 ]+4a 0f ae 04 05 00 00 00 00[	 ]+fxsave64[	
]+(0x0)?\(,%r8(,1)?\)
 [	 ]*[0-9a-f]+:[	 ]+43 0f ae 04 00[	 ]+fxsave[	 ]+\(%r8,%r8(,1)?\)
 [	 ]*[0-9a-f]+:[	 ]+4b 0f ae 04 00[	 ]+fxsave64[	 ]+\(%r8,%r8(,1)?\)
+[	 ]*[0-9a-f]+:[	 ]+41\s+rex\.B
+[	 ]*[0-9a-f]+:[	 ]+9b dd 30\s+fsave\s+\(%rax\)
+[	 ]*[0-9a-f]+:[	 ]+9b 41 dd 30\s+fsave\s+\(%r8\)
 [	 ]*[0-9a-f]+:[	 ]+40 c5 f9 28 00[	 ]+rex vmovapd \(%rax\),%xmm0
 [	 ]*[0-9a-f]+:[	 ]+40[	 ]+rex
 [	 ]*[0-9a-f]+:[	 ]+41[	 ]+rex.B
diff --git a/gas/testsuite/gas/i386/rex.d b/gas/testsuite/gas/i386/rex.d
index 3548ff2..bf783c6 100644
--- a/gas/testsuite/gas/i386/rex.d
+++ b/gas/testsuite/gas/i386/rex.d
@@ -14,6 +14,9 @@ Disassembly of section .text:
 [	 ]*[0-9a-f]+:[	 ]+4a 0f ae 04 05 00 00 00 00[	 ]+fxsave64[	
]+(0x0)?\(,%r8(,1)?\)
 [	 ]*[0-9a-f]+:[	 ]+43 0f ae 04 00[	 ]+fxsave[	 ]+\(%r8,%r8(,1)?\)
 [	 ]*[0-9a-f]+:[	 ]+4b 0f ae 04 00[	 ]+fxsave64[	 ]+\(%r8,%r8(,1)?\)
+[	 ]*[0-9a-f]+:[	 ]+41\s+rex\.B
+[	 ]*[0-9a-f]+:[	 ]+9b dd 30\s+fsave\s+\(%rax\)
+[	 ]*[0-9a-f]+:[	 ]+9b 41 dd 30\s+fsave\s+\(%r8\)
 [	 ]*[0-9a-f]+:[	 ]+40 c5 f9 28 00[	 ]+rex vmovapd \(%rax\),%xmm0
 [	 ]*[0-9a-f]+:[	 ]+40[	 ]+rex
 [	 ]*[0-9a-f]+:[	 ]+41[	 ]+rex.B
diff --git a/gas/testsuite/gas/i386/rex.s b/gas/testsuite/gas/i386/rex.s
index 055edb7..004b9b8 100644
--- a/gas/testsuite/gas/i386/rex.s
+++ b/gas/testsuite/gas/i386/rex.s
@@ -10,6 +10,9 @@ _start:
 	rex/fxsave (%r8,%r8)
 	rex64/fxsave (%r8,%r8)

+	.byte 0x41,0x9b,0xdd,0x30
+	fsave (%r8)
+
 	.byte 0x40
 	vmovapd (%rax),%xmm0

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 15c968a..f8e62aa 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -10756,6 +10756,9 @@ ckprefix (void)
 	    {
 	      prefixes |= PREFIX_FWAIT;
 	      codep++;
+	      /* This ensures that the previous REX prefixes are noticed
+		 as unused prefixes, as in the return case below.  */
+	      rex_used = rex;
 	      return 1;
 	    }
 	  prefixes = PREFIX_FWAIT;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]