x86: reject further invalid AVX-512 masking constructs
authorJan Beulich <jbeulich@novell.com>
Fri, 24 Nov 2017 07:42:57 +0000 (08:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Nov 2017 07:42:57 +0000 (08:42 +0100)
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/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/inval-avx512f.l
gas/testsuite/gas/i386/inval-avx512f.s
gas/testsuite/gas/i386/x86-64-inval-avx512f.l
gas/testsuite/gas/i386/x86-64-inval-avx512f.s

index c355559c5904099311f18230e66397fd5637935f..d6c9d4cd7a65f561afde566990a192e87679d2ae 100644 (file)
@@ -1,3 +1,14 @@
+2017-11-24  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.
+
 2017-11-24  Jan Beulich  <jbeulich@suse.com>
 
        * testsuite/gas/i386/intel.d, testsuite/gas/i386/opcode.d,
index f623e82034640bba8a35b5ccd0c1486486ac9090..4b5b2e5881b56f5259dc4c4895f96f4dacfcd9ae 100644 (file)
@@ -8138,10 +8138,10 @@ check_VecOperations (char *op_string, char *op_end)
          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);
+                 as_bad (_("`%s%s' can't be used for write mask"),
+                         register_prefix, mask->reg_name);
                  return NULL;
                }
 
@@ -8220,6 +8220,12 @@ check_VecOperations (char *op_string, char *op_end)
       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;
 }
 
index 357a3c66289347865919d0ab89fcf3602e11a398..ff27599ddf360cf4c22d2b5302bc0b5697000b4e 100644 (file)
 .*:48: Error: .*
 .*:49: Error: .*
 .*:50: Error: .*
+.*:53: Error: .*
+.*:54: Error: .*
+.*:57: Error: .*
+.*:58: Error: .*
 GAS LISTING .*
 
 
@@ -89,3 +93,13 @@ 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[   ]+\.att_syntax prefix
+[      ]*53[   ]+vaddps %zmm0, %zmm1, %zmm2\{%ecx\}
+[      ]*54[   ]+vaddps %zmm0, %zmm1, %zmm2\{z\}
+[      ]*55[   ]*
+[      ]*56[   ]+\.intel_syntax noprefix
+[      ]*57[   ]+vaddps zmm2\{ecx\}, zmm1, zmm0
+\fGAS LISTING .*
+#...
+[      ]*58[   ]+vaddps zmm2\{z\}, zmm1, zmm0
index f723c5ad1eb466451e36d9d6e585973ec1972209..f890eb272290f49f67472e2f15c127eac6bcb782 100644 (file)
@@ -48,3 +48,11 @@ _start:
        vaddps zmm2, zmm1, ZMMWORD PTR [eax]{1to16}
        vaddps zmm2, zmm1, DWORD PTR [eax]
        vaddpd zmm2, zmm1, QWORD PTR [eax]
+
+       .att_syntax prefix
+       vaddps %zmm0, %zmm1, %zmm2{%ecx}
+       vaddps %zmm0, %zmm1, %zmm2{z}
+
+       .intel_syntax noprefix
+       vaddps zmm2{ecx}, zmm1, zmm0
+       vaddps zmm2{z}, zmm1, zmm0
index 1f7251d773200cae964a28fc7281b4863e5b9b1c..80d63013fd0dbe3f059fc3de853c7e17c8eb88c0 100644 (file)
 .*:46: Error: .*
 .*:47: Error: .*
 .*:48: Error: .*
+.*:51: Error: .*
+.*:52: Error: .*
+.*:55: Error: .*
+.*:56: Error: .*
 GAS LISTING .*
 
 
@@ -85,3 +89,11 @@ GAS LISTING .*
 [      ]*46[   ]+vaddps zmm2, zmm1, ZMMWORD PTR \[rax\]\{1to16\}
 [      ]*47[   ]+vaddps zmm2, zmm1, DWORD PTR \[rax\]
 [      ]*48[   ]+vaddpd zmm2, zmm1, QWORD PTR \[rax\]
+[      ]*49[   ]*
+[      ]*50[   ]+\.att_syntax prefix
+[      ]*51[   ]+vaddps %zmm0, %zmm1, %zmm2\{%rcx\}
+[      ]*52[   ]+vaddps %zmm0, %zmm1, %zmm2\{z\}
+[      ]*53[   ]*
+[      ]*54[   ]+\.intel_syntax noprefix
+[      ]*55[   ]+vaddps zmm2\{rcx\}, zmm1, zmm0
+[      ]*56[   ]+vaddps zmm2\{z\}, zmm1, zmm0
index 835f677033de1d0799d75c23c4054b0d854abf7e..2ef31fed11b336133f6c75188d1482c85ab98079 100644 (file)
@@ -46,3 +46,11 @@ _start:
        vaddps zmm2, zmm1, ZMMWORD PTR [rax]{1to16}
        vaddps zmm2, zmm1, DWORD PTR [rax]
        vaddpd zmm2, zmm1, QWORD PTR [rax]
+
+       .att_syntax prefix
+       vaddps %zmm0, %zmm1, %zmm2{%rcx}
+       vaddps %zmm0, %zmm1, %zmm2{z}
+
+       .intel_syntax noprefix
+       vaddps zmm2{rcx}, zmm1, zmm0
+       vaddps zmm2{z}, zmm1, zmm0
This page took 0.035867 seconds and 4 git commands to generate.