]> git.proxmox.com Git - mirror_qemu.git/commit
target/i386: fix operand size for DATA16 REX.W POPCNT
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 May 2024 10:38:10 +0000 (12:38 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 10 May 2024 13:45:14 +0000 (15:45 +0200)
commit41c685dc59bb611096f3bb6a663cfa82e4cba97b
treef011fcbed8e10538ea3d14f2d576e0c281ada6e7
parent9f07e47a5e96c88c1d2892fbdcbc8ff0437b7ac3
target/i386: fix operand size for DATA16 REX.W POPCNT

According to the manual, 32-bit vs 64-bit is governed by REX.W
and REX ignores the 0x66 prefix.  This can be confirmed with this
program:

    #include <stdio.h>
    int main()
    {
       int x = 0x12340000;
       int y;
       asm("popcntl %1, %0" : "=r" (y) : "r" (x)); printf("%x\n", y);
       asm("mov $-1, %0; .byte 0x66; popcntl %1, %0" : "+r" (y) : "r" (x)); printf("%x\n", y);
       asm("mov $-1, %0; .byte 0x66; popcntq %q1, %q0" : "+r" (y) : "r" (x)); printf("%x\n", y);
    }

which prints 5/ffff0000/5 on real hardware and 5/ffff0000/ffff0000
on QEMU.

Cc: qemu-stable@nongnu.org
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/translate.c