Commit d9e028c1 authored by Peter Maydell's avatar Peter Maydell
Browse files

target-arm: Decode SETEND correctly in Thumb



Decode the SETEND instruction correctly in Thumb mode,
rather than accidentally treating it like CPS. We don't
support BE8 mode, but this change brings the Thumb mode
in to line with behaviour in ARM mode: 'SETEND BE' is
not supported and will provoke an UNDEF exception, but
'SETEND LE' is correctly handled as a no-op.

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Reported-by: default avatarDaniel Forsgren <daniel.forsgren@enea.com>
Reviewed-by: default avatarLaurent Desnogues <laurent.desnogues@gmail.com>
parent c98d174c
Loading
Loading
Loading
Loading
+40 −23
Original line number Diff line number Diff line
@@ -9704,10 +9704,22 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s)
            store_reg(s, rd, tmp);
            break;

        case 6: /* cps */
        case 6:
            switch ((insn >> 5) & 7) {
            case 2:
                /* setend */
                ARCH(6);
            if (IS_USER(s))
                if (insn & (1 << 3)) {
                    /* BE8 mode not implemented.  */
                    goto illegal_op;
                }
                break;
            case 3:
                /* cps */
                ARCH(6);
                if (IS_USER(s)) {
                    break;
                }
                if (IS_M(env)) {
                    tmp = tcg_const_i32((insn & (1 << 4)) != 0);
                    /* FAULTMASK */
@@ -9725,13 +9737,18 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s)
                    tcg_temp_free_i32(tmp);
                    gen_lookup_tb(s);
                } else {
                if (insn & (1 << 4))
                    if (insn & (1 << 4)) {
                        shift = CPSR_A | CPSR_I | CPSR_F;
                else
                    } else {
                        shift = 0;
                    }
                    gen_set_psr_im(s, ((insn & 7) << 6), 0, shift);
                }
                break;
            default:
                goto undef;
            }
            break;

        default:
            goto undef;