From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id 2326B3858D33 for ; Thu, 1 Feb 2024 22:47:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2326B3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2326B3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706827674; cv=none; b=fKTgtdLfpP82abzlXnqPwecm5+UyOC6WL+VBNfcQ9tUaT2MJcxrJE6bIRpr+Aa0AxA54v9HpkE7FazbbPAokYW2A2bwRmW+iTUUc8iCNeQeCbXXqh3zdG/L8sNErI6hn3iFLuUhSqZgM93/uVQtdV46IcHsrtRKOMP8ByGn1qcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706827674; c=relaxed/simple; bh=99DMxUEQM9Lzm+Es47rIc/Cb1w0XbZ1zWtwQLlGNHHY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ieHIioBJKxDc+0l1qZCQreQFMThtgTIZTUhnOtTInllk7C1GYmPdXFtc/H+8VuKinMkaU9FYi9XpwUUEdb8ZOrhQyImSDGcVGmyWp/a5xC7aW34Xh0AH76F7X+/3R1fMZc2t6VVCDXy+tvdIDO8AkyNgwIkD+jOiFDagXrwPVIg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5cddc5455aeso1357810a12.1 for ; Thu, 01 Feb 2024 14:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706827671; x=1707432471; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TbXzJNSoez7obzZbUYE251WnozeyTbkB+a0+vSxFTwg=; b=laUPQBES6GyBQtfg4ESoAxW/CVcJ1T+LKPL+4oDkujiAzM/T4Nq3rhfFIIQAAv/Lqq ikMa5c8HZnK52Z/wm3vvwBDUFLLR7CXbR4VZjqf0+phY/SqqmuMJU/Ok/JubOTRl0msn FQu457yJ4YkQ3w8armgIxNa4WwjDxruYF1ENVa4lSTCRkfYMTQgUxdvsx1Ez+VL5C8+E TTe7rvFVYYyxXoByv+UExz2/UtmWRDgE4AVMC/du5CDO+GZLOmxC96pqOzEFFcRjBoaf UP1koCljSAR//of0B3esZnJYsN2/e9SkWLc8Z1QKy1Tjmd7CGOBiSSBqruN0kXxOs8ra W/xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706827671; x=1707432471; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TbXzJNSoez7obzZbUYE251WnozeyTbkB+a0+vSxFTwg=; b=oTjx92CUzjpY13ETG+XzgXWN8ysr+YWoX2nr9ptvBaFC/YDOZl6MJRc8VlRxSt5qFm eZp3OIiztK1waeDjQvZJlTzEKlbtcH9ROpDyJD4JyeDDQoHTp8ZEyN6kJwSbXqzybItF YYpsY0NbDweh8hceFabyW26tUBPpObp7Q+0Gl1MrXx79USeYcYwW5fp5wqBDZOapmecT 0K+TrU8hwEwe45FFeafD/eh/LD3Q5uNxM57JkjvfQhzH0RR7UHMBZkXjXlW7iAkJa2Ip MiKqlbS/1iSMboZ/iL5Y9SlDmxQQlynHGDIdB0VP1C0KV+/+hqKbas5l7kV6YCSrhXBd PW8w== X-Gm-Message-State: AOJu0Yw6lXHdWgRNgfpn2DwwLx/2cKE+yg1bG1EaFhlqLKjGICwk+UAo 1+RBgtIhfdqJ4dDiJZdlc/cZ+VNINpDBtzaF+G+6L0JeTxorDzeHruUtrLNE X-Google-Smtp-Source: AGHT+IGR7kYhn+7imwgJiy40oZkWKuYzJWsu6vrUAzGOFQInHaR5X6mf1z2VRUn3Xs1S/fz3QTE3Ew== X-Received: by 2002:a17:90a:fd0f:b0:28c:fb86:23ce with SMTP id cv15-20020a17090afd0f00b0028cfb8623cemr422582pjb.44.1706827670948; Thu, 01 Feb 2024 14:47:50 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.56.169.51]) by smtp.gmail.com with ESMTPSA id i18-20020a17090acf9200b00295f71da63dsm3387155pju.53.2024.02.01.14.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:47:50 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 583E6740270; Thu, 1 Feb 2024 14:47:49 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Cc: wwwhhhyyy333@gmail.com Subject: [PATCH] x86: Disallow APX instruction with length > 15 bytes Date: Thu, 1 Feb 2024 14:47:49 -0800 Message-ID: <20240201224749.214439-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3023.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: It is a hard error when an APX instruction length exceeds the limit of 15 bytes: [hjl@gnu-cfl-3 pr31323]$ cat z.s addq $0xe0, %fs:0, %rdx [hjl@gnu-cfl-3 pr31323]$ as -o z.o z.s z.s: Assembler messages: z.s:1: Warning: instruction length of 16 bytes exceeds the limit of 15 [hjl@gnu-cfl-3 pr31323]$ objdump -dw z.o z.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <.text>: 0: 64 62 f4 ec 18 81 04 25 00 00 00 00 e0 00 00 (bad) ... [hjl@gnu-cfl-3 pr31323]$ We should issue an error when APX instruction length exceeds the limit of 15 bytes. PR gas/31323 * config/tc-i386.c (output_insn): Issue an error when APX instruction length exceeds the limit of 15 bytes. * testsuite/gas/i386/x86-64-apx-inval.l: New file. * testsuite/gas/i386/x86-64-apx-inval.s: Likewise. --- gas/config/tc-i386.c | 10 ++++++++-- gas/testsuite/gas/i386/x86-64-apx-inval.l | 3 +++ gas/testsuite/gas/i386/x86-64-apx-inval.s | 4 ++++ gas/testsuite/gas/i386/x86-64.exp | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 gas/testsuite/gas/i386/x86-64-apx-inval.l create mode 100644 gas/testsuite/gas/i386/x86-64-apx-inval.s diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 3c64057fd67..d1e522d3637 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -11772,8 +11772,14 @@ output_insn (const struct last_insn *last_insn) { j = encoding_length (insn_start_frag, insn_start_off, frag_more (0)); if (j > 15) - as_warn (_("instruction length of %u bytes exceeds the limit of 15"), - j); + { + if (i.tm.cpu.bitfield.cpuapx_f) + as_bad (_("instruction length of %u bytes exceeds the limit of 15"), + j); + else + as_warn (_("instruction length of %u bytes exceeds the limit of 15"), + j); + } else if (fragP) { /* NB: Don't add prefix with GOTPC relocation since diff --git a/gas/testsuite/gas/i386/x86-64-apx-inval.l b/gas/testsuite/gas/i386/x86-64-apx-inval.l new file mode 100644 index 00000000000..6c1a346fcbf --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-inval.l @@ -0,0 +1,3 @@ +.*: Assembler messages: +.*:3: Error: instruction length of 16 bytes exceeds the limit of 15 +.*:4: Error: instruction length of 16 bytes exceeds the limit of 15 diff --git a/gas/testsuite/gas/i386/x86-64-apx-inval.s b/gas/testsuite/gas/i386/x86-64-apx-inval.s new file mode 100644 index 00000000000..bb57817bc8a --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-inval.s @@ -0,0 +1,4 @@ +# Check illegal 64bit APX_F instructions + .text + addq $0xe0, %fs:0, %rdx + xorq $0xe0, foo(%eax,%edx), %rdx diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp index 6932ba97a4d..b77e8c10029 100644 --- a/gas/testsuite/gas/i386/x86-64.exp +++ b/gas/testsuite/gas/i386/x86-64.exp @@ -371,6 +371,7 @@ run_dump_test "x86-64-avx512f-rcigrne-intel" run_dump_test "x86-64-avx512f-rcigrne" run_dump_test "x86-64-avx512f-rcigru-intel" run_dump_test "x86-64-avx512f-rcigru" +run_list_test "x86-64-apx-inval" run_list_test "x86-64-apx-egpr-inval" run_dump_test "x86-64-apx-evex-promoted-bad" run_list_test "x86-64-apx-egpr-promote-inval" "-al" -- 2.43.0