This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86: reject further invalid AVX-512 masking constructs


On Mon, Nov 20, 2017 at 6:06 AM, Jan Beulich <JBeulich@suse.com> wrote:
> For one the register type used for masking should be validated. And then
> we shouldn't accept input producing encodings which will #UD when
> executed, as is the case when EVEX.Z is set while EVEX.AAA is zero.
>
> gas/
> 2017-11-20  Jan Beulich  <jbeulich@suse.com>
>
>         * config/tc-i386.c (check_VecOperations): Check register type
>         for masking. Quote the actual register name in the respective
>         diagnostic. Check {z} wasn't specified on its own.
>         * testsuite/gas/i386/inval-avx512f.s,
>         testsuite/gas/i386/x86-64-inval-avx512f.s: Add further bad
>         masking tests.
>         * testsuite/gas/i386/inval-avx512f.l,
>         testsuite/gas/i386/x86-64-inval-avx512f.l: Adjust expectations.
> ---
> This takes https://sourceware.org/ml/binutils/2017-11/msg00319.html as
> a prereq (the new tests being added would otherwise also cause
> multiple diagnostics to be issued).
>
> --- a/gas/config/tc-i386.c
> +++ b/gas/config/tc-i386.c
> @@ -8148,10 +8148,10 @@ check_VecOperations (char *op_string, ch
>           else if ((mask = parse_register (op_string, &end_op)) != NULL)
>             {
>               /* k0 can't be used for write mask.  */
> -             if (mask->reg_num == 0)
> +             if (!mask->reg_type.bitfield.regmask || mask->reg_num == 0)
>                 {
>                   as_bad (_("`%s' can't be used for write mask"),
> -                         op_string);
> +                         mask->reg_name);
>                   return NULL;
>                 }
>
> @@ -8230,6 +8230,12 @@ check_VecOperations (char *op_string, ch
>        return NULL;
>      }
>
> +  if (i.mask && i.mask->zeroing && !i.mask->mask)
> +    {
> +      as_bad (_("zeroing-masking only allowed with write mask"));
> +      return NULL;
> +    }
> +
>    return op_string;
>  }
>
> --- a/gas/testsuite/gas/i386/inval-avx512f.l
> +++ b/gas/testsuite/gas/i386/inval-avx512f.l
> @@ -36,6 +36,8 @@
>  .*:48: Error: .*
>  .*:49: Error: .*
>  .*:50: Error: .*
> +.*:52: Error: .*
> +.*:53: Error: .*
>  GAS LISTING .*
>
>
> @@ -89,3 +91,6 @@ GAS LISTING .*
>  [      ]*48[   ]+vaddps zmm2, zmm1, ZMMWORD PTR \[eax\]\{1to16\}
>  [      ]*49[   ]+vaddps zmm2, zmm1, DWORD PTR \[eax\]
>  [      ]*50[   ]+vaddpd zmm2, zmm1, QWORD PTR \[eax\]
> +[      ]*51[   ]*
> +[      ]*52[   ]+vaddps zmm2\{ecx\}, zmm1, zmm0
> +[      ]*53[   ]+vaddps zmm2\{z\}, zmm1, zmm0
> --- a/gas/testsuite/gas/i386/inval-avx512f.s
> +++ b/gas/testsuite/gas/i386/inval-avx512f.s
> @@ -48,3 +48,6 @@ _start:
>         vaddps zmm2, zmm1, ZMMWORD PTR [eax]{1to16}
>         vaddps zmm2, zmm1, DWORD PTR [eax]
>         vaddpd zmm2, zmm1, QWORD PTR [eax]
> +
> +       vaddps zmm2{ecx}, zmm1, zmm0
> +       vaddps zmm2{z}, zmm1, zmm0

Do they fail only in Intel syntax?  Testcases in AT&T syntax iare
required unless they are specific to Intel syntax.



-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]