| Summary: | VEX should support REX.W + POPF | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | Mike Dalessio <mike.dalessio> |
| Component: | vex | Assignee: | Julian Seward <jseward> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mark, mike.dalessio |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Mint (Ubuntu based) | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Mike Dalessio
2021-02-11 17:31:49 UTC
We had something similar in bug #422174 with REX prefixed JMP instructions. Lets see what the instruction manual says... (In reply to Mark Wielaard from comment #1) > We had something similar in bug #422174 with REX prefixed JMP instructions. > Lets see what the instruction manual says... It says (for PUSH, POP, PUSHF/D/Q, POPF/D/Q and LEAVE): "When in 64-bit mode, instruction defaults to 64-bit operand size and cannot encode 32-bit operand size." Which is explains the sz == to sz = 8 "upgrade" we always do. It seems a REX.W prefix simply explicitly sets the operant size to 8, and so can/must be ignored as redundant. I checked. PUSH and POP do always upgrade sz == 4 to sz = 8 but allow sz == 8 too. PUSHF actually has a note about having seen a dedundant REX prefix:
case 0x9C: /* PUSHF */ {
/* Note. There is no encoding for a 32-bit pushf in 64-bit
mode. So sz==4 actually means sz==8. */
/* 24 July 06: has also been seen with a redundant REX prefix,
so must also allow sz==8. */
We don't handle sz == 8 for LEAVE. But reading the instruction manual that seems tricky since it has to match the size operand of the corresponding ENTER (where we also don't handle sz == 8).
In summary, I think the patch is correct.
commit e2e830f61271c28dddfa6b478044870d2188cf57 Author: Mark Wielaard <mark@klomp.org> Date: Fri Feb 12 20:42:00 2021 +0100 PR432809 VEX should support REX.W + POPF It seems a REX.W prefix simply explicitly sets the operant size to 8, and so can/must be ignored as redundant. This is what we already do for PUSH, POP and PUSHF. All instructions are described as "When in 64-bit mode, instruction defaults to 64-bit operand size and cannot encode 32-bit operand size." in the instruction manual. Original patch and analysis by Mike Dalessio <mike.dalessio@gmail.com> https://bugs.kde.org/show_bug.cgi?id=432809 Thank you for the quick turnaround! |