From 18897deb534373660e12511aeabbc1885d942dae Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 9 Jun 2020 08:57:55 +0200 Subject: [PATCH] x86: fix {,V}MOV{L,H}PD disassembly Neither the legacy nor the VEX-encoded forms are permitted with register operands, just like is already the case for their store forms as well as {,V}MOV{L,H}PS. At the same time, besides folding respective vex_len_table[] entries, adjust adjacent related legacy mod_table[] entries: - when the prefix was already decoded, PREFIX_OPCODE is pointless, - limit the amount of string literals by using X consistently on all {,V}MOV{L,H}P{S,D} forms. --- opcodes/ChangeLog | 15 +++++++++++++ opcodes/i386-dis.c | 56 +++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index dcfa7616c3c..c6f1d2691e6 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,18 @@ +2020-06-09 Jan Beulich + + * i386-dis.c (MOD_0F12_PREFIX_2, MOD_0F16_PREFIX_2, + MOD_VEX_0F12_PREFIX_2, MOD_VEX_0F16_PREFIX_2): New enumerators. + (VEX_LEN_0F12_P_2, VEX_LEN_0F16_P_2): Delete. + (VEX_LEN_0F12_P_2_M_0, VEX_LEN_0F16_P_2_M_0): Define. + (prefix_table): Decode MOD for cases 2 of opcodes 0F12, 0F16, + VEX_0F12, and VEX_0F16. + (vex_len_table): Use X for vmovlp* and vmovh*s. Drop + VEX_LEN_0F12_P_2 and VEX_LEN_0F16_P_2 entries. + (mod_table): Use X for movlpX and movhpX. Drop PREFIX_OPCODE + from movlps and movhlps. New MOD_0F12_PREFIX_2, + MOD_0F16_PREFIX_2, MOD_VEX_0F12_PREFIX_2, and + MOD_VEX_0F16_PREFIX_2 entries. + 2020-06-09 Jan Beulich * i386-dis.c (MOD_EVEX_0F12_PREFIX_2, MOD_EVEX_0F13, diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index f6a0c51d2fb..3861371ed4e 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -778,8 +778,10 @@ enum MOD_0F01_REG_5, MOD_0F01_REG_7, MOD_0F12_PREFIX_0, + MOD_0F12_PREFIX_2, MOD_0F13, MOD_0F16_PREFIX_0, + MOD_0F16_PREFIX_2, MOD_0F17, MOD_0F18_REG_0, MOD_0F18_REG_1, @@ -842,8 +844,10 @@ enum MOD_C4_32BIT, MOD_C5_32BIT, MOD_VEX_0F12_PREFIX_0, + MOD_VEX_0F12_PREFIX_2, MOD_VEX_0F13, MOD_VEX_0F16_PREFIX_0, + MOD_VEX_0F16_PREFIX_2, MOD_VEX_0F17, MOD_VEX_0F2B, MOD_VEX_W_0_0F41_P_0_LEN_1, @@ -1799,11 +1803,11 @@ enum { VEX_LEN_0F12_P_0_M_0 = 0, VEX_LEN_0F12_P_0_M_1, - VEX_LEN_0F12_P_2, +#define VEX_LEN_0F12_P_2_M_0 VEX_LEN_0F12_P_0_M_0 VEX_LEN_0F13_M_0, VEX_LEN_0F16_P_0_M_0, VEX_LEN_0F16_P_0_M_1, - VEX_LEN_0F16_P_2, +#define VEX_LEN_0F16_P_2_M_0 VEX_LEN_0F16_P_0_M_0 VEX_LEN_0F17_M_0, VEX_LEN_0F41_P_0, VEX_LEN_0F41_P_2, @@ -3643,7 +3647,7 @@ static const struct dis386 prefix_table[][4] = { { { MOD_TABLE (MOD_0F12_PREFIX_0) }, { "movsldup", { XM, EXx }, PREFIX_OPCODE }, - { "movlpd", { XM, EXq }, PREFIX_OPCODE }, + { MOD_TABLE (MOD_0F12_PREFIX_2) }, { "movddup", { XM, EXq }, PREFIX_OPCODE }, }, @@ -3651,7 +3655,7 @@ static const struct dis386 prefix_table[][4] = { { { MOD_TABLE (MOD_0F16_PREFIX_0) }, { "movshdup", { XM, EXx }, PREFIX_OPCODE }, - { "movhpd", { XM, EXq }, PREFIX_OPCODE }, + { MOD_TABLE (MOD_0F16_PREFIX_2) }, }, /* PREFIX_0F1A */ @@ -4648,7 +4652,7 @@ static const struct dis386 prefix_table[][4] = { { { MOD_TABLE (MOD_VEX_0F12_PREFIX_0) }, { "vmovsldup", { XM, EXx }, 0 }, - { VEX_LEN_TABLE (VEX_LEN_0F12_P_2) }, + { MOD_TABLE (MOD_VEX_0F12_PREFIX_2) }, { "vmovddup", { XM, EXymmq }, 0 }, }, @@ -4656,7 +4660,7 @@ static const struct dis386 prefix_table[][4] = { { { MOD_TABLE (MOD_VEX_0F16_PREFIX_0) }, { "vmovshdup", { XM, EXx }, 0 }, - { VEX_LEN_TABLE (VEX_LEN_0F16_P_2) }, + { MOD_TABLE (MOD_VEX_0F16_PREFIX_2) }, }, /* PREFIX_VEX_0F2A */ @@ -9279,9 +9283,9 @@ static const struct dis386 vex_table[][256] = { #include "i386-dis-evex.h" static const struct dis386 vex_len_table[][2] = { - /* VEX_LEN_0F12_P_0_M_0 */ + /* VEX_LEN_0F12_P_0_M_0 / VEX_LEN_0F12_P_2_M_0 */ { - { "vmovlps", { XM, Vex128, EXq }, 0 }, + { "vmovlpX", { XM, Vex128, EXq }, 0 }, }, /* VEX_LEN_0F12_P_0_M_1 */ @@ -9289,19 +9293,14 @@ static const struct dis386 vex_len_table[][2] = { { "vmovhlps", { XM, Vex128, EXq }, 0 }, }, - /* VEX_LEN_0F12_P_2 */ - { - { "vmovlpd", { XM, Vex128, EXq }, 0 }, - }, - /* VEX_LEN_0F13_M_0 */ { { "vmovlpX", { EXq, XM }, PREFIX_OPCODE }, }, - /* VEX_LEN_0F16_P_0_M_0 */ + /* VEX_LEN_0F16_P_0_M_0 / VEX_LEN_0F16_P_2_M_0 */ { - { "vmovhps", { XM, Vex128, EXq }, 0 }, + { "vmovhpX", { XM, Vex128, EXq }, 0 }, }, /* VEX_LEN_0F16_P_0_M_1 */ @@ -9309,11 +9308,6 @@ static const struct dis386 vex_len_table[][2] = { { "vmovlhps", { XM, Vex128, EXq }, 0 }, }, - /* VEX_LEN_0F16_P_2 */ - { - { "vmovhpd", { XM, Vex128, EXq }, 0 }, - }, - /* VEX_LEN_0F17_M_0 */ { { "vmovhpX", { EXq, XM }, PREFIX_OPCODE }, @@ -10225,8 +10219,12 @@ static const struct dis386 mod_table[][2] = { }, { /* MOD_0F12_PREFIX_0 */ - { "movlps", { XM, EXq }, PREFIX_OPCODE }, - { "movhlps", { XM, EXq }, PREFIX_OPCODE }, + { "movlpX", { XM, EXq }, 0 }, + { "movhlps", { XM, EXq }, 0 }, + }, + { + /* MOD_0F12_PREFIX_2 */ + { "movlpX", { XM, EXq }, 0 }, }, { /* MOD_0F13 */ @@ -10234,9 +10232,13 @@ static const struct dis386 mod_table[][2] = { }, { /* MOD_0F16_PREFIX_0 */ - { "movhps", { XM, EXq }, 0 }, + { "movhpX", { XM, EXq }, 0 }, { "movlhps", { XM, EXq }, 0 }, }, + { + /* MOD_0F16_PREFIX_2 */ + { "movhpX", { XM, EXq }, 0 }, + }, { /* MOD_0F17 */ { "movhpX", { EXq, XM }, PREFIX_OPCODE }, @@ -10518,6 +10520,10 @@ static const struct dis386 mod_table[][2] = { { VEX_LEN_TABLE (VEX_LEN_0F12_P_0_M_0) }, { VEX_LEN_TABLE (VEX_LEN_0F12_P_0_M_1) }, }, + { + /* MOD_VEX_0F12_PREFIX_2 */ + { VEX_LEN_TABLE (VEX_LEN_0F12_P_2_M_0) }, + }, { /* MOD_VEX_0F13 */ { VEX_LEN_TABLE (VEX_LEN_0F13_M_0) }, @@ -10527,6 +10533,10 @@ static const struct dis386 mod_table[][2] = { { VEX_LEN_TABLE (VEX_LEN_0F16_P_0_M_0) }, { VEX_LEN_TABLE (VEX_LEN_0F16_P_0_M_1) }, }, + { + /* MOD_VEX_0F16_PREFIX_2 */ + { VEX_LEN_TABLE (VEX_LEN_0F16_P_2_M_0) }, + }, { /* MOD_VEX_0F17 */ { VEX_LEN_TABLE (VEX_LEN_0F17_M_0) }, -- 2.30.2