Bug 290655 - Add support for AESKEYGENASSIST instruction
Summary: Add support for AESKEYGENASSIST instruction
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.7 SVN
Platform: Compiled Sources macOS
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
: 293751 294617 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-01-05 01:47 UTC by Matt Woodrow
Modified: 2012-05-09 22:31 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Full log (42.24 KB, text/plain)
2012-01-05 01:47 UTC, Matt Woodrow
Details
patch implementing the 6 AES instructions. (42.80 KB, text/plain)
2012-02-13 21:29 UTC, Philippe Waroquiers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Woodrow 2012-01-05 01:47:43 UTC
Created attachment 67472 [details]
Full log

Version:           3.7 SVN
OS:                OS X

Valgrind crashes when trying to run firefox on OSX 10.7 using a sandy bridge Core i7.

Error message is: 
vex amd64->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0xDF 0xD1 0x1 0xE8 0x6A

which I believe is the AESKEYGENASSIST instruction.

Reproducible: Always

Steps to Reproduce:
Run firefox through valgrind as 'valgrind ./firefox -p test' with a CPU that supports this instruction.


Expected Results:
Comment 1 Tom Hughes 2012-02-10 09:46:11 UTC
*** Bug 293751 has been marked as a duplicate of this bug. ***
Comment 2 Philippe Waroquiers 2012-02-13 21:29:50 UTC
Created attachment 68775 [details]
patch implementing the 6 AES instructions.

Patch includes a test verifying explicitely some values
+ produces a bunch of values that are compared with a native run.

However, before I commit, it would be nice if some validation could be done
using a real application using AES instructions (e.g. firefox on OSX 10.7).
(I cannot test this myself).
Comment 3 Don W 2012-02-13 22:56:12 UTC
I applied this patch to a fresh checkout from SVN (Rev 12382), but wasn't able to build.  I'm probably doing something wrong.

I did:
patch -p0 < ~patch.diff
./autogen.sh
./configure
./make

Got:

Undefined symbols for architecture x86_64:
  "_amd64g_dirtyhelper_AES", referenced from:
      _dis_ESC_0F38__SSE4 in libvex-amd64-darwin.a(libvex_amd64_darwin_a-guest_amd64_toIR.o)
  "_amd64g_dirtyhelper_AESKEYGENASSIST", referenced from:
      _dis_ESC_0F3A__SSE4 in libvex-amd64-darwin.a(libvex_amd64_darwin_a-guest_amd64_toIR.o)
ld: symbol(s) not found for architecture x86_64
Comment 4 Julian Seward 2012-02-14 09:56:02 UTC
(In reply to comment #3)
> I applied this patch to a fresh checkout from SVN (Rev 12382), but wasn't able
> to build.  I'm probably doing something wrong.

I am surprised to hear this.  The patch at least looks like it should
work as-is.  Did it apply cleanly?
Comment 5 Don W 2012-02-14 18:17:18 UTC
There was one problem with the patch, but it didn't look like it would cause the problem.

patching file none/tests/amd64/Makefile.am
Hunk #1 FAILED at 21.
Hunk #2 succeeded at 93 with fuzz 2 (offset 1 line).
1 out of 2 hunks FAILED -- saving rejects to file none/tests/amd64/Makefile.am.rej

I deleted everything from svn and updated again, patched and built with the same steps as above.  Got the same result.
Comment 6 Julian Seward 2012-02-14 18:37:33 UTC
(In reply to comment #5)
> There was one problem with the patch, but it didn't look like it would cause
> the problem.
> 
> patching file none/tests/amd64/Makefile.am
> Hunk #1 FAILED at 21.

Uh .. what if this hunk contained the function which the linker
complained is missing?
Comment 7 Don W 2012-02-14 18:49:44 UTC
I thought it was just the test output in that Makefile that didn't get added, but yeah, it looks like maybe the function definition was in the patch after all... 

Downloaded the patch again, and it applied cleanly.  Sorry for the mess up.

Testing now...
Comment 8 Don W 2012-02-14 19:13:48 UTC
Ok, looks like it works in the case of TextEdit.app (my previous control case).  

For my own app, I still get the unhanded instruction message:

vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0xDF

Could this be because my app is being compiled 32 bit?

I also tried against firefox, and the original problem didn't manifest though the app did seem to crash for other reasons when running under valgrind.
Comment 9 Julian Seward 2012-02-14 19:18:32 UTC
> vex x86->IR: unhandled instruction bytes: 0x66 0xF 0x3A 0xDF
> 
> Could this be because my app is being compiled 32 bit?

Yes.  SSE4 and above isn't supported in 32-bit mode, only in 64-bit mode.
Comment 10 Philippe Waroquiers 2012-02-14 21:40:58 UTC
Fixed in revision 12384 and VEX revision 2247
Comment 11 Jan Wassenberg 2012-02-15 06:05:25 UTC
Verified with an in-house app running on OSX 10.7.3. Thanks!
Comment 12 Tom Hughes 2012-02-22 15:04:48 UTC
*** Bug 294617 has been marked as a duplicate of this bug. ***
Comment 13 nils_heidorn 2012-03-29 10:03:03 UTC
Hi !
I encountered the same Problem but for me it is not fixed...
I checked out from SVN trunk and i saw that the patches were included, GREAT !

But: i have to build my app in 32 Bit and i have to force valgrind build to 32 build as well ( --enable-only32bit ).

As i found out the hard way the patches apply only to the amd64 platform, not to plain x86.

Is there any chance that you / someone can extend the patch to the 32 Bit world as well ?

That would be GREAT !

Greetings,  

Nils
Comment 14 Philippe Waroquiers 2012-03-29 22:20:52 UTC
(In reply to comment #13)
> As i found out the hard way the patches apply only to the amd64 platform,
> not to plain x86.
> 
> Is there any chance that you / someone can extend the patch to the 32 Bit
> world as well ?
I just checked the behaviour of aes instructions in 32 bits mode.
They are the same as in 64 bits mode. So, the "aes" logic should be re-usable as such.

However, I understand that the aes instructions are part of the sse 4.2, which
is not at all supported in Valgrind 32 bits.
So, not clear to me if supporting aes instructions only in 32 bits is
1. easy to do ? (i.e. can we easily only add the decoding of aes instructions)
2. useful ? (as enabling gcc sse4.2 will enable aes, but I guess also plenty of other
   not supported by Valgrind in 32 bits sse 4.2 instructions.

Philippe