@samitouri / QOSamiQemu / commits / c05e01a885

target/arm: Make CBZ/CBNZ UNDEF before v6T2

The Thumb CBZ/CBNZ encodings are only introduced in v6T2 (for A-profile) and v7M (for M-profile). We missed out the feature-check in trans_CBZ(), so don't UNDEF on v5T or v6M. Add the missing check: conveniently, the ARM_FEATURE_THUMB2 feature is true for exactly the cases where CBZ is implemented. Cc: qemu-stable@nongnu.org Fixes: 9ee6e8bb853bde ("ARMv7 support.") Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260821132550.168896-2-peter.maydell@linaro.org

Peter Maydell committed Aug 21, 2026 at 14:25 UTC c05e01a885811f85c291ffa8513cb1d159b8c8b8
1 file changed +8 -1
target/arm/tcg/translate.c
+8 -1
@@ -5783,7 +5783,14 @@ static bool trans_TBH(DisasContext *s, arg_tbranch *a)
5783
5784 static bool trans_CBZ(DisasContext *s, arg_CBZ *a)
5785 {
5786 - TCGv_i32 tmp = load_reg(s, a->rn);
5786 + TCGv_i32 tmp;
5787 +
5788 + /* CBZ was introduced in v6T2 and v7M */
5789 + if (!arm_dc_feature(s, ARM_FEATURE_THUMB2)) {
5790 + return false;
5791 + }
5792 +
5793 + tmp = load_reg(s, a->rn);
5794
5795 arm_gen_condlabel(s);
5796 tcg_gen_brcondi_i32(a->nz ? TCG_COND_EQ : TCG_COND_NE,