diff --git a/qemu/target/arm/cpu.c b/qemu/target/arm/cpu.c index e6e2aa93..34d9a88a 100644 --- a/qemu/target/arm/cpu.c +++ b/qemu/target/arm/cpu.c @@ -210,21 +210,23 @@ static void arm_cpu_reset(CPUState *s) env->pc = cpu->rvbar; #endif } else { -#if defined(CONFIG_USER_ONLY) +// Unicorn: commented out to always allow accesses to FP/Neon +//#if defined(CONFIG_USER_ONLY) /* Userspace expects access to cp10 and cp11 for FP/Neon */ env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 4, 0xf); -#endif +//#endif } -#if defined(CONFIG_USER_ONLY) - env->uncached_cpsr = ARM_CPU_MODE_USR; - /* For user mode we must enable access to coprocessors */ + // Unicorn: Always enable access to the coprocessors initially. env->vfp.xregs[ARM_VFP_FPEXC] = 1 << 30; if (arm_feature(env, ARM_FEATURE_IWMMXT)) { env->cp15.c15_cpar = 3; } else if (arm_feature(env, ARM_FEATURE_XSCALE)) { env->cp15.c15_cpar = 1; } + +#if defined(CONFIG_USER_ONLY) + env->uncached_cpsr = ARM_CPU_MODE_USR; #else /* * If the highest available EL is EL2, AArch32 will start in Hyp diff --git a/qemu/target/arm/translate.c b/qemu/target/arm/translate.c index abdc52b4..223ba561 100644 --- a/qemu/target/arm/translate.c +++ b/qemu/target/arm/translate.c @@ -13644,6 +13644,13 @@ static bool arm_pre_translate_insn(DisasContext *dc) } #endif + // Unicorn: end address tells us to stop emulation + if (dc->pc == dc->uc->addr_end) { + // imitate WFI instruction to halt emulation + dc->base.is_jmp = DISAS_WFI; + return true; + } + if (dc->ss_active && !dc->pstate_ss) { /* Singlestep state is Active-pending. * If we're in this state at the start of a TB then either @@ -13667,13 +13674,6 @@ static bool arm_pre_translate_insn(DisasContext *dc) static void arm_post_translate_insn(DisasContext *dc) { - // Unicorn: end address tells us to stop emulation - if (dc->pc == dc->uc->addr_end) { - // imitate WFI instruction to halt emulation - dc->base.is_jmp = DISAS_WFI; - return; - } - if (dc->condjmp && !dc->base.is_jmp) { TCGContext *tcg_ctx = dc->uc->tcg_ctx; gen_set_label(tcg_ctx, dc->condlabel);