[3/5] x86: flag EVEX.z set when destination is memory

Message ID 65872bf7-36c2-0a0a-8992-38a0843a897d@suse.com
State Unresolved
Headers
Series x86/disasm: deal with invalid uses of AVX512 masking |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Jan Beulich June 16, 2023, 10:16 a.m. UTC
  Zeroing-masking is not permitted in this case. See the code comment for
how this is being dealt with.
  

Patch

--- a/gas/testsuite/gas/i386/avx512f-nondef.d
+++ b/gas/testsuite/gas/i386/avx512f-nondef.d
@@ -21,4 +21,5 @@  Disassembly of section .text:
 [ 	]*[a-f0-9]+:	62 f2 7d cf 92 04 08 	vgatherdps \(%eax,%zmm1(,1)?\),%zmm0\{%k7\}\{z\}/\(bad\)
 [ 	]*[a-f0-9]+:	62 f2 7d 48 92 04 08 	vgatherdps \(%eax,%zmm1(,1)?\),%zmm0/\(bad\)
 [ 	]*[a-f0-9]+:	62 f1 7c cf c2 c0 00 	vcmpeqps %zmm0,%zmm0,%k0\{%k7\}\{z\}/\(bad\)
+[ 	]*[a-f0-9]+:	62 f1 7c cf 29 00    	vmovaps %zmm0,\(%eax\)\{%k7\}\{z\}/\(bad\)
 #pass
--- a/gas/testsuite/gas/i386/avx512f-nondef.s
+++ b/gas/testsuite/gas/i386/avx512f-nondef.s
@@ -29,3 +29,6 @@ 
 
 	# vcmpeqps %zmm0, %zmm0, %k0{%k7} with EVEX.z set
 	.insn EVEX.0f 0xc2, $0, %zmm0, %zmm0, %k0{%k7}{z}
+
+	# vmovaps %zmm0, (%eax){%k7} with EVEX.z set
+	.insn EVEX.0f 0x29, %zmm0, (%eax){%k7}{z}
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -11854,6 +11854,13 @@  OP_E_memory (instr_info *ins, int bytemo
 
   if (ins->vex.evex)
     {
+
+      /* Zeroing-masking is invalid for memory destinations. Set the flag
+	 uniformly, as the consumer will inspect it only for the destination
+	 operand.  */
+      if (ins->vex.zeroing)
+	ins->illegal_masking = true;
+
       switch (bytemode)
 	{
 	case dw_mode: