From d0de673208b75b43c4de1bb897fdd6b115262e14 Mon Sep 17 00:00:00 2001 From: lazymio Date: Sat, 12 Feb 2022 17:47:57 +0100 Subject: [PATCH] Fix the undefined lshift negative numbers --- qemu/accel/tcg/translate-all.c | 4 ++-- qemu/include/exec/tb-lookup.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index 918a7979..0d50cf76 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -1035,7 +1035,7 @@ static uc_err uc_gen_tb(struct uc_struct *uc, uint64_t addr, uc_tb *out_tb) tb = cpu->tb_jmp_cache[hash]; cflags &= ~CF_CLUSTER_MASK; - cflags |= cpu->cluster_index << CF_CLUSTER_SHIFT; + cflags |= ((uint32_t)cpu->cluster_index) << CF_CLUSTER_SHIFT; if (unlikely(!(tb && tb->pc == pc && @@ -1581,7 +1581,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, } cflags &= ~CF_CLUSTER_MASK; - cflags |= cpu->cluster_index << CF_CLUSTER_SHIFT; + cflags |= ((uint32_t)cpu->cluster_index) << CF_CLUSTER_SHIFT; max_insns = cflags & CF_COUNT_MASK; if (max_insns == 0) { diff --git a/qemu/include/exec/tb-lookup.h b/qemu/include/exec/tb-lookup.h index 042423c2..685217dc 100644 --- a/qemu/include/exec/tb-lookup.h +++ b/qemu/include/exec/tb-lookup.h @@ -30,7 +30,7 @@ tb_lookup__cpu_state(CPUState *cpu, target_ulong *pc, target_ulong *cs_base, tb = cpu->tb_jmp_cache[hash]; cf_mask &= ~CF_CLUSTER_MASK; - cf_mask |= cpu->cluster_index << CF_CLUSTER_SHIFT; + cf_mask |= ((uint32_t)cpu->cluster_index) << CF_CLUSTER_SHIFT; if (likely(tb && tb->pc == *pc &&