You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: MOV instructions for CR/DR registers accept memory operands in addition to registers.
Both AMD and Intel manuals don't specify memory args as valid.
This can lead to unexpected results for the programmer.
Solution: fix Yml operand class to Yrl. Not totally backwards-compatible.
Details below.
MOV DebugReg instructions describe non-DR argument as reg/mem (Yml) instead of just reg (Yrl):
MOV_DR is special because it's ModR/M.MOD bits are all aliased to 0b11 (reg).
In theory, they should execute identically (source, see "COMMENT").
Also, quote from AMD manual for MOV DR:
The MOV(DR) instruction is always treated as a register-to-regi ster (MOD = 11) instruction, regardless of the encoding of the MOD field in the MODR/M byte
This makes it debatable whether we should forbid memory arguments or not, but it's almost certainly an error to use memory operand with displacement (SIB byte is error, too).
Here are external disassemblers output for code above:
If we change Yml to Yrl, weird behavior can be mitigated, but this is not backwards-compatible.
Not sure if anyone depends on this.
Maybe such code can be considered as broken anyway.
Everything above also applies to CR moves.
The text was updated successfully, but these errors were encountered:
I think we should fix it, rejecting the invalid cases. MOVL DR0, (AX) looks like a store, but the machine instruction it generates is not. MOVL DR0, 777(AX) is even worse.
Originated from CL107075.
Problem: MOV instructions for CR/DR registers accept memory operands in addition to registers.
Both AMD and Intel manuals don't specify memory args as valid.
This can lead to unexpected results for the programmer.
Solution: fix
Yml
operand class toYrl
. Not totally backwards-compatible.Details below.
MOV DebugReg
instructions describe non-DR argument as reg/mem (Yml) instead of just reg (Yrl):go/src/cmd/internal/obj/x86/asm6.go
Lines 3545 to 3560 in dd71e3f
Note that two entries have expected
Yrl
, they were added later:So, all lines below are assembled:
MOV_DR
is special because it'sModR/M.MOD
bits are all aliased to0b11
(reg).In theory, they should execute identically (source, see "COMMENT").
Also, quote from AMD manual for
MOV DR
:This makes it debatable whether we should forbid memory arguments or not, but it's almost certainly an error to use memory operand with displacement (SIB byte is error, too).
Here are external disassemblers output for code above:
XED accepts all MOD bits combinations, but not displacement immediate itself.
If we change
Yml
toYrl
, weird behavior can be mitigated, but this is not backwards-compatible.Not sure if anyone depends on this.
Maybe such code can be considered as broken anyway.
Everything above also applies to
CR
moves.The text was updated successfully, but these errors were encountered: