intelxed / xed

The X86 Encoder Decoder (XED), is a software library for encoding and decoding X86 (IA32 and Intel64) instructions
https://intelxed.github.io/
Apache License 2.0
1.38k stars 146 forks source link

False negatives with decoding bytes #284

Closed jposwiata closed 3 months ago

jposwiata commented 2 years ago

During testing SIGILL I found several instruction which should fail (expected behaviour) don't cause any handling (or SEGV). I noticed, that these instructions are incorrectly decoded by XED, while valid in other decoders/gdb.

0f 01 f8 // GENERAL_ERROR: swapgs f3 0f ae d8 // GENERAL_ERROR: wrgsbase eax f3 0f ae dc //GENERAL_ERROR: wrgsbase esp

65 62 d1 cd 46 dd ec // BAD_EVEX_V_PRIME: gs vpaddusw zmm5{k6},zmm22,zmm12
c4 c2 09 90 74 c1 2c // GATHER_REGS:: vpgatherdd xmm6,DWORD PTR [r9+xmm0*8+0x2c],xmm14

62 c1 1d c2 db 0e // BAD_EVEX_V_PRIME: vpandd zmm17{k2}{z},zmm28,ZMMWORD PTR [r14] 62 c1 25 01 e2 d1 // BAD_EVEX_V_PRIME: vpsrad xmm18{k1},xmm27,xmm9

(and many more, mostly with 62 prefix) I can provide longer list.

marjevan commented 2 years ago

Hi, Did you set the decode request to 64bit mode?

This is the decoder output using the xed.c example:

$ xed.exe -64 -d 62 c1 1d c2 db 0e
62C11DC2DB0E
ICLASS:     VPANDD
CATEGORY:   LOGICAL
EXTENSION:  AVX512EVEX
IFORM:      VPANDD_ZMMu32_MASKmskw_ZMMu32_MEMu32_AVX512
ISA_SET:    AVX512F_512
ATTRIBUTES: BROADCAST_ENABLED DISP8_FULL MASKOP_EVEX MEMORY_FAULT_SUPPRESSION
SHORT:      vpandd zmm17{k2}{z}, zmm28, zmmword ptr [r14]