From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id C8D3E3864830 for ; Fri, 19 Apr 2024 04:24:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8D3E3864830 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C8D3E3864830 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713500670; cv=none; b=JOTA+4kpsMuxOcU62j5sMhYB0jVNEI2iM20od0qn305FHfsfHfBH+/EFeCMSBVkbAK4OJtdu6H3hUK7vq9Q7LTnqa0xCmYjhkpWZz8ruCbeWygLPUIlGagRnmjagw2EZGfP5ywA/HiqPciQoZpcn0ITkWZDLkE/0ig6W5k/T4Bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713500670; c=relaxed/simple; bh=xJa0K4lr/2emu7rU0I0TKx9oru/+26LBqQS3iRUU9Gg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ApddJYDQ4PDTXRPKidwciHvITsmetSpZlbIkiCGMYYqIJq90nYJIo9oBXpAaR3nTLjr+FmvdQ1UnporXP4zf+/fu1Y9L6os6YbmcJCcHizDY/cQO9mk4GvhD1RhSklW8iM5n+sT1iJzVeDi5su8jU9aDr7oFB0aNf9ng91r0YXQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713500668; x=1745036668; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xJa0K4lr/2emu7rU0I0TKx9oru/+26LBqQS3iRUU9Gg=; b=fLnIHX0jgP7uqKOhjDX1X8OCukRc3YQzS/GffzCGoiLpuCwh5In7YmFP 0v27aEqF4h7q+Ir2NQFUZEM7EGwzCORFW1ZynF4SXau3Y/9H2ChebosDS 9mhPW2aC54UsHOfYN0Wt+k+G47IDixt69UVV789uedqq3ru6Iv206nQxM rjkimnV/Y83wAQRwElBcg6wZtEj+5HBi/ERq8NqBLMMnEHsm3xJvPGpNs 5lf7p5YB36zAq/Nn5iKKglUzJu7NA/SNkvoi6k3cjHnm1tKvm0W+btWfo GORVwKYRUkUSCwBxaQ9gzTWIQ+oLJgHs7MwxA1aoyY8/HnTwwdVAsxixV A==; X-CSE-ConnectionGUID: e7pA8D7UTCG/m3XjsZlq6Q== X-CSE-MsgGUID: UWluC5CuRhqOdlBfAKa7rA== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19785388" X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="19785388" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 21:24:26 -0700 X-CSE-ConnectionGUID: vy0IeQtwTgK6+qKwH8pfOw== X-CSE-MsgGUID: fk6d0rviTjGPokxoEn4XoQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,213,1708416000"; d="scan'208";a="60646320" Received: from scymds04.sc.intel.com ([10.82.73.238]) by orviesa001.jf.intel.com with ESMTP; 18 Apr 2024 21:24:26 -0700 Received: from shgcc10.sh.intel.com (unknown [10.239.85.189]) by scymds04.sc.intel.com (Postfix) with ESMTP id E9B852003B3C; Thu, 18 Apr 2024 21:24:24 -0700 (PDT) From: "Cui, Lili" To: binutils@sourceware.org Cc: hjl.tools@gmail.com, jbeulich@suse.com Subject: [PATCH] x86/APX: Add invalid checks for APX EVEX.X4. Date: Fri, 19 Apr 2024 12:24:24 +0800 Message-Id: <20240419042424.1778015-1-lili.cui@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Maintianer, APX spec updated EVEX payload description for bit P[10], this patch is to add invalid checks for APX EVEX.X4. Regards, Lili. APX spec updated EVEX payload description for bit P[10] (now called EVEX.U) to include usage between APX and AVX10 and how it is related to EVEX.X4. EVEX.X4 is defined only when ModRM.Mod != 3. When ModRM.Mod = 3, the U bit must be 1 for all promoted instructions. gas/ChangeLog: * config/tc-i386.c (build_apx_evex_prefix): Added invalid check for APX X4. * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d: Added invalid testcase. * testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s: Ditto. opcodes/ChangeLog: * i386-dis.c (get_valid_dis386): Added invalid check for APX X4. --- gas/config/tc-i386.c | 6 +++++- gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d | 4 ++++ gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s | 7 +++++++ opcodes/i386-dis.c | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 56b2431b1bc..042e8a75296 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4276,7 +4276,11 @@ build_apx_evex_prefix (void) if (i.rex2 & REX_B) i.vex.bytes[1] |= 0x08; if (i.rex2 & REX_X) - i.vex.bytes[2] &= ~0x04; + { + /* EVEX.X4 is defined only when ModRM.Mod != 3. */ + gas_assert (i.rm.mode != 3); + i.vex.bytes[2] &= ~0x04; + } if (i.vex.register_specifier && i.vex.register_specifier->reg_flags & RegRex2) i.vex.bytes[3] &= ~0x08; diff --git a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d index 1a6b6656ff7..9ba62a7ca62 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d +++ b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.d @@ -39,4 +39,8 @@ Disassembly of section .text: [ ]*[a-f0-9]+:[ ]+62 d4 24 18 8f[ ]+\(bad\) [ ]*[a-f0-9]+:[ ]+c3[ ]+.* [ ]*[a-f0-9]+:[ ]+62 fc 7d 0c 60 c7[ ]+movbe \{bad-nf\},%r23w,%ax +[ ]*[a-f0-9]+:[ ]+62 fc 79 08 60[ ]+\(bad\) +[ ]*[a-f0-9]+:[ ]+c2 ff ff[ ]+.* +[ ]*[a-f0-9]+:[ ]+62 ec f8 08 f5[ ]+\(bad\) +[ ]*[a-f0-9]+:[ ]+c3[ ]+.* #pass diff --git a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s index bc55b5e726a..75c583d1a0e 100644 --- a/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s +++ b/gas/testsuite/gas/i386/x86-64-apx-evex-promoted-bad.s @@ -53,3 +53,10 @@ _start: #EVEX_MAP4 movbe %r18w,%ax set EVEX.nf = 1. .insn EVEX.L0.66.M12.W0 0x60, %di, %ax {%k4} + + # EVEX_MAP4 movbe %r18w,%ax set X4 (EVEX.P[10] = 0). + .byte 0x62, 0xfc, 0x79, 0x08, 0x60, 0xc2 + .byte 0xff, 0xff + + # EVEX from VEX bzhi %rax,%rbx,%r16 set X4 (EVEX.P[10] = 0). + .byte 0x62, 0xec, 0xf8, 0x08, 0xf5, 0xc3 diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 3efe65af940..c06dc094c42 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -9190,6 +9190,10 @@ get_valid_dis386 (const struct dis386 *dp, instr_info *ins) if (!fetch_modrm (ins)) return &err_opcode; + /* EVEX.X4 is defined only when ModRM.Mod != 3. */ + if (ins->modrm.mod == 3 && (ins->rex2 & REX_X)) + return &bad_opcode; + /* Set vector length. For EVEX-promoted instructions, evex.ll == 0b00, which has the same encoding as vex.length == 128 and they can share the same processing with vex.length in OP_VEX. */ -- 2.34.1