From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by sourceware.org (Postfix) with ESMTPS id C78AD3858034 for ; Fri, 24 Nov 2023 07:02:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C78AD3858034 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 C78AD3858034 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.55.52.88 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700809358; cv=none; b=ctERinxC4cHWiNl2axkYmoz3PkSxHcikYDUweUPFSFGNVxh653WrYO8TmI3ZIVOKsDSQ6fD5f53ImCbzvQ3DtpTbJ9IQaUEkNaSZ6AtOn73gTgBTHGS+/L+e1QRVvQla8eQUcSHOLEBA3Bw9cdgRm+Vhm6gz3DisMLjMBoh9lCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700809358; c=relaxed/simple; bh=1RikQ6wdeQzsOYUgfhArCmkZUlcHeF2T4QXHkReA/ak=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nqXUuGF3KC7SzXaANRGjgIh7/JMt+pp+q9QyAjKSjBItKuB6FvAo3t765zWCAxxABOinKDymqm3Vrg77SMgiDAWwfYuZcYIFDX8pKWUoiMjdLA2ImYlbzgA93ca63frZIoKCecrVtGlPqmHTQMmOs+WrzfLYajcf6HBUZdQVOD0= 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=1700809355; x=1732345355; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1RikQ6wdeQzsOYUgfhArCmkZUlcHeF2T4QXHkReA/ak=; b=RfBzaQp47MM89T3bdhG8oZRNk3sRX1KZzTrc2qDOgwz/yUuiWi/++3ME sRv63OBFpip45B6H2+OXxgRfSsv0lJt2bOX/WG2buIk77gQdAg4M0ntCt Iurf+Wj3xXvJJK/2NtJbxRI2af00/CAV9O8tFfRqWYOpj7FFnoAWGfitd nhLt2zk7Ru+k02R7bOjZTz5jwQTeYIEhnhRALnlBiuPuGr+6YjTeFiyOo tKeVPc+rh2ZYKE936YKPxM1ZCMxD6TlT+MXEtjhFvaAiH4LoNmLicvzAz GXAQBs+Neu9l9UxsLDSG5Zsmme+FS4oKAxWTtjK/5SIBDPvNpx/TxCuAn Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="423513745" X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="423513745" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2023 23:02:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,223,1695711600"; d="scan'208";a="15880750" Received: from scymds04.sc.intel.com ([10.82.73.238]) by fmviesa001.fm.intel.com with ESMTP; 23 Nov 2023 23:02:34 -0800 Received: from shgcc101.sh.intel.com (shgcc101.sh.intel.com [10.239.85.97]) by scymds04.sc.intel.com (Postfix) with ESMTP id 0CAA9200311D; Thu, 23 Nov 2023 23:02:32 -0800 (PST) From: "Cui, Lili" To: binutils@sourceware.org Cc: jbeulich@suse.com, hongjiu.lu@intel.com, "Hu, Lin1" Subject: [PATCH v3 9/9] Support APX JMPABS for disassembler Date: Fri, 24 Nov 2023 07:02:13 +0000 Message-Id: <20231124070213.3886483-9-lili.cui@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231124070213.3886483-1-lili.cui@intel.com> References: <20231124070213.3886483-1-lili.cui@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,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: From: "Hu, Lin1" gas/ChangeLog: * testsuite/gas/i386/x86-64.exp: Ditto. * testsuite/gas/i386/x86-64-apx-jmpabs-intel.d: Ditto. * testsuite/gas/i386/x86-64-apx-jmpabs-inval.d: Ditto. * testsuite/gas/i386/x86-64-apx-jmpabs-inval.s: Ditto. * testsuite/gas/i386/x86-64-apx-jmpabs.d: Ditto. * testsuite/gas/i386/x86-64-apx-jmpabs.s: Ditto. opcodes/ChangeLog: * i386-dis.c (JMPABS_Fixup): New Fixup function to disassemble jmpabs. (print_insn): Add #UD exception for jmpabs. (dis386): Modify a1 unit for support jmpabs. * i386-mnem.h: Regenerated. * i386-opc.tbl: New insns. * i386-tbl.h: Regenerated. --- .../gas/i386/x86-64-apx-jmpabs-intel.d | 11 +++++ .../gas/i386/x86-64-apx-jmpabs-inval.d | 40 ++++++++++++++++++ .../gas/i386/x86-64-apx-jmpabs-inval.s | 15 +++++++ gas/testsuite/gas/i386/x86-64-apx-jmpabs.d | 11 +++++ gas/testsuite/gas/i386/x86-64-apx-jmpabs.s | 5 +++ gas/testsuite/gas/i386/x86-64.exp | 3 ++ opcodes/i386-dis.c | 41 +++++++++++++++++-- 7 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 gas/testsuite/gas/i386/x86-64-apx-jmpabs-intel.d create mode 100644 gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.d create mode 100644 gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.s create mode 100644 gas/testsuite/gas/i386/x86-64-apx-jmpabs.d create mode 100644 gas/testsuite/gas/i386/x86-64-apx-jmpabs.s diff --git a/gas/testsuite/gas/i386/x86-64-apx-jmpabs-intel.d b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-intel.d new file mode 100644 index 00000000000..8c229315904 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-intel.d @@ -0,0 +1,11 @@ +#as: +#objdump: -dw -Mintel +#name: x86_64 APX_F JMPABS insns (Intel disassembly) +#source: x86-64-apx-jmpabs.s + +.*: +file format .* + +Disassembly of section \.text: + +0+ <_start>: +\s*[a-f0-9]+:\s*d5 00 a1 02 00 00 00 00 00 00 00[ ]+jmpabs 0x2 diff --git a/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.d b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.d new file mode 100644 index 00000000000..c3dc0b0ad79 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.d @@ -0,0 +1,40 @@ +#as: --64 +#objdump: -dw +#name: illegal decoding of APX_F jmpabs insns +#source: x86-64-apx-jmpabs-inval.s + +.*: +file format .* + +Disassembly of section \.text: + +0+ <.text>: +\s*[a-f0-9]+: 66 d5 00 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 67 d5 00 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: f2 d5 00 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: f3 d5 00 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: f0 d5 00 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: d5 08 a1[ ]+\(bad\) +\s*[a-f0-9]+: 01 00[ ]+add %eax,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*[a-f0-9]+: 00 00[ ]+add %al,\(%rax\) +\s*... diff --git a/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.s b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.s new file mode 100644 index 00000000000..de4440a5466 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-jmpabs-inval.s @@ -0,0 +1,15 @@ +# Check bytecode of APX_F jmpabs instructions with illegal encode. + + .text +# With 66 prefix + .byte 0x66,0xd5,0x00,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# With 67 prefix + .byte 0x67,0xd5,0x00,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# With F2 prefix + .byte 0xf2,0xd5,0x00,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# With F3 prefix + .byte 0xf3,0xd5,0x00,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# With LOCK prefix + .byte 0xf0,0xd5,0x00,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +# REX2.M0 = 0 REX2.W = 1 + .byte 0xd5,0x08,0xa1,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/gas/testsuite/gas/i386/x86-64-apx-jmpabs.d b/gas/testsuite/gas/i386/x86-64-apx-jmpabs.d new file mode 100644 index 00000000000..f2dbd617527 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-jmpabs.d @@ -0,0 +1,11 @@ +#as: +#objdump: -dw +#name: x86_64 APX_F JMPABS insns +#source: x86-64-apx-jmpabs.s + +.*: +file format .* + +Disassembly of section \.text: + +0+ <_start>: +\s*[a-f0-9]+:\s*d5 00 a1 02 00 00 00 00 00 00 00[ ]+jmpabs \$0x2 diff --git a/gas/testsuite/gas/i386/x86-64-apx-jmpabs.s b/gas/testsuite/gas/i386/x86-64-apx-jmpabs.s new file mode 100644 index 00000000000..69ffb763260 --- /dev/null +++ b/gas/testsuite/gas/i386/x86-64-apx-jmpabs.s @@ -0,0 +1,5 @@ +# Check 64bit APX_F JMPABS instructions + + .text + _start: + .byte 0xd5,0x00,0xa1,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00 diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp index 034fc49b180..8b41f9891a5 100644 --- a/gas/testsuite/gas/i386/x86-64.exp +++ b/gas/testsuite/gas/i386/x86-64.exp @@ -374,6 +374,9 @@ run_dump_test "x86-64-apx-evex-promoted" run_dump_test "x86-64-apx-evex-promoted-intel" run_dump_test "x86-64-apx-evex-egpr" run_dump_test "x86-64-apx-ndd" +run_dump_test "x86-64-apx-jmpabs" +run_dump_test "x86-64-apx-jmpabs-intel" +run_dump_test "x86-64-apx-jmpabs-inval" run_dump_test "x86-64-avx512f-rcigrz-intel" run_dump_test "x86-64-avx512f-rcigrz" run_dump_test "x86-64-clwb" diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 0612b0cd4b4..b33b44d7c27 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -106,6 +106,7 @@ static bool MOVSXD_Fixup (instr_info *, int, int); static bool DistinctDest_Fixup (instr_info *, int, int); static bool PREFETCHI_Fixup (instr_info *, int, int); static bool PUSH2_POP2_Fixup (instr_info *, int, int); +static bool JMPABS_Fixup (instr_info *, int, int); static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const disassemble_info *, enum disassembler_style, @@ -2021,7 +2022,7 @@ static const struct dis386 dis386[] = { { "lahf", { XX }, 0 }, /* a0 */ { "mov%LB", { AL, Ob }, PREFIX_REX2_ILLEGAL }, - { "mov%LS", { eAX, Ov }, PREFIX_REX2_ILLEGAL }, + { "mov%LS", { { JMPABS_Fixup, eAX_reg }, { JMPABS_Fixup, v_mode } }, PREFIX_REX2_ILLEGAL }, { "mov%LB", { Ob, AL }, PREFIX_REX2_ILLEGAL }, { "mov%LS", { Ov, eAX }, PREFIX_REX2_ILLEGAL }, { "movs{b|}", { Ybr, Xb }, PREFIX_REX2_ILLEGAL }, @@ -9689,7 +9690,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax) } if ((dp->prefix_requirement & PREFIX_REX2_ILLEGAL) - && ins.last_rex2_prefix >= 0) + && ins.last_rex2_prefix >= 0 && (ins.rex2 & 16) == 0) { i386_dis_printf (info, dis_style_text, "(bad)"); ret = ins.end_codep - priv.the_buffer; @@ -9774,7 +9775,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax) ins.all_prefixes[ins.last_rex_prefix] = 0; /* Check if the REX2 prefix is used. */ - if (ins.last_rex2_prefix >= 0 && (ins.rex2 & 7)) + if (ins.last_rex2_prefix >= 0 && (ins.rex2 & 23)) ins.all_prefixes[ins.last_rex2_prefix] = 0; /* Check if the SEG prefix is used. */ @@ -13917,3 +13918,37 @@ PUSH2_POP2_Fixup (instr_info *ins, int bytemode, int sizeflag) return OP_VEX (ins, bytemode, sizeflag); } + +static bool +JMPABS_Fixup (instr_info *ins, int bytemode, int sizeflag) +{ + if (ins->address_mode == mode_64bit + && ins->last_rex2_prefix >= 0 + && (ins->rex2 & 0x80) == 0x0) + { + uint64_t op; + + if (bytemode == eAX_reg) + return true; + + if (!get64 (ins, &op)) + return false; + + if ((ins->prefixes & (PREFIX_OPCODE | PREFIX_ADDR | PREFIX_LOCK)) != 0x0 + || (ins->rex & REX_W) != 0x0) + { + oappend (ins, "(bad)"); + return true; + } + + ins->mnemonicendp = stpcpy (ins->obuf, "jmpabs"); + ins->rex2 |= 16; + oappend_immediate (ins, op); + + return true; + } + + if (bytemode == eAX_reg) + return OP_IMREG (ins, bytemode, sizeflag); + return OP_OFF64 (ins, bytemode, sizeflag); +} -- 2.25.1