[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.2.5 06/21] target/i386: fix operand size for DATA16 REX.W POPC
From: |
Michael Tokarev |
Subject: |
[Stable-8.2.5 06/21] target/i386: fix operand size for DATA16 REX.W POPCNT |
Date: |
Mon, 27 May 2024 10:24:16 +0300 |
From: Paolo Bonzini <pbonzini@redhat.com>
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)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 6ca4d791ab..47d2d1bb16 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -420,16 +420,6 @@ static inline MemOp mo_stacksize(DisasContext *s)
return CODE64(s) ? MO_64 : SS32(s) ? MO_32 : MO_16;
}
-/* Select only size 64 else 32. Used for SSE operand sizes. */
-static inline MemOp mo_64_32(MemOp ot)
-{
-#ifdef TARGET_X86_64
- return ot == MO_64 ? MO_64 : MO_32;
-#else
- return MO_32;
-#endif
-}
-
/* Select size 8 if lsb of B is clear, else OT. Used for decoding
byte vs word opcodes. */
static inline MemOp mo_b_d(int b, MemOp ot)
@@ -6780,12 +6770,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);
--
2.39.2
- [Stable-8.2.5 00/21] Patch Round-up for stable 8.2.5, freeze on 2024-06-07, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 01/21] target/i386: Give IRQs a chance when resetting HF_INHIBIT_IRQ_MASK, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 02/21] target/sparc: Fix FEXPAND, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 06/21] target/i386: fix operand size for DATA16 REX.W POPCNT,
Michael Tokarev <=
- [Stable-8.2.5 08/21] target/i386: fix feature dependency for WAITPKG, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 04/21] hw/loongarch/virt: Fix memory leak, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 07/21] target/i386: rdpkru/wrpkru are no-prefix instructions, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 10/21] configure: Fix error message when C compiler is not working, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 03/21] target/sparc: Fix FMUL8x16, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 05/21] hw/remote/vfio-user: Fix config space access byte order, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 12/21] ui/gtk: Check if fence_fd is equal to or greater than 0, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 09/21] configure: quote -D options that are passed through to meson, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 11/21] ui/gtk: Fix mouse/motion event scaling issue with GTK display backend, Michael Tokarev, 2024/05/27
- [Stable-8.2.5 16/21] target/loongarch/kvm: Fix VM recovery from disk failures, Michael Tokarev, 2024/05/27