[PATCH] target/i386/tcg: fix CPUID checks for TZCNT and LZCNT

Paolo Bonzini posted 1 patch 1 week, 6 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20261109185651.1068471-1-pbonzini@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
target/i386/tcg/decode-new.c.inc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] target/i386/tcg: fix CPUID checks for TZCNT and LZCNT
Posted by Paolo Bonzini 1 week, 6 days ago
decode_0FBC() decodes F3 0F BC as TZCNT only if the CPU has ABM, and
decode_0FBD() decodes F3 0F BD as LZCNT only if the CPU has BMI1.  The
features are the other way round: TZCNT is part of BMI1, and LZCNT is
part of ABM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/decode-new.c.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index aa22014786f..b51b2f1ae9d 100644
--- a/target/i386/tcg/decode-new.c.inc
+++ b/target/i386/tcg/decode-new.c.inc
@@ -688,7 +688,7 @@ static void decode_0FBC(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
         X86_OP_ENTRYwr(TZCNT, G,v, E,v, zextT0), /* 0xf3 */
         X86_OP_ENTRY2(BSF,    G,v, E,v, zextT1), /* 0xf2 */
     };
-    if (!(s->cpuid_ext3_features & CPUID_EXT3_ABM)) {
+    if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) {
         *entry = opcodes_0FBC[0];
     } else {
         *entry = *decode_by_prefix(s, opcodes_0FBC);
@@ -703,7 +703,7 @@ static void decode_0FBD(DisasContext *s, CPUX86State *env, X86OpEntry *entry, ui
         X86_OP_ENTRYwr(LZCNT, G,v, E,v, zextT0), /* 0xf3 */
         X86_OP_ENTRY2(BSR,    G,v, E,v, zextT1), /* 0xf2 */
     };
-    if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)) {
+    if (!(s->cpuid_ext3_features & CPUID_EXT3_ABM)) {
         *entry = opcodes_0FBD[0];
     } else {
         *entry = *decode_by_prefix(s, opcodes_0FBD);
-- 
2.56.0