[PATCH 3/9] x86: correct MPX insn w/o base or index encoding in 16-bit mode

H.J. Lu hjl.tools@gmail.com
Wed Mar 4 11:55:00 GMT 2020


On Wed, Mar 4, 2020 at 3:50 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 04.03.2020 12:45, H.J. Lu wrote:
> > On Wed, Mar 4, 2020 at 1:38 AM Jan Beulich <jbeulich@suse.com> wrote:
> >> --- a/gas/config/tc-i386.c
> >> +++ b/gas/config/tc-i386.c
> >> @@ -10297,6 +10297,21 @@ i386_addressing_mode (void)
> >>
> >>    if (i.prefix[ADDR_PREFIX])
> >>      addr_mode = flag_code == CODE_32BIT ? CODE_16BIT : CODE_32BIT;
> >> +  else if (flag_code == CODE_16BIT
> >> +          && current_templates->start->cpu_flags.bitfield.cpumpx
> >> +          /* Avoid replacing the "16-bit addressing not allowed" diagnostic
> >> +             from md_assemble() by "is not a valid base/index expression"
> >> +             when there is a base and/or index.  */
> >> +          && !i.types[this_operand].bitfield.baseindex)
> >> +    {
> >> +      /* MPX insn memory operands with neither base nor index must be forced
> >> +        to use 32-bit addressing in 16-bit mode.  */
> >> +      addr_mode = CODE_32BIT;
> >> +      i.prefix[ADDR_PREFIX] = ADDR_PREFIX_OPCODE;
> >> +      ++i.prefixes;
> >> +      gas_assert (!i.types[this_operand].bitfield.disp16);
> >> +      gas_assert (!i.types[this_operand].bitfield.disp32);
> >> +    }
> >>    else
> >>      {
> >
> > Since MPX isn't available in 16-bit mode, should they be disallowed?
>
> How is it not available? As per my understanding, one just needs
> to use 32-bit addressing.

0x67 prefix is special for MPX.  It can't be used as address prefix on MPX
instructions.

> > Given that MPX has been deprecated, I prefer an error here.
>
> The use of "here" is confusing - just for the broken case (no
> base/index), or for MPX insns in general? (Asking just in case
> my understanding expressed above is wrong.)

flag_code == CODE_16BIT && current_templates->start->cpu_flags.bitfield.cpumpx

should be an error.

-- 
H.J.



More information about the Binutils mailing list