52 lines
1.8 KiB
Diff
52 lines
1.8 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Paolo Bonzini <pbonzini@redhat.com>
|
||
|
Date: Thu, 9 May 2024 12:38:10 +0200
|
||
|
Subject: [PATCH] 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>
|
||
|
(cherry picked from commit 41c685dc59bb611096f3bb6a663cfa82e4cba97b)
|
||
|
[FE: keep mo_64_32 helper which still has other users in 9.0.0]
|
||
|
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
|
||
|
---
|
||
|
target/i386/tcg/translate.c | 7 +------
|
||
|
1 file changed, 1 insertion(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
|
||
|
index 76a42c679c..b60f3bd642 100644
|
||
|
--- a/target/i386/tcg/translate.c
|
||
|
+++ b/target/i386/tcg/translate.c
|
||
|
@@ -6799,12 +6799,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
|
||
|
modrm = x86_ldub_code(env, s);
|
||
|
reg = ((modrm >> 3) & 7) | REX_R(s);
|
||
|
|
||
|
- if (s->prefix & PREFIX_DATA) {
|
||
|
- ot = MO_16;
|
||
|
- } else {
|
||
|
- ot = mo_64_32(dflag);
|
||
|
- }
|
||
|
-
|
||
|
+ ot = dflag;
|
||
|
gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
|
||
|
gen_extu(ot, s->T0);
|
||
|
tcg_gen_mov_tl(cpu_cc_src, s->T0);
|