Bug 366237 - pextrw - Unrecoginzed instruction
Summary: pextrw - Unrecoginzed instruction
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: vex (show other bugs)
Version: 3.12 SVN
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-29 09:57 UTC by Vasiliy Olekhov
Modified: 2016-09-15 10:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
sample project (766 bytes, application/x-bzip)
2016-07-29 09:57 UTC, Vasiliy Olekhov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vasiliy Olekhov 2016-07-29 09:57:13 UTC
Created attachment 100373 [details]
sample project

valgrind complains about unrecognized instruction, generated by NASM assembler.
A sample project is attached.

YASM and NASM  generate different instructions:

Yasm listing:
     1                                 %line 1+1 test_pextrw.nas
     2                                 [bits 64]
     3                                 [default rel]
     4
     5                                 [section .text align=16]
     6
     7                                 [global test_pextrw]
     8                                 test_pextrw:
     9 00000000 0F1007                  movups xmm0, [rdi]
    10 00000003 66480FC5C000            pextrw rax, xmm0, 0
    11 00000009 C3                      ret
    12

nasm listing:
     1                                  [bits 64]
     2                                  [default rel]
     3
     4                                  [section .text align=16]
     5
     6                                  [global test_pextrw]
     7                                  test_pextrw:
     8 00000000 0F1007                    movups xmm0, [rdi]
     9 00000003 66480F3A15C000            pextrw rax, xmm0, 0
    10 0000000A C3                        ret
    11


NASM  2.12.02rc7 (latest rc)
yasm 1.3.0.28.g51af (current git)
valgrind-3.12.0.SVN (current svn)

yasm generates instruction that executes on Intel Celeron E3400
nasm's instruction causes "illegal hardware instruction" exception on Celeron E3400

both versions work on Core i7-4770S

This might be a bug in nasm.
I'll report to the nasm team too.

valgrind error messages on nasm version:

vex amd64->IR: unhandled instruction bytes: 0x66 0x48 0xF 0x3A 0x15 0xC0 0x0 0xC3 0x90 0x90
vex amd64->IR:   REX=1 REX.W=1 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=0F3A
vex amd64->IR:   PFX.66=1 PFX.F2=0 PFX.F3=0
==6168== valgrind: Unrecognised instruction at address 0x400583.
==6168==    at 0x400583: ??? (test_pextrw.nas:9)
==6168==    by 0x4E4FCDC: (below main) (in /lib64/libc-2.12.so)
==6168== 1. Your program has a bug and erroneously jumped to a non-code
==6168==    location.  If you are running Memcheck and you just saw a
==6168==    warning about a bad jump, it's probably your program's fault.
==6168== 2. The instruction is legitimate but Valgrind doesn't handle it,
==6168==    i.e. it's Valgrind's fault.  If you think this is the case or
==6168==    you are not sure, please let us know and we'll try to fix it.
==6168== Either way, Valgrind will now raise a SIGILL signal which will
==6168== probably kill your program.
==6168==
==6168== Process terminating with default action of signal 4 (SIGILL)
==6168==  Illegal opcode at address 0x400583
==6168==    at 0x400583: ??? (test_pextrw.nas:9)
==6168==    by 0x4E4FCDC: (below main) (in /lib64/libc-2.12.so)

code produced by yasm works under valgrind without errors.
Comment 1 Vasiliy Olekhov 2016-07-29 10:05:36 UTC
It seems that nasm generates SSE4_1 version, which is not supported on Celeron E3400
Comment 2 Julian Seward 2016-09-15 06:08:30 UTC
This is confusing.  I think what you are saying is: the nasm version doesn't
work either directly, or via valgrind, on Celeron E3400.  Correct?

In which case I don't think this is a bug in Valgrind.  I will close this now.
But feel free to reopen if you have more information.
Comment 3 Vasiliy Olekhov 2016-09-15 10:46:35 UTC
Let me rephrase.

valgrind complains about instruction with opcode 
66480F3A15C000 
This is pretty valid PEXTRW instruction, SSE4_1 variant.

valgrind does not complain about other flavor of PEXTRW instruction, that has opcode
66480FC5C000