Skip to content

Commit

Permalink
Fixed several of Nathan's reported issues including #193
Browse files Browse the repository at this point in the history
  • Loading branch information
John Detter committed Nov 7, 2016
1 parent a79ba00 commit ff68cf0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions common/h/entryIDs.h
Expand Up @@ -612,6 +612,7 @@ enum entryID {
e_vblendvps,
e_vblendvpd,
e_vpblendmw,
e_vpblendmd,
e_vpblendmb,
e_vpblendvb,
e_vcmppd,
Expand Down
39 changes: 32 additions & 7 deletions common/src/arch-x86.C
Expand Up @@ -248,7 +248,7 @@ SSEB00 = 0, SSEB01, SSEB02, SSEB03, SSEB04, SSEB05, SSEB06, SSEB07,
SSEB40, SSEB41, SSEB42, SSEB43, SSEB44, SSEB45, SSEB46, SSEB47,
SSEB4C, SSEB4D, SSEB4E, SSEB4F,
SSEB58, SSEB59, SSEB5A,
SSEB65, SSEB66,
SSEB64, SSEB65, SSEB66,
SSEB75, SSEB76, SSEB77,
SSEB78, SSEB79, SSEB7C, SSEB7D, SSEB7E, SSEB7F,
SSEB83,
Expand Down Expand Up @@ -336,6 +336,7 @@ enum { /** AUTOGENERATED */
SSEB4D_66,
SSEB4E_66,
SSEB4F_66,
SSEB64_66,
SSEB65_66,
SSEB66_66,
SSEB75_66,
Expand Down Expand Up @@ -1356,6 +1357,7 @@ COMMON_EXPORT dyn_hash_map<entryID, std::string> entryNames_IAPI = map_list_of
(e_vblendvps, "vblendvps")
(e_vblendvpd, "vblendvpd")
(e_vpblendmb, "vpblendmb")
(e_vpblendmd, "vpblendmd")
(e_vpblendmw, "vpblendmw")
(e_vpblendvb, "vpblendvb")
(e_vcmppd, "vcmppd")
Expand Down Expand Up @@ -2801,12 +2803,12 @@ static ia32_entry threeByteMap[256] = {
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
/* 65 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
/* 60 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_sse_bis, SSEB64, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_sse_bis, SSEB65, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_sse_bis, SSEB66, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
Expand Down Expand Up @@ -3633,7 +3635,7 @@ static ia32_entry groupMap2[][2][8] = {
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_grpsse, G12SSE100B, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
Expand Down Expand Up @@ -3949,7 +3951,7 @@ static ia32_entry sseMap[][4] = {
{ e_movntsd, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R | (fNT << FPOS) },
},
{ /* SSE2C */
{ e_cvttps2pi, t_done, 0, true, { Qq, Wps, Zz }, 0, s1W2R },
{ e_cvttps2pi, t_done, 0, true, { Pq, Wps, Zz }, 0, s1W2R },
{ e_cvttss2si, t_sse_mult, SSE2C_F3, true, { Gv, Wss, Zz }, 0, s1W2R },
{ e_cvttpd2pi, t_done, 0, true, { Qdq, Wpd, Zz }, 0, s1W2R },
{ e_cvttsd2si, t_sse_mult, SSE2C_F2, true, { Gv, Wsd, Zz }, 0, s1W2R },
Expand Down Expand Up @@ -5148,6 +5150,12 @@ static ia32_entry sseMapBis[][5] = {
{ e_vbroadcastf128, t_done, 0, true, { Vsd, Wq, Zz }, 0, s1W2R },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
}, { /* SSEB64 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_sse_bis_mult, SSEB64_66, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
}, { /* SSEB65 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
Expand Down Expand Up @@ -7044,6 +7052,10 @@ ia32_entry sseMapBisMult[][3] =
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_vexw, VEXW89, false, { Zz, Zz, Zz }, 0, 0 }
}, { /* SSEB65_66 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_vpblendmd, t_done, 0, true, { Vpd, Hpd, Wpd }, 0, s1RW2R3R },
}, { /* SSEB65_66 */
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
{ e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
Expand Down Expand Up @@ -7656,7 +7668,7 @@ static ia32_entry ssegrpMap_VEX[][2] = {
/* G12SSE100B */
{
{ e_vpsraw, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
{ e_vpsraw, t_done, 0, true, { Pdq, Ib, Zz }, 0, s1RW2R }
{ e_vpsraw, t_done, 0, true, { Vps, Wps, Ib }, 0, s1RW2R }
},
/* G12SSE110B */
{
Expand Down Expand Up @@ -8293,6 +8305,7 @@ ia32_instruction& ia32_decode(unsigned int capa, const unsigned char* addr, ia32
/* First decode any prefixes for this instruction */
if (!ia32_decode_prefixes(addr, instruct))
{
fprintf(stderr, "PREFIX DECODE FAILURE.\n");
instruct.size = 1;
instruct.entry = NULL;
instruct.legacy_type = ILLEGAL;
Expand Down Expand Up @@ -10042,6 +10055,12 @@ bool ia32_decode_prefixes(const unsigned char* addr, ia32_instruction& instruct)
pref.vex_present = true;
pref.vex_type = VEX_TYPE_EVEX;
memmove(&pref.vex_prefix, addr + 1, 3);
#ifdef VEX_DEBUG
printf("EVEX PREFIX: 0x%x 0x%x 0x%x\n",
pref.vex_prefix[0],
pref.vex_prefix[1],
pref.vex_prefix[2]);
#endif
pref.vex_sse_mult = 2;
pref.vex_vvvv_reg = EVEXGET_VVVV(pref.vex_prefix[1], pref.vex_prefix[2]);
pref.vex_ll = EVEXGET_LL(pref.vex_prefix[2]);
Expand All @@ -10059,6 +10078,9 @@ bool ia32_decode_prefixes(const unsigned char* addr, ia32_instruction& instruct)
/* VEX_LL must be 0, 1, or 2 */
if(pref.vex_ll >= 3 || pref.vex_ll < 0)
{
#ifdef VEX_DEBUG
printf("VEX PREFIX LL Invalid: %d\n", pref.vex_ll);
#endif
err = true;
break;
}
Expand Down Expand Up @@ -10086,7 +10108,10 @@ bool ia32_decode_prefixes(const unsigned char* addr, ia32_instruction& instruct)
|| ((pref.vex_prefix[1] & (unsigned int)(1 << 2)) == 0))
{
#ifdef VEX_DEBUG
printf("EVEX PREFIX INVALID!\n");
printf("EVEX PREFIX INVALID! 0x%x 0x%x 0x%x != 0 || 0x%x != 1\n",
pref.vex_prefix[0], pref.vex_prefix[1],
pref.vex_prefix[0] & (unsigned int)(0x03 << 2),
pref.vex_prefix[1] & (unsigned int)(1 << 2));
#endif
err = true;
break;
Expand Down

0 comments on commit ff68cf0

Please sign in to comment.