[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 16/16] target/ppc: Validate hflags with CONFIG_DEBUG_TCG
From: |
Richard Henderson |
Subject: |
[PATCH v3 16/16] target/ppc: Validate hflags with CONFIG_DEBUG_TCG |
Date: |
Sun, 14 Mar 2021 11:59:06 -0600 |
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>
---
target/ppc/cpu.h | 5 +++++
target/ppc/helper_regs.c | 29 +++++++++++++++++++++++++++--
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 2f8d7fa13c..7ee5c9a66e 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -2424,6 +2424,10 @@ void cpu_write_xer(CPUPPCState *env, target_ulong xer);
*/
#define is_book3s_arch2x(ctx) (!!((ctx)->insns_flags & PPC_SEGMENT_64B))
+#ifdef CONFIG_DEBUG_TCG
+void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc,
+ target_ulong *cs_base, uint32_t *flags);
+#else
static inline void cpu_get_tb_cpu_state(CPUPPCState *env, target_ulong *pc,
target_ulong *cs_base, uint32_t *flags)
{
@@ -2431,6 +2435,7 @@ static inline void cpu_get_tb_cpu_state(CPUPPCState *env,
target_ulong *pc,
*cs_base = 0;
*flags = env->hflags;
}
+#endif
void QEMU_NORETURN raise_exception(CPUPPCState *env, uint32_t exception);
void QEMU_NORETURN raise_exception_ra(CPUPPCState *env, uint32_t exception,
diff --git a/target/ppc/helper_regs.c b/target/ppc/helper_regs.c
index b28037ca24..9df1098fec 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;
@@ -147,9 +147,34 @@ 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)
{
if (!kvm_enabled()) {
--
2.25.1
- [PATCH v3 12/16] target/ppc: Remove MSR_SA and MSR_AP from hflags, (continued)
- [PATCH v3 12/16] target/ppc: Remove MSR_SA and MSR_AP from hflags, Richard Henderson, 2021/03/14
- [PATCH v3 13/16] target/ppc: Remove env->immu_idx and env->dmmu_idx, Richard Henderson, 2021/03/14
- [PATCH v3 11/16] target/ppc: Put LPCR[GTSE] in hflags, Richard Henderson, 2021/03/14
- [PATCH v3 08/16] target/ppc: Reduce env->hflags to uint32_t, Richard Henderson, 2021/03/14
- [PATCH v3 09/16] target/ppc: Put dbcr0 single-step bits into hflags, Richard Henderson, 2021/03/14
- [PATCH v3 14/16] hw/ppc: Use hreg_store_msr for msr updates, Richard Henderson, 2021/03/14
- [PATCH v3 10/16] target/ppc: Create helper_scv, Richard Henderson, 2021/03/14
- [PATCH v3 16/16] target/ppc: Validate hflags with CONFIG_DEBUG_TCG,
Richard Henderson <=
- [PATCH v3 15/16] linux-user/ppc: Fix msr updates, Richard Henderson, 2021/03/14