Commit dfc64f2809 for qemu.org
commit dfc64f28096acce4180a63e649290eb447a60311
Author: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon Nov 2 01:26:09 2026 +0100
target/i386/tcg: fix CPUID checks for TZCNT and LZCNT
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>
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
index aa22014786..b51b2f1ae9 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);