x86: PadLock adjustments

For one, all PadLock insns depend on CR4.FXSR to be enabled, which means
they ought to be taking FXSR as a prereq.

Furthermore none of them permits a REPNE prefix; such forms are documented
to cause #UD. (This is mainly relevant for XSTORE, which doesn't include a
REP prefix in its base encoding. For the others this merely is a change in
what diagnostic is issued.)

Finally it is documented that an operand size prefix also causes #UD.
This commit is contained in:
Jan Beulich
2025-10-10 09:26:24 +02:00
parent d4c517eec1
commit 5690a49ac7
9 changed files with 133 additions and 105 deletions

View File

@@ -4899,11 +4899,6 @@ check_hle (void)
switch (i.tm.opcode_modifier.prefixok)
{
default:
abort ();
case PrefixLock:
case PrefixNone:
case PrefixNoTrack:
case PrefixRep:
as_bad (_("invalid instruction `%s' after `%s'"),
insn_name (&i.tm), i.hle_prefix);
return 0;
@@ -7372,7 +7367,9 @@ i386_assemble (char *line)
return;
/* Check if REP prefix is OK. */
if (i.rep_prefix && i.tm.opcode_modifier.prefixok != PrefixRep)
if (i.rep_prefix && i.tm.opcode_modifier.prefixok != PrefixRep
&& (i.prefix[REP_PREFIX] != REPE_PREFIX_OPCODE
|| i.tm.opcode_modifier.prefixok != PrefixRepe))
{
as_bad (_("invalid instruction `%s' after `%s'"),
insn_name (&i.tm), i.rep_prefix);
@@ -7416,9 +7413,13 @@ i386_assemble (char *line)
if ((is_any_vex_encoding (&i.tm) && i.tm.opcode_space != SPACE_MAP4)
|| i.tm.operand_types[i.imm_operands].bitfield.class >= RegMMX
|| i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX)
|| i.tm.operand_types[i.imm_operands + 1].bitfield.class >= RegMMX
/* (Ab)use the PrefixRepe attribute of PadLock insns as long as no
others use it. */
|| i.tm.opcode_modifier.prefixok == PrefixRepe)
{
/* Check for data size prefix on VEX/XOP/EVEX encoded and SIMD insns. */
/* Check for data size prefix on VEX/XOP/EVEX encoded, SIMD, and
PadLock insns. */
if (i.prefix[DATA_PREFIX])
{
as_bad (_("data size prefix invalid with `%s'"), insn_name (&i.tm));

View File

@@ -114,6 +114,7 @@ if [gas_32_check] then {
run_dump_test "quoted2"
run_dump_test "unary"
run_dump_test "padlock"
run_list_test "padlock-bad"
run_dump_test "gmi"
run_dump_test "padlockrng2"
run_dump_test "padlockphe2"

View File

@@ -0,0 +1,5 @@
.* Assembler messages:
.*:8: Error: invalid instruction `xstore' after `repne'
.*:10: Error: data size prefix invalid with `xstore'
.*:15: Error: invalid instruction `xsha1' after `repne'
.*:17: Error: data size prefix invalid with `xsha1'

View File

@@ -0,0 +1,17 @@
# VIA Nehemiah PadLock instructions w/ (problematic) prefixes
.text
foo:
xstore
rep xstore
repe xstore
repne xstore
data16 xstore
xsha1
rep xsha1
repe xsha1
repne xsha1
data16 xsha1