This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] x86: reject further invalid AVX-512 masking constructs
- From: "Jan Beulich" <JBeulich at suse dot com>
- To: <binutils at sourceware dot org>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>
- Date: Mon, 20 Nov 2017 07:06:41 -0700
- Subject: [PATCH] x86: reject further invalid AVX-512 masking constructs
- Authentication-results: sourceware.org; auth=none
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
--- a/gas/testsuite/gas/i386/x86-64-inval-avx512f.l
+++ b/gas/testsuite/gas/i386/x86-64-inval-avx512f.l
@@ -34,6 +34,8 @@
.*:46: Error: .*
.*:47: Error: .*
.*:48: Error: .*
+.*:50: Error: .*
+.*:51: Error: .*
GAS LISTING .*
@@ -85,3 +87,6 @@ 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[ ]+vaddps zmm2\{rcx\}, zmm1, zmm0
+[ ]*51[ ]+vaddps zmm2\{z\}, zmm1, zmm0
--- a/gas/testsuite/gas/i386/x86-64-inval-avx512f.s
+++ b/gas/testsuite/gas/i386/x86-64-inval-avx512f.s
@@ -46,3 +46,6 @@ _start:
vaddps zmm2, zmm1, ZMMWORD PTR [rax]{1to16}
vaddps zmm2, zmm1, DWORD PTR [rax]
vaddpd zmm2, zmm1, QWORD PTR [rax]
+
+ vaddps zmm2{rcx}, zmm1, zmm0
+ vaddps zmm2{z}, zmm1, zmm0