Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update instructions and add new ISA extensions #407

Merged
merged 5 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion include/Zydis/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ typedef enum ZydisDecoderMode_
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_CLDEMOTE,
/**
* Enables the `IPREFETCH` mode.
*
* The `IPREFETCH` isa-extension reuses (overrides) some of the widenop instruction opcodes.
*
* This mode is enabled by default.
*/
ZYDIS_DECODER_MODE_IPREFETCH,

/**
* Maximum value of this enum.
*/
ZYDIS_DECODER_MODE_MAX_VALUE = ZYDIS_DECODER_MODE_CLDEMOTE,
ZYDIS_DECODER_MODE_MAX_VALUE = ZYDIS_DECODER_MODE_IPREFETCH,
/**
* The minimum number of bits required to represent all values of this enum.
*/
Expand Down
8 changes: 8 additions & 0 deletions include/Zydis/Generated/EnumISAExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_AMD3DNOW_PREFETCH,
ZYDIS_ISA_EXT_AMD_INVLPGB,
ZYDIS_ISA_EXT_AMX_BF16,
ZYDIS_ISA_EXT_AMX_FP16,
ZYDIS_ISA_EXT_AMX_INT8,
ZYDIS_ISA_EXT_AMX_TILE,
ZYDIS_ISA_EXT_AVX,
Expand All @@ -18,7 +19,10 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_AVX512EVEX,
ZYDIS_ISA_EXT_AVX512VEX,
ZYDIS_ISA_EXT_AVXAES,
ZYDIS_ISA_EXT_AVX_IFMA,
ZYDIS_ISA_EXT_AVX_NE_CONVERT,
ZYDIS_ISA_EXT_AVX_VNNI,
ZYDIS_ISA_EXT_AVX_VNNI_INT8,
ZYDIS_ISA_EXT_BASE,
ZYDIS_ISA_EXT_BMI1,
ZYDIS_ISA_EXT_BMI2,
Expand All @@ -34,6 +38,7 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_FMA4,
ZYDIS_ISA_EXT_GFNI,
ZYDIS_ISA_EXT_HRESET,
ZYDIS_ISA_EXT_ICACHE_PREFETCH,
ZYDIS_ISA_EXT_INVPCID,
ZYDIS_ISA_EXT_KEYLOCKER,
ZYDIS_ISA_EXT_KEYLOCKER_WIDE,
Expand All @@ -49,13 +54,15 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_MOVBE,
ZYDIS_ISA_EXT_MOVDIR,
ZYDIS_ISA_EXT_MPX,
ZYDIS_ISA_EXT_MSRLIST,
ZYDIS_ISA_EXT_PADLOCK,
ZYDIS_ISA_EXT_PAUSE,
ZYDIS_ISA_EXT_PCLMULQDQ,
ZYDIS_ISA_EXT_PCONFIG,
ZYDIS_ISA_EXT_PKU,
ZYDIS_ISA_EXT_PREFETCHWT1,
ZYDIS_ISA_EXT_PT,
ZYDIS_ISA_EXT_RAO_INT,
ZYDIS_ISA_EXT_RDPID,
ZYDIS_ISA_EXT_RDPRU,
ZYDIS_ISA_EXT_RDRAND,
Expand Down Expand Up @@ -86,6 +93,7 @@ typedef enum ZydisISAExt_
ZYDIS_ISA_EXT_VPCLMULQDQ,
ZYDIS_ISA_EXT_VTX,
ZYDIS_ISA_EXT_WAITPKG,
ZYDIS_ISA_EXT_WRMSRNS,
ZYDIS_ISA_EXT_X87,
ZYDIS_ISA_EXT_XOP,
ZYDIS_ISA_EXT_XSAVE,
Expand Down
9 changes: 9 additions & 0 deletions include/Zydis/Generated/EnumISASet.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_AMD3DNOW,
ZYDIS_ISA_SET_AMD_INVLPGB,
ZYDIS_ISA_SET_AMX_BF16,
ZYDIS_ISA_SET_AMX_FP16,
ZYDIS_ISA_SET_AMX_INT8,
ZYDIS_ISA_SET_AMX_TILE,
ZYDIS_ISA_SET_AVX,
Expand Down Expand Up @@ -81,7 +82,10 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_AVX512_VPOPCNTDQ_512,
ZYDIS_ISA_SET_AVXAES,
ZYDIS_ISA_SET_AVX_GFNI,
ZYDIS_ISA_SET_AVX_IFMA,
ZYDIS_ISA_SET_AVX_NE_CONVERT,
ZYDIS_ISA_SET_AVX_VNNI,
ZYDIS_ISA_SET_AVX_VNNI_INT8,
ZYDIS_ISA_SET_BMI1,
ZYDIS_ISA_SET_BMI2,
ZYDIS_ISA_SET_CET,
Expand All @@ -96,6 +100,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_F16C,
ZYDIS_ISA_SET_FAT_NOP,
ZYDIS_ISA_SET_FCMOV,
ZYDIS_ISA_SET_FCOMI,
ZYDIS_ISA_SET_FMA,
ZYDIS_ISA_SET_FMA4,
ZYDIS_ISA_SET_FXSAVE,
Expand All @@ -109,6 +114,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_I486,
ZYDIS_ISA_SET_I486REAL,
ZYDIS_ISA_SET_I86,
ZYDIS_ISA_SET_ICACHE_PREFETCH,
ZYDIS_ISA_SET_INVPCID,
ZYDIS_ISA_SET_KEYLOCKER,
ZYDIS_ISA_SET_KEYLOCKER_WIDE,
Expand All @@ -128,6 +134,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_MOVBE,
ZYDIS_ISA_SET_MOVDIR,
ZYDIS_ISA_SET_MPX,
ZYDIS_ISA_SET_MSRLIST,
ZYDIS_ISA_SET_PADLOCK_ACE,
ZYDIS_ISA_SET_PADLOCK_PHE,
ZYDIS_ISA_SET_PADLOCK_PMM,
Expand All @@ -143,6 +150,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_PREFETCHWT1,
ZYDIS_ISA_SET_PREFETCH_NOP,
ZYDIS_ISA_SET_PT,
ZYDIS_ISA_SET_RAO_INT,
ZYDIS_ISA_SET_RDPID,
ZYDIS_ISA_SET_RDPMC,
ZYDIS_ISA_SET_RDPRU,
Expand Down Expand Up @@ -180,6 +188,7 @@ typedef enum ZydisISASet_
ZYDIS_ISA_SET_VPCLMULQDQ,
ZYDIS_ISA_SET_VTX,
ZYDIS_ISA_SET_WAITPKG,
ZYDIS_ISA_SET_WRMSRNS,
ZYDIS_ISA_SET_X87,
ZYDIS_ISA_SET_XOP,
ZYDIS_ISA_SET_XSAVE,
Expand Down
3 changes: 3 additions & 0 deletions include/Zydis/Generated/EnumInstructionCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ typedef enum ZydisInstructionCategory_
ZYDIS_CATEGORY_AVX512_BITALG,
ZYDIS_CATEGORY_AVX512_VBMI,
ZYDIS_CATEGORY_AVX512_VP2INTERSECT,
ZYDIS_CATEGORY_AVX_IFMA,
ZYDIS_CATEGORY_BINARY,
ZYDIS_CATEGORY_BITBYTE,
ZYDIS_CATEGORY_BLEND,
Expand Down Expand Up @@ -63,6 +64,7 @@ typedef enum ZydisInstructionCategory_
ZYDIS_CATEGORY_MMX,
ZYDIS_CATEGORY_MOVDIR,
ZYDIS_CATEGORY_MPX,
ZYDIS_CATEGORY_MSRLIST,
ZYDIS_CATEGORY_NOP,
ZYDIS_CATEGORY_PADLOCK,
ZYDIS_CATEGORY_PCLMULQDQ,
Expand Down Expand Up @@ -108,6 +110,7 @@ typedef enum ZydisInstructionCategory_
ZYDIS_CATEGORY_VTX,
ZYDIS_CATEGORY_WAITPKG,
ZYDIS_CATEGORY_WIDENOP,
ZYDIS_CATEGORY_WRMSRNS,
ZYDIS_CATEGORY_X87_ALU,
ZYDIS_CATEGORY_XOP,
ZYDIS_CATEGORY_XSAVE,
Expand Down
22 changes: 22 additions & 0 deletions include/Zydis/Generated/EnumMnemonic.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_INVALID,
ZYDIS_MNEMONIC_AAA,
ZYDIS_MNEMONIC_AAD,
ZYDIS_MNEMONIC_AADD,
ZYDIS_MNEMONIC_AAM,
ZYDIS_MNEMONIC_AAND,
ZYDIS_MNEMONIC_AAS,
ZYDIS_MNEMONIC_ADC,
ZYDIS_MNEMONIC_ADCX,
Expand Down Expand Up @@ -38,7 +40,9 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_ANDNPS,
ZYDIS_MNEMONIC_ANDPD,
ZYDIS_MNEMONIC_ANDPS,
ZYDIS_MNEMONIC_AOR,
ZYDIS_MNEMONIC_ARPL,
ZYDIS_MNEMONIC_AXOR,
ZYDIS_MNEMONIC_BEXTR,
ZYDIS_MNEMONIC_BLCFILL,
ZYDIS_MNEMONIC_BLCI,
Expand Down Expand Up @@ -615,6 +619,8 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_POPFQ,
ZYDIS_MNEMONIC_POR,
ZYDIS_MNEMONIC_PREFETCH,
ZYDIS_MNEMONIC_PREFETCHIT0,
ZYDIS_MNEMONIC_PREFETCHIT1,
ZYDIS_MNEMONIC_PREFETCHNTA,
ZYDIS_MNEMONIC_PREFETCHT0,
ZYDIS_MNEMONIC_PREFETCHT1,
Expand Down Expand Up @@ -675,6 +681,7 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_RDFSBASE,
ZYDIS_MNEMONIC_RDGSBASE,
ZYDIS_MNEMONIC_RDMSR,
ZYDIS_MNEMONIC_RDMSRLIST,
ZYDIS_MNEMONIC_RDPID,
ZYDIS_MNEMONIC_RDPKRU,
ZYDIS_MNEMONIC_RDPMC,
Expand Down Expand Up @@ -788,6 +795,7 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_TDPBSUD,
ZYDIS_MNEMONIC_TDPBUSD,
ZYDIS_MNEMONIC_TDPBUUD,
ZYDIS_MNEMONIC_TDPFP16PS,
ZYDIS_MNEMONIC_TEST,
ZYDIS_MNEMONIC_TESTUI,
ZYDIS_MNEMONIC_TILELOADD,
Expand Down Expand Up @@ -839,6 +847,8 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_VANDNPS,
ZYDIS_MNEMONIC_VANDPD,
ZYDIS_MNEMONIC_VANDPS,
ZYDIS_MNEMONIC_VBCSTNEBF162PS,
ZYDIS_MNEMONIC_VBCSTNESH2PS,
ZYDIS_MNEMONIC_VBLENDMPD,
ZYDIS_MNEMONIC_VBLENDMPS,
ZYDIS_MNEMONIC_VBLENDPD,
Expand Down Expand Up @@ -880,6 +890,10 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_VCVTFXPNTPS2UDQ,
ZYDIS_MNEMONIC_VCVTFXPNTUDQ2PS,
ZYDIS_MNEMONIC_VCVTNE2PS2BF16,
ZYDIS_MNEMONIC_VCVTNEEBF162PS,
ZYDIS_MNEMONIC_VCVTNEEPH2PS,
ZYDIS_MNEMONIC_VCVTNEOBF162PS,
ZYDIS_MNEMONIC_VCVTNEOPH2PS,
ZYDIS_MNEMONIC_VCVTNEPS2BF16,
ZYDIS_MNEMONIC_VCVTPD2DQ,
ZYDIS_MNEMONIC_VCVTPD2PH,
Expand Down Expand Up @@ -1341,8 +1355,14 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_VPCOMW,
ZYDIS_MNEMONIC_VPCONFLICTD,
ZYDIS_MNEMONIC_VPCONFLICTQ,
ZYDIS_MNEMONIC_VPDPBSSD,
ZYDIS_MNEMONIC_VPDPBSSDS,
ZYDIS_MNEMONIC_VPDPBSUD,
ZYDIS_MNEMONIC_VPDPBSUDS,
ZYDIS_MNEMONIC_VPDPBUSD,
ZYDIS_MNEMONIC_VPDPBUSDS,
ZYDIS_MNEMONIC_VPDPBUUD,
ZYDIS_MNEMONIC_VPDPBUUDS,
ZYDIS_MNEMONIC_VPDPWSSD,
ZYDIS_MNEMONIC_VPDPWSSDS,
ZYDIS_MNEMONIC_VPERM2F128,
Expand Down Expand Up @@ -1719,6 +1739,8 @@ typedef enum ZydisMnemonic_
ZYDIS_MNEMONIC_WRFSBASE,
ZYDIS_MNEMONIC_WRGSBASE,
ZYDIS_MNEMONIC_WRMSR,
ZYDIS_MNEMONIC_WRMSRLIST,
ZYDIS_MNEMONIC_WRMSRNS,
ZYDIS_MNEMONIC_WRPKRU,
ZYDIS_MNEMONIC_WRSSD,
ZYDIS_MNEMONIC_WRSSQ,
Expand Down
6 changes: 5 additions & 1 deletion include/Zydis/Internal/DecoderData.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ enum ZydisDecoderTreeNodeTypes
/**
* Reference to a CLDEMOTE-mode filter.
*/
ZYDIS_NODETYPE_FILTER_MODE_CLDEMOTE = 0x1B
ZYDIS_NODETYPE_FILTER_MODE_CLDEMOTE = 0x1B,
/**
* Reference to a IPREFETCH-mode filter.
*/
ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH = 0x1C
};

/* ---------------------------------------------------------------------------------------------- */
Expand Down
3 changes: 3 additions & 0 deletions include/Zydis/Internal/SharedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ typedef enum ZydisInternalElementType_
ZYDIS_IELEMENT_TYPE_UINT,
ZYDIS_IELEMENT_TYPE_INT1,
ZYDIS_IELEMENT_TYPE_INT8,
ZYDIS_IELEMENT_TYPE_INT8X4,
ZYDIS_IELEMENT_TYPE_INT16,
ZYDIS_IELEMENT_TYPE_INT32,
ZYDIS_IELEMENT_TYPE_INT64,
ZYDIS_IELEMENT_TYPE_UINT8,
ZYDIS_IELEMENT_TYPE_UINT8X4,
ZYDIS_IELEMENT_TYPE_UINT16,
ZYDIS_IELEMENT_TYPE_UINT32,
ZYDIS_IELEMENT_TYPE_UINT64,
Expand All @@ -130,6 +132,7 @@ typedef enum ZydisInternalElementType_
ZYDIS_IELEMENT_TYPE_FLOAT32,
ZYDIS_IELEMENT_TYPE_FLOAT64,
ZYDIS_IELEMENT_TYPE_FLOAT80,
ZYDIS_IELEMENT_TYPE_BFLOAT16X2,
ZYDIS_IELEMENT_TYPE_BCD80,
ZYDIS_IELEMENT_TYPE_CC3,
ZYDIS_IELEMENT_TYPE_CC5,
Expand Down
4 changes: 4 additions & 0 deletions include/Zydis/SharedTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ typedef enum ZydisElementType_
* 80-bit floating point value (`extended`).
*/
ZYDIS_ELEMENT_TYPE_FLOAT80,
/**
* 16-bit brain floating point value.
*/
ZYDIS_ELEMENT_TYPE_BFLOAT16,
/**
* Binary coded decimal value.
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -4800,6 +4800,9 @@ static ZyanStatus ZydisDecodeInstruction(ZydisDecoderState* state,
case ZYDIS_NODETYPE_FILTER_MODE_CLDEMOTE:
index = state->decoder->decoder_mode[ZYDIS_DECODER_MODE_CLDEMOTE] ? 1 : 0;
break;
case ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH:
index = state->decoder->decoder_mode[ZYDIS_DECODER_MODE_IPREFETCH] ? 1 : 0;
break;
default:
if (node_type & ZYDIS_NODETYPE_DEFINITION_MASK)
{
Expand Down Expand Up @@ -4910,7 +4913,8 @@ ZyanStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMode machine_mode
ZYAN_TRUE , // ZYDIS_DECODER_MODE_LZCNT
ZYAN_TRUE , // ZYDIS_DECODER_MODE_TZCNT
ZYAN_FALSE, // ZYDIS_DECODER_MODE_WBNOINVD
ZYAN_TRUE // ZYDIS_DECODER_MODE_CLDEMOTE
ZYAN_TRUE, // ZYDIS_DECODER_MODE_CLDEMOTE
ZYAN_FALSE // ZYDIS_DECODER_MODE_IPREFETCH
};

if (!decoder)
Expand Down
3 changes: 3 additions & 0 deletions src/DecoderData.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ const ZydisDecoderTreeNode* ZydisDecoderTreeGetChildNode(const ZydisDecoderTreeN
case ZYDIS_NODETYPE_FILTER_MODE_CLDEMOTE:
ZYAN_ASSERT(index < 2);
return &FILTERS_MODE_CLDEMOTE[parent->value][index];
case ZYDIS_NODETYPE_FILTER_MODE_IPREFETCH:
ZYAN_ASSERT(index < 2);
return &FILTERS_MODE_IPREFETCH[parent->value][index];
default:
ZYAN_UNREACHABLE;
}
Expand Down
5,289 changes: 2,703 additions & 2,586 deletions src/Generated/DecoderTables.inc

Large diffs are not rendered by default.