From b8efd62e7856de987113db1e271cb22838a4dbe0 Mon Sep 17 00:00:00 2001 From: MayShao-oc Date: Mon, 16 Dec 2024 13:54:13 +0800 Subject: [PATCH] x86: Change padlock instructions prefix as rep Hi all: This patch change the display of all padlock instructions prefix from repz to rep, because padlock instructions don't effect zf flag. Test ok, ok for trunk? BR Mayshao gas/ChangeLog: * testsuite/gas/i386/padlock.d: Change padlock instructions prefix. opcodes/ChangeLog: * i386-dis.c (OP_0f07): Delete. (MONTMUL_Fixup): Ditto. (PADLOCK_Fixup): New. --- gas/testsuite/gas/i386/padlock.d | 32 +++++++++++++-------------- gas/testsuite/gas/i386/padlock.s | 2 +- opcodes/i386-dis.c | 37 ++++++++++++-------------------- opcodes/i386-opc.h | 2 +- opcodes/i386-opc.tbl | 2 +- 5 files changed, 33 insertions(+), 42 deletions(-) diff --git a/gas/testsuite/gas/i386/padlock.d b/gas/testsuite/gas/i386/padlock.d index eae6b24ac3e..663b1ab0697 100644 --- a/gas/testsuite/gas/i386/padlock.d +++ b/gas/testsuite/gas/i386/padlock.d @@ -7,21 +7,21 @@ Disassembly of section .text: 0+000 : 0:[ ]*0f a7 c0 [ ]*xstore-rng - 3:[ ]*f3 0f a7 c0 [ ]*repz xstore-rng - 7:[ ]*f3 0f a7 c8 [ ]*repz xcrypt-ecb - b:[ ]*f3 0f a7 c8 [ ]*repz xcrypt-ecb - f:[ ]*f3 0f a7 d0 [ ]*repz xcrypt-cbc - 13:[ ]*f3 0f a7 d0 [ ]*repz xcrypt-cbc - 17:[ ]*f3 0f a7 e0 [ ]*repz xcrypt-cfb - 1b:[ ]*f3 0f a7 e0 [ ]*repz xcrypt-cfb - 1f:[ ]*f3 0f a7 e8 [ ]*repz xcrypt-ofb - 23:[ ]*f3 0f a7 e8 [ ]*repz xcrypt-ofb + 3:[ ]*f3 0f a7 c0 [ ]*rep xstore-rng + 7:[ ]*f3 0f a7 c8 [ ]*rep xcrypt-ecb + b:[ ]*f3 0f a7 c8 [ ]*rep xcrypt-ecb + f:[ ]*f3 0f a7 d0 [ ]*rep xcrypt-cbc + 13:[ ]*f3 0f a7 d0 [ ]*rep xcrypt-cbc + 17:[ ]*f3 0f a7 e0 [ ]*rep xcrypt-cfb + 1b:[ ]*f3 0f a7 e0 [ ]*rep xcrypt-cfb + 1f:[ ]*f3 0f a7 e8 [ ]*rep xcrypt-ofb + 23:[ ]*f3 0f a7 e8 [ ]*rep xcrypt-ofb 27:[ ]*0f a7 c0 [ ]*xstore-rng - 2a:[ ]*f3 0f a7 c0 [ ]*repz xstore-rng - 2e:[ ]*f3 0f a6 c0 [ ]*repz montmul - 32:[ ]*f3 0f a6 c0 [ ]*repz montmul - 36:[ ]*f3 0f a6 c8 [ ]*repz xsha1 - 3a:[ ]*f3 0f a6 c8 [ ]*repz xsha1 - 3e:[ ]*f3 0f a6 d0 [ ]*repz xsha256 - 42:[ ]*f3 0f a6 d0 [ ]*repz xsha256 + 2a:[ ]*f3 0f a7 c0 [ ]*rep xstore-rng + 2e:[ ]*f3 0f a6 c0 [ ]*rep montmul + 32:[ ]*f3 0f a6 c0 [ ]*rep montmul + 36:[ ]*f3 0f a6 c8 [ ]*rep xsha1 + 3a:[ ]*f3 0f a6 c8 [ ]*rep xsha1 + 3e:[ ]*f3 0f a6 d0 [ ]*rep xsha256 + 42:[ ]*f3 0f a6 d0 [ ]*rep xsha256 #pass diff --git a/gas/testsuite/gas/i386/padlock.s b/gas/testsuite/gas/i386/padlock.s index b4a19506b27..6c22fab90fa 100644 --- a/gas/testsuite/gas/i386/padlock.s +++ b/gas/testsuite/gas/i386/padlock.s @@ -1,4 +1,4 @@ -# VIA Nehemiah PadLock instructions +# ZHAOXIN PadLock instructions .text foo: diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 8795e397082..ef926c303e5 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -82,7 +82,6 @@ static bool OP_VexW (instr_info *, int, int); static bool OP_Rounding (instr_info *, int, int); static bool OP_REG_VexI4 (instr_info *, int, int); static bool OP_VexI4 (instr_info *, int, int); -static bool OP_0f07 (instr_info *, int, int); static bool OP_Monitor (instr_info *, int, int); static bool OP_Mwait (instr_info *, int, int); @@ -90,7 +89,7 @@ static bool PCLMUL_Fixup (instr_info *, int, int); static bool VPCMP_Fixup (instr_info *, int, int); static bool VPCOM_Fixup (instr_info *, int, int); static bool NOP_Fixup (instr_info *, int, int); -static bool MONTMUL_Fixup (instr_info *, int, int); +static bool PADLOCK_Fixup (instr_info *, int, int); static bool OP_3DNowSuffix (instr_info *, int, int); static bool CMP_Fixup (instr_info *, int, int); static bool REP_Fixup (instr_info *, int, int); @@ -2897,20 +2896,20 @@ static const struct dis386 reg_table[][8] = { /* REG_0FA6 */ { { PREFIX_TABLE (PREFIX_0FA6_REG_0) }, - { "xsha1", { { OP_0f07, 0 } }, 0 }, - { "xsha256", { { OP_0f07, 0 } }, 0 }, + { "xsha1", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xsha256", { { PADLOCK_Fixup, 0 } }, 0 }, { Bad_Opcode }, { Bad_Opcode }, { PREFIX_TABLE (PREFIX_0FA6_REG_5) }, }, /* REG_0FA7 */ { - { "xstore-rng", { { OP_0f07, 0 } }, 0 }, - { "xcrypt-ecb", { { OP_0f07, 0 } }, 0 }, - { "xcrypt-cbc", { { OP_0f07, 0 } }, 0 }, - { "xcrypt-ctr", { { OP_0f07, 0 } }, 0 }, - { "xcrypt-cfb", { { OP_0f07, 0 } }, 0 }, - { "xcrypt-ofb", { { OP_0f07, 0 } }, 0 }, + { "xstore-rng", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xcrypt-ecb", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xcrypt-cbc", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xcrypt-ctr", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xcrypt-cfb", { { PADLOCK_Fixup, 0 } }, 0 }, + { "xcrypt-ofb", { { PADLOCK_Fixup, 0 } }, 0 }, { PREFIX_TABLE (PREFIX_0FA7_REG_6) }, }, /* REG_0FAE */ @@ -3495,7 +3494,7 @@ static const struct dis386 prefix_table[][4] = { /* PREFIX_0FA6_REG_0 */ { { Bad_Opcode }, - { "montmul", { { MONTMUL_Fixup, 0 } }, 0}, + { "montmul", { { PADLOCK_Fixup, 0 } }, 0}, { Bad_Opcode }, { "sm2", { Skip_MODRM }, 0 }, }, @@ -13191,25 +13190,17 @@ OP_M (instr_info *ins, int bytemode, int sizeflag) return OP_E_memory (ins, bytemode, sizeflag); } -static bool -OP_0f07 (instr_info *ins, int bytemode, int sizeflag) -{ - if (ins->modrm.mod != 3 || ins->modrm.rm != 0) - return BadOp (ins); - return OP_E (ins, bytemode, sizeflag); -} - -/* montmul instruction need display repz and skip modrm */ +/* padlock instruction need display rep and skip modrm */ static bool -MONTMUL_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) +PADLOCK_Fixup (instr_info *ins, int bytemode ATTRIBUTE_UNUSED, int sizeflag ATTRIBUTE_UNUSED) { if (ins->modrm.mod != 3 || ins->modrm.rm != 0) return BadOp (ins); - /* The 0xf3 prefix should be displayed as "repz" for montmul. */ + /* The 0xf3 prefix should be displayed as "rep" for padlock. */ if (ins->prefixes & PREFIX_REPZ) - ins->all_prefixes[ins->last_repz_prefix] = 0xf3; + ins->all_prefixes[ins->last_repz_prefix] = REP_PREFIX; /* Skip mod/rm byte. */ MODRM_CHECK; diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h index e50f518ec1a..9d20f0a4359 100644 --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -64,7 +64,7 @@ enum i386_cpu CpuSSE2, /* SSE3 support required */ CpuSSE3, - /* VIA PadLock required */ + /* ZHAOXIN PadLock required */ CpuPadLock, /* ZHAOXIN GMI required */ CpuGMI, diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl index 502264cb78a..2e973a4a9b1 100644 --- a/opcodes/i386-opc.tbl +++ b/opcodes/i386-opc.tbl @@ -2114,7 +2114,7 @@ lzcnt, 0xf5, LZCNT&APX_F, Modrm|CheckOperandSize|No_bSuf|No_sSuf|EVexMap4|NF, { popcnt, 0xf30fb8, POPCNT, Modrm|CheckOperandSize|No_bSuf|No_sSuf, { Reg16|Reg32|Reg64|Unspecified|BaseIndex, Reg16|Reg32|Reg64 } popcnt, 0x88, POPCNT&APX_F, Modrm|CheckOperandSize|No_bSuf|No_sSuf|EVexMap4|NF, { Reg16|Reg32|Reg64|Unspecified|BaseIndex, Reg16|Reg32|Reg64 } -// VIA PadLock extensions. +// ZHAOXIN PadLock extensions. xstore-rng, 0xfa7c0, PadLock, NoSuf|RepPrefixOk, {} xcrypt-ecb, 0xf30fa7c8, PadLock, NoSuf|RepPrefixOk, {} xcrypt-cbc, 0xf30fa7d0, PadLock, NoSuf|RepPrefixOk, {} -- 2.27.0