emulate: save/restore host flags in fastop_dispatch#216
emulate: save/restore host flags in fastop_dispatch#216coxuintel merged 1 commit intointel:masterfrom
Conversation
|
OK to verify |
|
emmm I'm investigating another interesting issue in PR#204 recently and finally came to the same root cause as described in this PR, that FLAGS are corrupted after fastop. |
coxuintel
left a comment
There was a problem hiding this comment.
In generally, it's better to add PUSHF/POPF at begin/end and adjust stack_arg offset accordingly.
core/emulate_ops.asm
Outdated
| mov reg_dst, [ebx] | ||
| mov reg_src1, [esi] | ||
| mov reg_src2, [edi] | ||
| pushf |
There was a problem hiding this comment.
I'll suggest move PUSHF to beginning, after push ebp. And move POPF to end, before pop ebp. Then change stack_arg(index) by adding another 0x4 offset. No need to change call stack_arg() so that the fastop handler and remaining arguments are still start from index 0.
core/emulate_ops.asm
Outdated
| mov reg_dst, [rsi] | ||
| mov reg_src1, [r10] | ||
| mov reg_src2, [r11] | ||
| pushf |
There was a problem hiding this comment.
Ditto. Move this PUSHF to beginning and adjust stack_arg() offset. Move POPF to end.
core/emulate_ops.asm
Outdated
| mov reg_dst, [r11] | ||
| mov reg_src1, [r8] | ||
| mov reg_src2, [r9] | ||
| pushf |
|
Looks good to me! Thanks for the patch @jarveson, I also agree with the new |
|
sure, so something like this then? |
coxuintel
left a comment
There was a problem hiding this comment.
The new change looks good to me. I'll merge this PR.
|
@jarveson would you mind update the commit message in your own branch? I'll merge it. |
fastop_dispatch isn't saving/restoring host flags before overwriting with guest flags, which can cause some interesting issues. This fixes that by just pushing and poping host flags before/after executing fastop instruction. Signed-off-by: Jake Arveson <jarveson@gmail.com>
|
like this? otherwise im not fully sure what you mean |
Exactly. Unlike PR comments, detailed commit msg in original commit will remains in git repo which helps future development. |
fastop_dispatch isn't saving/restoring host flags before overwriting with guest flags, which can cause some interesting issues. This fixes that by just pushing and poping host flags before/after executing fastop instruction.