Skip to content

Commit

Permalink
Fix VEX-encoded AES instruction operand sizes. (#7135)
Browse files Browse the repository at this point in the history
These instructions do accept VEX.L.
  • Loading branch information
khuey authored Dec 16, 2024
1 parent eb4a4b8 commit 8afe9a3
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 106 deletions.
2 changes: 2 additions & 0 deletions api/docs/release.dox
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ Further non-compatibility-affecting changes include:
on the 32/64 bit mode and the presence or absence of the address size prefix.
- Fixed the order of operands for the vpexpandd/vpexpandq opcodes (previously the
source and destination operands were reversed).
- Fixed the VEX-encoded forms of vaesdec/vaesdeclast/vaesenc/vaesenclast/vpclmulqdq
to obey VEX.L, which they previously ignored.

**************************************************
<hr>
Expand Down
10 changes: 5 additions & 5 deletions core/ir/x86/decode_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -6159,19 +6159,19 @@ const instr_info_t e_vex_extensions[][3] = {
{INVALID, 0x6638db18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 32 */
{OP_aesenc, 0x6638dc18, catSIMD, "aesenc", Vdq, xx, Wdq,Vdq, xx, mrm|reqp, x, END_LIST},
{OP_vaesenc, 0x6638dc18, catSIMD, "vaesenc", Vdq, xx, Hdq,Wdq, xx, mrm|vex|reqp, x, END_LIST},
{OP_vaesenc, 0x6638dc18, catSIMD, "vaesenc", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638dc18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 33 */
{OP_aesenclast, 0x6638dd18, catSIMD, "aesenclast",Vdq,xx,Wdq,Vdq,xx, mrm|reqp, x, END_LIST},
{OP_vaesenclast, 0x6638dd18, catSIMD, "vaesenclast",Vdq,xx,Hdq,Wdq,xx, mrm|vex|reqp, x, END_LIST},
{OP_vaesenclast, 0x6638dd18, catSIMD, "vaesenclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638dd18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 34 */
{OP_aesdec, 0x6638de18, catSIMD, "aesdec", Vdq, xx, Wdq,Vdq, xx, mrm|reqp, x, END_LIST},
{OP_vaesdec, 0x6638de18, catSIMD, "vaesdec", Vdq, xx, Hdq,Wdq, xx, mrm|vex|reqp, x, END_LIST},
{OP_vaesdec, 0x6638de18, catSIMD, "vaesdec", Vx, xx, Hx,Wx, xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638de18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 35 */
{OP_aesdeclast, 0x6638df18, catSIMD, "aesdeclast",Vdq,xx,Wdq,Vdq,xx, mrm|reqp, x, END_LIST},
{OP_vaesdeclast, 0x6638df18, catSIMD, "vaesdeclast",Vdq,xx,Hdq,Wdq,xx, mrm|vex|reqp, x, END_LIST},
{OP_vaesdeclast, 0x6638df18, catSIMD, "vaesdeclast",Vx,xx,Hx,Wx,xx, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x6638df18, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 36 */
{OP_pextrb, 0x663a1418, catSIMD, "pextrb", Rd_Mb, xx, Vb_dq, Ib, xx, mrm|reqp, x, END_LIST},
Expand Down Expand Up @@ -6260,7 +6260,7 @@ const instr_info_t e_vex_extensions[][3] = {
{INVALID, 0x663a6318, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 57 */
{OP_pclmulqdq, 0x663a4418, catSIMD, "pclmulqdq", Vdq, xx, Wdq, Ib, Vdq, mrm|reqp, x, END_LIST},
{OP_vpclmulqdq,0x663a4418, catSIMD, "vpclmulqdq", Vdq, xx, Hdq, Wdq, Ib, mrm|vex|reqp, x, END_LIST},
{OP_vpclmulqdq,0x663a4418, catSIMD, "vpclmulqdq", Vx, xx, Hx, Wx, Ib, mrm|vex|reqp, x, END_LIST},
{INVALID, 0x663a4418, catUncategorized, "(bad)", xx, xx, xx, xx, xx, no, x, NA},
}, { /* e_vex ext 58 */
{OP_aeskeygenassist, 0x663adf18, catSIMD, "aeskeygenassist",Vdq,xx,Wdq,Ib,xx,mrm|reqp,x,END_LIST},
Expand Down
58 changes: 54 additions & 4 deletions suite/tests/api/ir_x86_3args.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,62 @@ OPCODE(vpmaxsd, vpmaxsd, vpmaxsd, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16)
OPCODE(vpmaxuw, vpmaxuw, vpmaxuw, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vpmaxud, vpmaxud, vpmaxud, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vpmulld, vpmulld, vpmulld, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vaesenc, vaesenc, vaesenc, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vaesenclast, vaesenclast, vaesenclast, 0, REGARG(XMM0), REGARG(XMM1),
OPCODE(vaesenc_xloxloxlo, vaesenc, vaesenc, 0, REGARG(XMM0), REGARG(XMM1), REGARG(XMM2))
OPCODE(vaesenc_xloxlold, vaesenc, vaesenc, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vaesenc_xhixhixhi, vaesenc, vaesenc, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
REGARG(XMM15))
OPCODE(vaesenc_xhixhild, vaesenc, vaesenc, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
MEMARG(OPSZ_16))
OPCODE(vaesdec, vaesdec, vaesdec, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vaesdeclast, vaesdeclast, vaesdeclast, 0, REGARG(XMM0), REGARG(XMM1),
OPCODE(vaesenc_yloyloylo, vaesenc, vaesenc, 0, REGARG(YMM0), REGARG(YMM1), REGARG(YMM2))
OPCODE(vaesenc_yloylold, vaesenc, vaesenc, 0, REGARG(YMM0), REGARG(YMM1), MEMARG(OPSZ_32))
OPCODE(vaesenc_yhiyhiyhi, vaesenc, vaesenc, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
REGARG(YMM15))
OPCODE(vaesenc_yhiyhild, vaesenc, vaesenc, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
MEMARG(OPSZ_32))
OPCODE(vaesenclast_xloxloxlo, vaesenclast, vaesenclast, 0, REGARG(XMM0), REGARG(XMM1),
REGARG(XMM2))
OPCODE(vaesenclast_xloxlold, vaesenclast, vaesenclast, 0, REGARG(XMM0), REGARG(XMM1),
MEMARG(OPSZ_16))
OPCODE(vaesenclast_xhixhixhi, vaesenclast, vaesenclast, X64_ONLY, REGARG(XMM8),
REGARG(XMM9), REGARG(XMM15))
OPCODE(vaesenclast_xhixhild, vaesenclast, vaesenclast, X64_ONLY, REGARG(XMM8),
REGARG(XMM9), MEMARG(OPSZ_16))
OPCODE(vaesenclast_yloyloylo, vaesenclast, vaesenclast, 0, REGARG(YMM0), REGARG(YMM1),
REGARG(YMM2))
OPCODE(vaesenclast_yloylold, vaesenclast, vaesenclast, 0, REGARG(YMM0), REGARG(YMM1),
MEMARG(OPSZ_32))
OPCODE(vaesenclast_yhiyhiyhi, vaesenclast, vaesenclast, X64_ONLY, REGARG(YMM8),
REGARG(YMM9), REGARG(YMM15))
OPCODE(vaesenclast_yhiyhild, vaesenclast, vaesenclast, X64_ONLY, REGARG(YMM8),
REGARG(YMM9), MEMARG(OPSZ_32))
OPCODE(vaesdec_xloxloxlo, vaesdec, vaesdec, 0, REGARG(XMM0), REGARG(XMM1), REGARG(XMM2))
OPCODE(vaesdec_xloxlold, vaesdec, vaesdec, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16))
OPCODE(vaesdec_xhixhixlo, vaesdec, vaesdec, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
REGARG(XMM15))
OPCODE(vaesdec_xhixhild, vaesdec, vaesdec, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
MEMARG(OPSZ_16))
OPCODE(vaesdec_yloyloylo, vaesdec, vaesdec, 0, REGARG(YMM0), REGARG(YMM1), REGARG(YMM2))
OPCODE(vaesdec_yloylold, vaesdec, vaesdec, 0, REGARG(YMM0), REGARG(YMM1), MEMARG(OPSZ_32))
OPCODE(vaesdec_yhiyhiylo, vaesdec, vaesdec, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
REGARG(YMM15))
OPCODE(vaesdec_yhiyhild, vaesdec, vaesdec, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
MEMARG(OPSZ_32))
OPCODE(vaesdeclast_xloxloxlo, vaesdeclast, vaesdeclast, 0, REGARG(XMM0), REGARG(XMM1),
REGARG(XMM2))
OPCODE(vaesdeclast_xloxlold, vaesdeclast, vaesdeclast, 0, REGARG(XMM0), REGARG(XMM1),
MEMARG(OPSZ_16))
OPCODE(vaesdeclast_xhixhixhi, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(XMM8),
REGARG(XMM9), REGARG(XMM15))
OPCODE(vaesdeclast_xhixhild, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(XMM8),
REGARG(XMM9), MEMARG(OPSZ_16))
OPCODE(vaesdeclast_yloyloylo, vaesdeclast, vaesdeclast, 0, REGARG(YMM0), REGARG(YMM1),
REGARG(YMM2))
OPCODE(vaesdeclast_yloylold, vaesdeclast, vaesdeclast, 0, REGARG(YMM0), REGARG(YMM1),
MEMARG(OPSZ_32))
OPCODE(vaesdeclast_yhiyhiyhi, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(YMM8),
REGARG(YMM9), REGARG(YMM15))
OPCODE(vaesdeclast_yhiyhild, vaesdeclast, vaesdeclast, X64_ONLY, REGARG(YMM8),
REGARG(YMM9), MEMARG(OPSZ_32))
OPCODE(vpextrb, vpextrb, vpextrb, 0, REGARG(EAX), REGARG_PARTIAL(XMM0, OPSZ_1),
IMMARG(OPSZ_1))
OPCODE(vpextrb_mem, vpextrb, vpextrb, 0, MEMARG(OPSZ_1), REGARG_PARTIAL(XMM0, OPSZ_1),
Expand Down
18 changes: 16 additions & 2 deletions suite/tests/api/ir_x86_4args.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,22 @@ OPCODE(vdppd, vdppd, vdppd, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16),
IMMARG(OPSZ_1))
OPCODE(vmpsadbw, vmpsadbw, vmpsadbw, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16),
IMMARG(OPSZ_1))
OPCODE(vpclmulqdq, vpclmulqdq, vpclmulqdq, 0, REGARG(XMM0), REGARG(XMM1), MEMARG(OPSZ_16),
IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_xloxloxlo, vpclmulqdq, vpclmulqdq, 0, REGARG(XMM0), REGARG(XMM1),
REGARG(XMM2), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_xloxlold, vpclmulqdq, vpclmulqdq, 0, REGARG(XMM0), REGARG(XMM1),
MEMARG(OPSZ_16), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_xhixhixhi, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
REGARG(XMM15), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_xhixhild, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(XMM8), REGARG(XMM9),
MEMARG(OPSZ_16), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_yloyloylo, vpclmulqdq, vpclmulqdq, 0, REGARG(YMM0), REGARG(YMM1),
REGARG(YMM2), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_yloylold, vpclmulqdq, vpclmulqdq, 0, REGARG(YMM0), REGARG(YMM1),
MEMARG(OPSZ_32), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_yhiyhiyhi, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
REGARG(YMM15), IMMARG(OPSZ_1))
OPCODE(vpclmulqdq_yhiyhild, vpclmulqdq, vpclmulqdq, X64_ONLY, REGARG(YMM8), REGARG(YMM9),
MEMARG(OPSZ_32), IMMARG(OPSZ_1))
OPCODE(vroundss, vroundss, vroundss, 0, REGARG(XMM0), REGARG_PARTIAL(XMM1, OPSZ_12),
MEMARG(OPSZ_4), IMMARG(OPSZ_1))
OPCODE(vroundsd, vroundsd, vroundsd, 0, REGARG(XMM0), REGARG_PARTIAL(XMM1, OPSZ_8),
Expand Down
52 changes: 26 additions & 26 deletions third_party/binutils/test_decenc/drdecode_decenc_x86.expect
Original file line number Diff line number Diff line change
Expand Up @@ -79758,26 +79758,26 @@ test_s:
90 nop
90 nop
90 nop
c4 e2 4d dc d4 vaesenc %xmm6, %xmm4, %xmm2
c4 e2 4d dc 39 vaesenc %xmm6, (%ecx), %xmm7
c4 e2 4d dd d4 vaesenclast %xmm6, %xmm4, %xmm2
c4 e2 4d dd 39 vaesenclast %xmm6, (%ecx), %xmm7
c4 e2 4d de d4 vaesdec %xmm6, %xmm4, %xmm2
c4 e2 4d de 39 vaesdec %xmm6, (%ecx), %xmm7
c4 e2 4d df d4 vaesdeclast %xmm6, %xmm4, %xmm2
c4 e2 4d df 39 vaesdeclast %xmm6, (%ecx), %xmm7
c4 e2 4d dc d4 vaesenc %xmm6, %xmm4, %xmm2
c4 e2 4d dc 39 vaesenc %xmm6, (%ecx), %xmm7
c4 e2 4d dc 39 vaesenc %xmm6, (%ecx), %xmm7
c4 e2 4d dd d4 vaesenclast %xmm6, %xmm4, %xmm2
c4 e2 4d dd 39 vaesenclast %xmm6, (%ecx), %xmm7
c4 e2 4d dd 39 vaesenclast %xmm6, (%ecx), %xmm7
c4 e2 4d de d4 vaesdec %xmm6, %xmm4, %xmm2
c4 e2 4d de 39 vaesdec %xmm6, (%ecx), %xmm7
c4 e2 4d de 39 vaesdec %xmm6, (%ecx), %xmm7
c4 e2 4d df d4 vaesdeclast %xmm6, %xmm4, %xmm2
c4 e2 4d df 39 vaesdeclast %xmm6, (%ecx), %xmm7
c4 e2 4d df 39 vaesdeclast %xmm6, (%ecx), %xmm7
c4 e2 4d dc d4 vaesenc %ymm6, %ymm4, %ymm2
c4 e2 4d dc 39 vaesenc %ymm6, (%ecx), %ymm7
c4 e2 4d dd d4 vaesenclast %ymm6, %ymm4, %ymm2
c4 e2 4d dd 39 vaesenclast %ymm6, (%ecx), %ymm7
c4 e2 4d de d4 vaesdec %ymm6, %ymm4, %ymm2
c4 e2 4d de 39 vaesdec %ymm6, (%ecx), %ymm7
c4 e2 4d df d4 vaesdeclast %ymm6, %ymm4, %ymm2
c4 e2 4d df 39 vaesdeclast %ymm6, (%ecx), %ymm7
c4 e2 4d dc d4 vaesenc %ymm6, %ymm4, %ymm2
c4 e2 4d dc 39 vaesenc %ymm6, (%ecx), %ymm7
c4 e2 4d dc 39 vaesenc %ymm6, (%ecx), %ymm7
c4 e2 4d dd d4 vaesenclast %ymm6, %ymm4, %ymm2
c4 e2 4d dd 39 vaesenclast %ymm6, (%ecx), %ymm7
c4 e2 4d dd 39 vaesenclast %ymm6, (%ecx), %ymm7
c4 e2 4d de d4 vaesdec %ymm6, %ymm4, %ymm2
c4 e2 4d de 39 vaesdec %ymm6, (%ecx), %ymm7
c4 e2 4d de 39 vaesdec %ymm6, (%ecx), %ymm7
c4 e2 4d df d4 vaesdeclast %ymm6, %ymm4, %ymm2
c4 e2 4d df 39 vaesdeclast %ymm6, (%ecx), %ymm7
c4 e2 4d df 39 vaesdeclast %ymm6, (%ecx), %ymm7
90 nop
90 nop
90 nop
Expand Down Expand Up @@ -79873,15 +79873,15 @@ test_s:
90 nop
90 nop
90 nop
c4 e3 55 44 f4 ab vpclmulqdq %xmm5, %xmm4, $0xab, %xmm6
c4 e3 55 44 b4 f4 c0 vpclmulqdq %xmm5, -0x0001e240(%esp,%esi,8), $0x7b, %xmm6
c4 e3 55 44 f4 ab vpclmulqdq %ymm5, %ymm4, $0xab, %ymm6
c4 e3 55 44 b4 f4 c0 vpclmulqdq %ymm5, -0x0001e240(%esp,%esi,8), $0x7b, %ymm6
1d fe ff 7b
c4 e3 55 44 b2 e0 0f vpclmulqdq %xmm5, 0x00000fe0(%edx), $0x7b, %xmm6
c4 e3 55 44 b2 e0 0f vpclmulqdq %ymm5, 0x00000fe0(%edx), $0x7b, %ymm6
00 00 7b
c4 e3 55 44 f4 ab vpclmulqdq %xmm5, %xmm4, $0xab, %xmm6
c4 e3 55 44 b4 f4 c0 vpclmulqdq %xmm5, -0x0001e240(%esp,%esi,8), $0x7b, %xmm6
c4 e3 55 44 f4 ab vpclmulqdq %ymm5, %ymm4, $0xab, %ymm6
c4 e3 55 44 b4 f4 c0 vpclmulqdq %ymm5, -0x0001e240(%esp,%esi,8), $0x7b, %ymm6
1d fe ff 7b
c4 e3 55 44 b2 e0 0f vpclmulqdq %xmm5, 0x00000fe0(%edx), $0x7b, %xmm6
c4 e3 55 44 b2 e0 0f vpclmulqdq %ymm5, 0x00000fe0(%edx), $0x7b, %ymm6
00 00 7b
90 nop
90 nop
Expand Down
Loading

0 comments on commit 8afe9a3

Please sign in to comment.