diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2021-03-23 12:43:40 -0600 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2021-05-04 11:41:25 +1000 |
commit | 2da8a6bcdca72c7a79a9c732133eaeb9452242cc (patch) | |
tree | 5cb1439602ee121bf90a051d0ebebffc2b35e62e /target/ppc/helper_regs.c | |
parent | 75da499733696889453b3fda9ae0f0f5c28fcd6b (diff) |
target/ppc: Validate hflags with CONFIG_DEBUG_TCG
Verify that hflags was updated correctly whenever we change
cpu state that is used by hflags.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210323184340.619757-11-richard.henderson@linaro.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target/ppc/helper_regs.c')
-rw-r--r-- | target/ppc/helper_regs.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c index 5411a67e9a..3723872aa6 100644 --- a/target/ppc/helper_regs.c +++ b/target/ppc/helper_regs.c @@ -43,7 +43,7 @@ void hreg_swap_gpr_tgpr(CPUPPCState *env) env->tgpr[3] = tmp; } -void hreg_compute_hflags(CPUPPCState *env) +static uint32_t hreg_compute_hflags_value(CPUPPCState *env) { target_ulong msr = env->msr; uint32_t ppc_flags = env->flags; @@ -155,8 +155,33 @@ void hreg_compute_hflags(CPUPPCState *env) hflags |= dmmu_idx << HFLAGS_DMMU_IDX; #endif - env->hflags = hflags | (msr & msr_mask); + return hflags | (msr & msr_mask); +} + +void hreg_compute_hflags(CPUPPCState *env) +{ + env->hflags = hreg_compute_hflags_value(env); +} + +#ifdef CONFIG_DEBUG_TCG +void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc, + target_ulong *cs_base, uint32_t *flags) +{ + uint32_t hflags_current = env->hflags; + uint32_t hflags_rebuilt; + + *pc = env->nip; + *cs_base = 0; + *flags = hflags_current; + + hflags_rebuilt = hreg_compute_hflags_value(env); + if (unlikely(hflags_current != hflags_rebuilt)) { + cpu_abort(env_cpu(env), + "TCG hflags mismatch (current:0x%08x rebuilt:0x%08x)\n", + hflags_current, hflags_rebuilt); + } } +#endif void cpu_interrupt_exittb(CPUState *cs) { |