Re: [PATCH V2 2/4] x86/insn: Add AVX-512 support to the instruction decoder

Borislav Petkov
2025-11-30T16:05:55Z

Resurrecting a very old thread...

On Wed, Jul 20, 2016 at 11:30:35AM +0300, Adrian Hunter wrote:
> Add support for Intel's AVX-512 instructions to the instruction decoder.
>
> AVX-512 instructions are documented in Intel Architecture Instruction Set
> Extensions Programming Reference (February 2016).
>
> AVX-512 instructions are identified by a EVEX prefix which, for the purpose
> of instruction decoding, can be treated as though it were a 4-byte VEX
> prefix.
>
> Existing instructions which can now accept an EVEX prefix need not be
> further annotated in the op code map (x86-opcode-map.txt). In the case of
> new instructions, the op code map is updated accordingly.
>
> Also add associated Mask Instructions that are used to manipulate mask
> registers used in AVX-512 instructions.
>
> 'perf tools' instruction decoder is updated in a subsequent patch. And a
> representative set of instructions is added to the perf tools new
> instructions test in a subsequent patch.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> arch/x86/include/asm/inat.h | 17 ++-
> arch/x86/include/asm/insn.h | 12 +-
> arch/x86/lib/insn.c | 18 ++-
> arch/x86/lib/x86-opcode-map.txt | 263 +++++++++++++++++++++++------------
> arch/x86/tools/gen-insn-attr-x86.awk | 11 +-
> 5 files changed, 220 insertions(+), 101 deletions(-)
>
> +78: VMREAD Ey,Gy | vcvttps2udq/pd2udq Vx,Wpd (evo) | vcvttsd2usi Gv,Wx (F2),(ev) | vcvttss2usi Gv,Wx (F3),(ev) | vcvttps2uqq/pd2uqq Vx,Wx (66),(ev)
> +79: VMWRITE Gy,Ey | vcvtps2udq/pd2udq Vx,Wpd (evo) | vcvtsd2usi Gv,Wx (F2),(ev) | vcvtss2usi Gv,Wx (F3),(ev) | vcvtps2uqq/pd2uqq Vx,Wx (66),(ev)

This is all fine and dandy but those (ev*) flags cause the escape table to
have INAT_EVEXONLY as a flag:

const insn_attr_t inat_escape_table_1_1[INAT_OPCODE_TABLE_SIZE] = {
...

[0x79] = INAT_MODRM | INAT_VEXOK | INAT_EVEXONLY,

};

except that that opcode is not EVEX only. Intel's VMREAD and VMWRITE are *not*
EVEX insns and AMD has there EXTRQ and INSERTQ with prefixes 66 and F2
respectively which are SSE4a and both are not EVEX.

The VMREAD and VMWRITE decoding happens to work out by pure chance because
those are without a prefix and the check for prefix id in
inat_get_escape_attribute() happens to not select that escape table.

So the first thing that comes to mind is excluding opcodes like 0x79 which can
be mixed type from that inat_must_vex() enforcement...?

Masami, any other ideas?

--
Regards/Gruss,
Boris.