x86: PUSHF/POPF address size fixes (64-bit mode) #6601
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
addrsize
should be ignored for PUSHF/POPF instructions. This was potentially used before theLONGMODE_ON
context bit was introduced to distinguish the 64-bit behavior from the 32-bit behavior. Sinceaddrsize
can be manipulated using the address size override prefix, it can cause the wrong PUSHF/POPF size to be decoded. TheLONGMODE_ON
constraint is now sufficient, so this PR simply removes the unnecessaryaddrsize
constraint.e.g.,
PUSHF
withRSP=0x1002
,ZF=1
mem[0x1000] = 4201
,RSP=0x1000
}x86:LE:64:default
(Existing):"PUSHFQ"
{mem[0xffa] = 4000000000000000
,RSP=0x0ffa
}x86:LE:64:default
(This patch):"PUSHF"
{mem[0x1000] = 4000
,RSP=0x1000
}(Note: on the hardware reference, extra bits that are set correspond to
EFLAGS.res1
(bit 1) andEFLAGS.TF
(bit 8))POPF
withRSP=0x1000
,mem[0x1000] = 4000
ZF=1
,RSP=0x1002
}x86:LE:64:default
(Existing): Invalid Instructionx86:LE:64:default
(This patch):"PUSHF"
{ZF=1
,RSP=0x1002
}The
LONGMODE_OFF
constructors have been left alone in this PR, although they technically should also ignore address size overrides. WithLONGMODE_OFF
, the address size is used to determine whether thesegment
pcodeop is applied during address translation, however segmentation should still be applied in 32-bit protected mode, but since most users are likely to be working with 32-bit programs where segment bases are all zero, the current behavior probably behaves better than injectingsegment
ops everywhere.(It could make sense to introduce pseudo registers like
CS.base
/DS.base
/etc... that are assumed to be zero but are user overridable, like the way the direction flag is handled)