From db63f2d9d7650fdf11bf0e3f696cbc821bd84802 Mon Sep 17 00:00:00 2001 From: StalkR Date: Tue, 14 Nov 2023 10:22:18 +0100 Subject: [PATCH] qemu: fix UBSAN errors in tcg and arm translation --- qemu/include/tcg/tcg-op.h | 5 +++-- qemu/target/arm/translate.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qemu/include/tcg/tcg-op.h b/qemu/include/tcg/tcg-op.h index 13ec344a..b57f96b1 100644 --- a/qemu/include/tcg/tcg-op.h +++ b/qemu/include/tcg/tcg-op.h @@ -46,8 +46,9 @@ static inline void gen_uc_tracecode(TCGContext *tcg_ctx, int32_t size, int32_t t 0 }; - if (puc->hooks_count[type] == 1) { - cur = puc->hook[type].head; + const int hook_type = type & UC_HOOK_IDX_MASK; + if (puc->hooks_count[hook_type] == 1) { + cur = puc->hook[hook_type].head; while (cur) { hk = cur->data; diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index d93a438e..f8fe7ea7 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -7761,7 +7761,7 @@ static int t32_expandimm_rot(DisasContext *s, int x) /* Return the unrotated immediate from T32ExpandImm. */ static int t32_expandimm_imm(DisasContext *s, int x) { - int imm = extract32(x, 0, 8); + uint32_t imm = extract32(x, 0, 8); switch (extract32(x, 8, 4)) { case 0: /* XY */