diff --git a/qemu/aarch64.h b/qemu/aarch64.h index b6de9963..882cae6a 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_aarch64 #define gen_helper_set_rmode gen_helper_set_rmode_aarch64 #define gen_helper_set_user_reg gen_helper_set_user_reg_aarch64 +#define gen_helper_setend gen_helper_setend_aarch64 #define gen_helper_shadd16 gen_helper_shadd16_aarch64 #define gen_helper_shadd8 gen_helper_shadd8_aarch64 #define gen_helper_shaddsubx gen_helper_shaddsubx_aarch64 @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_aarch64 #define helper_set_rmode helper_set_rmode_aarch64 #define helper_set_user_reg helper_set_user_reg_aarch64 +#define helper_setend helper_setend_aarch64 #define helper_shadd16 helper_shadd16_aarch64 #define helper_shadd8 helper_shadd8_aarch64 #define helper_shaddsubx helper_shaddsubx_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index e60cead5..cfa84e39 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_aarch64eb #define gen_helper_set_rmode gen_helper_set_rmode_aarch64eb #define gen_helper_set_user_reg gen_helper_set_user_reg_aarch64eb +#define gen_helper_setend gen_helper_setend_aarch64eb #define gen_helper_shadd16 gen_helper_shadd16_aarch64eb #define gen_helper_shadd8 gen_helper_shadd8_aarch64eb #define gen_helper_shaddsubx gen_helper_shaddsubx_aarch64eb @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_aarch64eb #define helper_set_rmode helper_set_rmode_aarch64eb #define helper_set_user_reg helper_set_user_reg_aarch64eb +#define helper_setend helper_setend_aarch64eb #define helper_shadd16 helper_shadd16_aarch64eb #define helper_shadd8 helper_shadd8_aarch64eb #define helper_shaddsubx helper_shaddsubx_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index 38af2db4..c35783ec 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_arm #define gen_helper_set_rmode gen_helper_set_rmode_arm #define gen_helper_set_user_reg gen_helper_set_user_reg_arm +#define gen_helper_setend gen_helper_setend_arm #define gen_helper_shadd16 gen_helper_shadd16_arm #define gen_helper_shadd8 gen_helper_shadd8_arm #define gen_helper_shaddsubx gen_helper_shaddsubx_arm @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_arm #define helper_set_rmode helper_set_rmode_arm #define helper_set_user_reg helper_set_user_reg_arm +#define helper_setend helper_setend_arm #define helper_shadd16 helper_shadd16_arm #define helper_shadd8 helper_shadd8_arm #define helper_shaddsubx helper_shaddsubx_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index 9c6d819c..ece6834c 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_armeb #define gen_helper_set_rmode gen_helper_set_rmode_armeb #define gen_helper_set_user_reg gen_helper_set_user_reg_armeb +#define gen_helper_setend gen_helper_setend_armeb #define gen_helper_shadd16 gen_helper_shadd16_armeb #define gen_helper_shadd8 gen_helper_shadd8_armeb #define gen_helper_shaddsubx gen_helper_shaddsubx_armeb @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_armeb #define helper_set_rmode helper_set_rmode_armeb #define helper_set_user_reg helper_set_user_reg_armeb +#define helper_setend helper_setend_armeb #define helper_shadd16 helper_shadd16_armeb #define helper_shadd8 helper_shadd8_armeb #define helper_shaddsubx helper_shaddsubx_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 3192b4d4..eacbe7b0 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -1045,6 +1045,7 @@ symbols = ( 'gen_helper_set_r13_banked', 'gen_helper_set_rmode', 'gen_helper_set_user_reg', + 'gen_helper_setend', 'gen_helper_shadd16', 'gen_helper_shadd8', 'gen_helper_shaddsubx', @@ -1814,6 +1815,7 @@ symbols = ( 'helper_set_r13_banked', 'helper_set_rmode', 'helper_set_user_reg', + 'helper_setend', 'helper_shadd16', 'helper_shadd8', 'helper_shaddsubx', diff --git a/qemu/m68k.h b/qemu/m68k.h index 04a9e8d2..c6240bf4 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_m68k #define gen_helper_set_rmode gen_helper_set_rmode_m68k #define gen_helper_set_user_reg gen_helper_set_user_reg_m68k +#define gen_helper_setend gen_helper_setend_m68k #define gen_helper_shadd16 gen_helper_shadd16_m68k #define gen_helper_shadd8 gen_helper_shadd8_m68k #define gen_helper_shaddsubx gen_helper_shaddsubx_m68k @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_m68k #define helper_set_rmode helper_set_rmode_m68k #define helper_set_user_reg helper_set_user_reg_m68k +#define helper_setend helper_setend_m68k #define helper_shadd16 helper_shadd16_m68k #define helper_shadd8 helper_shadd8_m68k #define helper_shaddsubx helper_shaddsubx_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 96eebc44..a6ae37e3 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_mips #define gen_helper_set_rmode gen_helper_set_rmode_mips #define gen_helper_set_user_reg gen_helper_set_user_reg_mips +#define gen_helper_setend gen_helper_setend_mips #define gen_helper_shadd16 gen_helper_shadd16_mips #define gen_helper_shadd8 gen_helper_shadd8_mips #define gen_helper_shaddsubx gen_helper_shaddsubx_mips @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_mips #define helper_set_rmode helper_set_rmode_mips #define helper_set_user_reg helper_set_user_reg_mips +#define helper_setend helper_setend_mips #define helper_shadd16 helper_shadd16_mips #define helper_shadd8 helper_shadd8_mips #define helper_shaddsubx helper_shaddsubx_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index e2becb2f..60b95bfb 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_mips64 #define gen_helper_set_rmode gen_helper_set_rmode_mips64 #define gen_helper_set_user_reg gen_helper_set_user_reg_mips64 +#define gen_helper_setend gen_helper_setend_mips64 #define gen_helper_shadd16 gen_helper_shadd16_mips64 #define gen_helper_shadd8 gen_helper_shadd8_mips64 #define gen_helper_shaddsubx gen_helper_shaddsubx_mips64 @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_mips64 #define helper_set_rmode helper_set_rmode_mips64 #define helper_set_user_reg helper_set_user_reg_mips64 +#define helper_setend helper_setend_mips64 #define helper_shadd16 helper_shadd16_mips64 #define helper_shadd8 helper_shadd8_mips64 #define helper_shaddsubx helper_shaddsubx_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 7d9ab32f..bb5c169f 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_mips64el #define gen_helper_set_rmode gen_helper_set_rmode_mips64el #define gen_helper_set_user_reg gen_helper_set_user_reg_mips64el +#define gen_helper_setend gen_helper_setend_mips64el #define gen_helper_shadd16 gen_helper_shadd16_mips64el #define gen_helper_shadd8 gen_helper_shadd8_mips64el #define gen_helper_shaddsubx gen_helper_shaddsubx_mips64el @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_mips64el #define helper_set_rmode helper_set_rmode_mips64el #define helper_set_user_reg helper_set_user_reg_mips64el +#define helper_setend helper_setend_mips64el #define helper_shadd16 helper_shadd16_mips64el #define helper_shadd8 helper_shadd8_mips64el #define helper_shaddsubx helper_shaddsubx_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index 5fd01ed2..6a355da4 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_mipsel #define gen_helper_set_rmode gen_helper_set_rmode_mipsel #define gen_helper_set_user_reg gen_helper_set_user_reg_mipsel +#define gen_helper_setend gen_helper_setend_mipsel #define gen_helper_shadd16 gen_helper_shadd16_mipsel #define gen_helper_shadd8 gen_helper_shadd8_mipsel #define gen_helper_shaddsubx gen_helper_shaddsubx_mipsel @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_mipsel #define helper_set_rmode helper_set_rmode_mipsel #define helper_set_user_reg helper_set_user_reg_mipsel +#define helper_setend helper_setend_mipsel #define helper_shadd16 helper_shadd16_mipsel #define helper_shadd8 helper_shadd8_mipsel #define helper_shaddsubx helper_shaddsubx_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index 7eb4f066..315ac04a 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_powerpc #define gen_helper_set_rmode gen_helper_set_rmode_powerpc #define gen_helper_set_user_reg gen_helper_set_user_reg_powerpc +#define gen_helper_setend gen_helper_setend_powerpc #define gen_helper_shadd16 gen_helper_shadd16_powerpc #define gen_helper_shadd8 gen_helper_shadd8_powerpc #define gen_helper_shaddsubx gen_helper_shaddsubx_powerpc @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_powerpc #define helper_set_rmode helper_set_rmode_powerpc #define helper_set_user_reg helper_set_user_reg_powerpc +#define helper_setend helper_setend_powerpc #define helper_shadd16 helper_shadd16_powerpc #define helper_shadd8 helper_shadd8_powerpc #define helper_shaddsubx helper_shaddsubx_powerpc diff --git a/qemu/sparc.h b/qemu/sparc.h index a49f61c9..a87aa634 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_sparc #define gen_helper_set_rmode gen_helper_set_rmode_sparc #define gen_helper_set_user_reg gen_helper_set_user_reg_sparc +#define gen_helper_setend gen_helper_setend_sparc #define gen_helper_shadd16 gen_helper_shadd16_sparc #define gen_helper_shadd8 gen_helper_shadd8_sparc #define gen_helper_shaddsubx gen_helper_shaddsubx_sparc @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_sparc #define helper_set_rmode helper_set_rmode_sparc #define helper_set_user_reg helper_set_user_reg_sparc +#define helper_setend helper_setend_sparc #define helper_shadd16 helper_shadd16_sparc #define helper_shadd8 helper_shadd8_sparc #define helper_shaddsubx helper_shaddsubx_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index 47911816..12be936b 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_sparc64 #define gen_helper_set_rmode gen_helper_set_rmode_sparc64 #define gen_helper_set_user_reg gen_helper_set_user_reg_sparc64 +#define gen_helper_setend gen_helper_setend_sparc64 #define gen_helper_shadd16 gen_helper_shadd16_sparc64 #define gen_helper_shadd8 gen_helper_shadd8_sparc64 #define gen_helper_shaddsubx gen_helper_shaddsubx_sparc64 @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_sparc64 #define helper_set_rmode helper_set_rmode_sparc64 #define helper_set_user_reg helper_set_user_reg_sparc64 +#define helper_setend helper_setend_sparc64 #define helper_shadd16 helper_shadd16_sparc64 #define helper_shadd8 helper_shadd8_sparc64 #define helper_shaddsubx helper_shaddsubx_sparc64 diff --git a/qemu/target-arm/helper.h b/qemu/target-arm/helper.h index 8231d046..990bfe59 100644 --- a/qemu/target-arm/helper.h +++ b/qemu/target-arm/helper.h @@ -51,6 +51,7 @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_2(exception_internal, void, env, i32) DEF_HELPER_4(exception_with_syndrome, void, env, i32, i32, i32) +DEF_HELPER_1(setend, void, env) DEF_HELPER_1(wfi, void, env) DEF_HELPER_1(wfe, void, env) DEF_HELPER_1(yield, void, env) diff --git a/qemu/target-arm/op_helper.c b/qemu/target-arm/op_helper.c index 942ea69e..1afdc8ad 100644 --- a/qemu/target-arm/op_helper.c +++ b/qemu/target-arm/op_helper.c @@ -296,6 +296,11 @@ uint32_t HELPER(usat16)(CPUARMState *env, uint32_t x, uint32_t shift) return res; } +void HELPER(setend)(CPUARMState *env) +{ + env->uncached_cpsr ^= CPSR_E; +} + /* Function checks whether WFx (WFI/WFE) instructions are set up to be trapped. * The function returns the target EL (1-3) if the instruction is to be trapped; * otherwise it returns 0 indicating it is not trapped. diff --git a/qemu/target-arm/translate.c b/qemu/target-arm/translate.c index e66ffa16..f1bd10e3 100644 --- a/qemu/target-arm/translate.c +++ b/qemu/target-arm/translate.c @@ -7917,10 +7917,9 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) // qq if ((insn & 0x0ffffdff) == 0x01010000) { ARCH(6); /* setend */ - if (((insn >> 9) & 1) != bswap_code(s->sctlr_b)) { - /* Dynamic endianness switching not implemented. */ - qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n"); - goto illegal_op; + if (((insn >> 9) & 1) != !!(s->be_data == MO_BE)) { + gen_helper_setend(tcg_ctx, tcg_ctx->cpu_env); + s->is_jmp = DISAS_UPDATE; } return; } else if ((insn & 0x0fffff00) == 0x057ff000) { @@ -11276,10 +11275,9 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) // qq case 2: /* setend */ ARCH(6); - if (((insn >> 3) & 1) != bswap_code(s->sctlr_b)) { - /* Dynamic endianness switching not implemented. */ - qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n"); - goto illegal_op; + if (((insn >> 3) & 1) != !!(s->be_data == MO_BE)) { + gen_helper_setend(tcg_ctx, tcg_ctx->cpu_env); + s->is_jmp = DISAS_UPDATE; } break; case 3: diff --git a/qemu/x86_64.h b/qemu/x86_64.h index a42bd40e..dc06ce7f 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -1039,6 +1039,7 @@ #define gen_helper_set_r13_banked gen_helper_set_r13_banked_x86_64 #define gen_helper_set_rmode gen_helper_set_rmode_x86_64 #define gen_helper_set_user_reg gen_helper_set_user_reg_x86_64 +#define gen_helper_setend gen_helper_setend_x86_64 #define gen_helper_shadd16 gen_helper_shadd16_x86_64 #define gen_helper_shadd8 gen_helper_shadd8_x86_64 #define gen_helper_shaddsubx gen_helper_shaddsubx_x86_64 @@ -1808,6 +1809,7 @@ #define helper_set_r13_banked helper_set_r13_banked_x86_64 #define helper_set_rmode helper_set_rmode_x86_64 #define helper_set_user_reg helper_set_user_reg_x86_64 +#define helper_setend helper_setend_x86_64 #define helper_shadd16 helper_shadd16_x86_64 #define helper_shadd8 helper_shadd8_x86_64 #define helper_shaddsubx helper_shaddsubx_x86_64