@@ -10,6 +10,38 @@
* See the COPYING file in the top-level directory.
*/
+#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
+/*
+ * Increments PMC5 if MMCR0_FC is cleared.
+ */
+static void pmu_inc_pmc5(DisasContext *ctx)
+{
+ TCGv t0, t1;
+ TCGLabel *l_skip_pmc;
+
+ /*
+ * If MMCR0_FC56 is set skip PMC5 increment.
+ */
+ l_skip_pmc = gen_new_label();
+
+ t0 = tcg_temp_new();
+ gen_load_spr(t0, SPR_POWER_MMCR0);
+
+ tcg_gen_andi_tl(t0, t0, MMCR0_FC56);
+ tcg_gen_brcondi_tl(TCG_COND_EQ, t0, MMCR0_FC56, l_skip_pmc);
+
+ t1 = tcg_temp_new();
+ gen_load_spr(t1, SPR_POWER_PMC5);
+ tcg_gen_addi_tl(t1, t1, ctx->base.num_insns);
+ gen_store_spr(SPR_POWER_PMC5, t1);
+
+ gen_set_label(l_skip_pmc);
+
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+}
+#endif /* #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY) */
+
#if defined(TARGET_PPC64)
static void pmu_count_insns(DisasContext *ctx)
{
@@ -22,15 +54,9 @@ static void pmu_count_insns(DisasContext *ctx)
}
#if !defined(CONFIG_USER_ONLY)
- /*
- * The PMU insns_inc() helper stops the internal PMU timer if a
- * counter overflows happens. In that case, if the guest is
- * running with icount and we do not handle it beforehand,
- * the helper can trigger a 'bad icount read'.
- */
- gen_icount_io_start(ctx);
- gen_helper_insns_inc(cpu_env, tcg_constant_i32(ctx->base.num_insns));
+ pmu_inc_pmc5(ctx);
+
#else
/*
* User mode can read (but not write) PMC5 and start/stop
The first PMC to be counted using exclusively TCG ops will be PMC5. pmu_inc_pmc5() will always be called inside pmu_count_insns() since it's able to avoid incrementing PMC5 by checking for MMCR0_FC56 beforehand. Note that we've already checked that MMCR0_FC is cleared at this point via ctx->pmu_insn_cnt being set. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> --- target/ppc/power8-pmu-insn-cnt.c.inc | 42 ++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-)