xchg r8,rax treated as nop
Public bug reported:
xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used.
qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
** Affects: qemu
Importance: Undecided
Status: New
Signature · 11 lines
xchg r8,rax treated as nop https://bugs.launchpad.net/bugs/600589 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: New Bug description: xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used. qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
Quoted 11 lines · On 07/01/2010 05:04 AM, Vic3Dexe wrote:
Public bug reported:
xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used.
qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
** Affects: qemu
Importance: Undecided
Status: New
Verified. Test case for x86_64-linux-user:
.globl main
.type main, @function
main:
movl $0, %r8d movl $1, %eax xchgq %r8, %rax ret
Expected result is exit status 0.
r~
PATCH 1/1 target-i386: Fix xchg rax,r8
We were ignoring REX_B while special-casing NOP, i.e. xchg eax,eax.
--- target-i386/translate.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
target-i386/translate.c +7 -2
@@ -5293,6 +5293,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)break ; case 0x91 ... 0x97: /* xchg R, EAX */ + do_xchg_reg_eax: ot = dflag +OT_WORD ; reg = (b &7 ) |REX_B (s); rm =R_EAX ;
@@ -6663,10 +6664,14 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)/************************/ /* misc */ case 0x90 :/* nop */ -/* XXX: xchg + rex handling */ /* XXX: correct lock test for all insn */ -if (prefixes &PREFIX_LOCK ) +if (prefixes &PREFIX_LOCK ) { goto illegal_op; + } +/* If REX_B is set, then this is xchg eax, r8d, not a nop. */ +if (REX_B (s)) { + goto do_xchg_reg_eax; + }if (prefixes &PREFIX_REPZ ) {gen_svm_check_intercept (s, pc_start,SVM_EXIT_PAUSE ); }
Signature · 1 line
1.7.0.1
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH] target-i386: Fix xchg rax,r8
Quoted 6 lines · Richard Henderson
We were ignoring
REX_Bwhile special-casing NOP, i.e. xchg eax,eax.Signed-off-by Richard Henderson <[email protected]>--- target-i386/translate.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-)
Applied, thanks.
Quoted 34 lines
target-i386/translate.c +7
-2@@ -5293,6 +5293,7 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)break ; case 0x91 ... 0x97: /* xchg R, EAX */ + do_xchg_reg_eax: ot = dflag +OT_WORD ; reg = (b &7 ) |REX_B (s); rm =R_EAX ;@@ -6663,10 +6664,14 @@ static target_ulong disas_insn(DisasContext *s, target_ulong pc_start)/************************/ /* misc */ case 0x90 :/* nop */ -/* XXX: xchg + rex handling */ /* XXX: correct lock test for all insn */ -if (prefixes &PREFIX_LOCK ) +if (prefixes &PREFIX_LOCK ) { goto illegal_op; + } +/* If REX_B is set, then this is xchg eax, r8d, not a nop. */ +if (REX_B (s)) { + goto do_xchg_reg_eax; + }if (prefixes &PREFIX_REPZ ) {gen_svm_check_intercept (s, pc_start,SVM_EXIT_PAUSE ); }Signature · 1 line
1.7.0.1
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Quoted 18 lines · Richard Henderson
Quoted 11 lines · On 07/01/2010 05:04 AM, Vic3Dexe wrote:
Public bug reported:
xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used.
qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
** Affects: qemu
Importance: Undecided
Status: NewVerified. Test case for x86_64-linux-user:
.globl main
.type main, @function
main:
Quoted 7 lines
movl $0, %r8d movl $1, %eax xchgq %r8, %rax retExpected result is exit status 0.
No surprise really:
target-i386/translate.c lines 6665-...
case 0x90: /* nop */
/* XXX: xchg + rex handling */
/* XXX: correct lock test for all insn */The code to handle that just isn't there.
Signature · 1 line
mailto:[email protected]
You wrote 1 июля 2010 г., 19:43:06:
Quoted 30 lines · Richard Henderson
Quoted 19 lines · On 07/01/2010 05:04 AM, Vic3Dexe wrote:
Quoted 11 lines
Public bug reported:
xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used.
qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
** Affects: qemu
Importance: Undecided
Status: NewVerified. Test case for x86_64-linux-user:
.globl main
.type main, @function
main:Quoted 7 lines
movl $0, %r8d movl $1, %eax xchgq %r8, %raxret
Expected result is exit status 0.
No surprise really:
Quoted 7 lines
target-i386/translate.clines 6665-...case 0x90: /* nop */ /* XXX: xchg + rex handling */ /* XXX: correct lock test for all insn */The code to handle that just isn't there.
Sorry for inconvenience, I just forgot to look in source. :) Do you plan to fix it in the near future?
Signature · 2 lines
Best regards, Vic3dexe mailto:[email protected]
Quoted 2 lines · On 07/02/2010 12:13 PM, [email protected] wrote:
Sorry for inconvenience, I just forgot to look in source. :) Do you plan to fix it in the near future?
No, in the near past. ;-)
The fix was committed to qemu.git head yesterday.
r~
Per rth's reply to qemu-devel, fix has been pushed into upstream as of July 1st, commit 7418027ea4fec276455abd4291558bc58a0a7ba7
If problem reappears, please reopen or open a new bug.
Closing
** Changed in: qemu
Status: New => Fix Committed
Signature · 11 lines
xchg r8,rax treated as nop https://bugs.launchpad.net/bugs/600589 You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. Status in QEMU: Fix Committed Bug description: xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used. qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.
** Changed in: qemu
Status: Fix Committed => Fix Released
Signature · 15 lines
You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/600589 Title: xchg r8,rax treated as nop Status in QEMU: Fix Released Bug description: xchg r8,rax (49h 90h) executed as nop (90h) in long mode, in other words REX not used. qemu 0.12.4, host Win 7 x64, running qemu-system-x86_64.exe.