Skip to content

Incorrect VEX Instruction Mnemonic/Encoding on x86 #6107

Open

Description

@BradleyWood

Whilst investigation #6102 I discovered a number of instructions with incorrect encoding. Many AVX instructions have been incorrectly labeled without the V prefix in their mnemonic. For instance, in the example below, ADDSSRegReg should be the SSE non-vex version of addss.

INSTRUCTION(ADDSSRegReg, addss,
            BINARY(VEX_L128, VEX_vReg_, PREFIX_F3, REX__, ESCAPE_0F__, 0x58, 0, ModRM_RM__, Immediate_0),
            PROPERTY0(IA32OpProp_ModifiesTarget | IA32OpProp_SingleFP | IA32OpProp_SourceRegisterInModRM | IA32OpProp_UsesTarget),
            PROPERTY1(IA32OpProp1_XMMSource | IA32OpProp1_XMMTarget)),

VEX_L128, VEX_vReg_ should be replaced with VEX_L___, VEX_vNONE and the vex encoded versions should be added with the V prefix. According to the intel manual, these vex encoded instructions (except vmovdqu, vmovdqa, etc) should have three operands (not two) xmm1, xmm2, xmm3/m128. Therefore, the RegRegReg/RegRegMem suffix should be added for the vex encoded versions to avoid this confusion.

This issue is prevalent for most VEX encoded instructions defined in X86Ops.ins such as add/sub/mul/div ss/ps/sd/pd etc.

In addition, these instructions are not always used correctly. The same AVX opcodes are used when AVX is not supported.

Activity

  1. BradleyWood commented on Jul 14, 2021

    @BradleyWood
    ContributorAuthor

    It seems like OpenJ9 will crash on any CPU prior to SandyBridge whilst I believe the minimum target is Pentium 4.

  2. BradleyWood commented on Mar 15, 2022

    @BradleyWood
    ContributorAuthor

    The choice of instruction variant should not be differed to binary encoding. This causes difficulty testing the binary encoding of instructions that have SSE/AVX forms. Opcodes without 'V' prefix should not be flagged as VEX_L128. AVX variants of these instructions should be added to X86Ops.ins with the 'V' prefix.

    Opcode evaluators should be responsible for choosing the most appropriate instruction variant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions