From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org,
Daniel Henrique Barboza <danielhb413@gmail.com>,
qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au
Subject: [PATCH 6/8] target/ppc/power8-pmu-insn-cnt.c: add pmu_inc_pmc4()
Date: Wed, 22 Dec 2021 10:45:18 -0300 [thread overview]
Message-ID: <20211222134520.587877-7-danielhb413@gmail.com> (raw)
In-Reply-To: <20211222134520.587877-1-danielhb413@gmail.com>
pmu_inc_pmc4() will count both PM_INST_CMPL and PM_RUN_INST_CMPL.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
target/ppc/power8-pmu-insn-cnt.c.inc | 60 ++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/target/ppc/power8-pmu-insn-cnt.c.inc b/target/ppc/power8-pmu-insn-cnt.c.inc
index a84d688503..d3dd6d4685 100644
--- a/target/ppc/power8-pmu-insn-cnt.c.inc
+++ b/target/ppc/power8-pmu-insn-cnt.c.inc
@@ -16,6 +16,8 @@
#define MMCR1_PMC1_INS_CNT2 0xFE000000
#define MMCR1_PMC2_INS_CNT 0x00020000
#define MMCR1_PMC3_INS_CNT 0x00000200
+#define MMCR1_PMC4_INS_CNT 0x00000002
+#define MMCR1_PMC4_INS_LATCH_CNT 0x000000FA
/*
* Increments PMC1 checking if MMCR1_PMC1SEL has one of the following
@@ -123,6 +125,63 @@ static void pmu_inc_pmc3(DisasContext *ctx)
tcg_temp_free(t1);
}
+/*
+ * Increments PMC4 checking if MMCR1_PMC4SEL has one of the following
+ * events:
+ *
+ * - 0x02: implementation dependent PM_INST_CMPL
+ * - 0xFE: ISA architected PM_RUN_INST_CMPL (run latch)
+ *
+ * This function assumes that MMCR0_FC14 is cleared.
+ */
+static void pmu_inc_pmc4(DisasContext *ctx)
+{
+ TCGv t0, t1, t2, t3;
+ TCGLabel *l_inc_pmc;
+ TCGLabel *l_skip_pmc;
+
+ /*
+ * PMC4 will be incremented if MMCR1_PMC4SEL = 0x2
+ * or 0xFA. For 0xFA (INSN_RUN_LATCH) we need to do an
+ * extra check with SPR_CTRL & CTRL_RUN.
+ */
+ l_inc_pmc = gen_new_label();
+ l_skip_pmc = gen_new_label();
+
+ t0 = tcg_temp_new();
+ gen_load_spr(t0, SPR_POWER_MMCR1);
+ tcg_gen_andi_tl(t0, t0, MMCR1_PMC4_INS_CNT);
+ tcg_gen_brcondi_tl(TCG_COND_EQ, t0, MMCR1_PMC4_INS_CNT, l_inc_pmc);
+
+ t1 = tcg_temp_new();
+ gen_load_spr(t1, SPR_POWER_MMCR1);
+ tcg_gen_andi_tl(t1, t1, MMCR1_PMC4_INS_LATCH_CNT);
+ tcg_gen_brcondi_tl(TCG_COND_NE, t1, MMCR1_PMC4_INS_LATCH_CNT, l_skip_pmc);
+
+ /*
+ * MMCR1_PMC4SEL is 0xFA at this point. Check if we have
+ * the run latch, skip if we don't.
+ */
+ t2 = tcg_temp_new();
+ gen_load_spr(t2, SPR_CTRL);
+ tcg_gen_andi_tl(t2, t2, CTRL_RUN);
+ tcg_gen_brcondi_tl(TCG_COND_NE, t2, CTRL_RUN, l_skip_pmc);
+
+ gen_set_label(l_inc_pmc);
+
+ t3 = tcg_temp_new();
+ gen_load_spr(t3, SPR_POWER_PMC4);
+ tcg_gen_addi_tl(t3, t3, ctx->base.num_insns);
+ gen_store_spr(SPR_POWER_PMC4, t3);
+
+ gen_set_label(l_skip_pmc);
+
+ tcg_temp_free(t0);
+ tcg_temp_free(t1);
+ tcg_temp_free(t2);
+ tcg_temp_free(t3);
+}
+
/*
* Increments PMC5 if MMCR0_FC is cleared.
*/
@@ -191,6 +250,7 @@ static void pmu_count_insns(DisasContext *ctx)
pmu_inc_pmc1(ctx);
pmu_inc_pmc2(ctx);
pmu_inc_pmc3(ctx);
+ pmu_inc_pmc4(ctx);
gen_set_label(l_skip_pmc14);
--
2.33.1
next prev parent reply other threads:[~2021-12-22 13:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 13:45 [PATCH 0/8] Re-write PPC64 PMU instruction count using TCG Ops Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 1/8] target/ppc: introduce power8-pmu-insn-cnt.c.inc Daniel Henrique Barboza
2021-12-22 18:00 ` Cédric Le Goater
2021-12-22 18:10 ` Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 2/8] target/ppc/power8-pmu-insn-cnt: add pmu_inc_pmc5() Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 3/8] target/ppc/power8-pmu-insn-cnt: add pmu_inc_pmc1() Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 4/8] target/ppc/power8-pmu-insn-cnt: add pmu_inc_pmc2() Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 5/8] target/ppc/power8-pmu-insn-cnt: add pmu_inc_pmc3() Daniel Henrique Barboza
2021-12-22 13:45 ` Daniel Henrique Barboza [this message]
2021-12-22 13:45 ` [PATCH 7/8] target/ppc/power8-pmu-insn-cnt: add pmu_check_overflow() Daniel Henrique Barboza
2021-12-22 13:45 ` [PATCH 8/8] target/ppc/power8-pmu.c: remove helper_insns_inc() Daniel Henrique Barboza
2021-12-23 2:43 ` [PATCH 0/8] Re-write PPC64 PMU instruction count using TCG Ops Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211222134520.587877-7-danielhb413@gmail.com \
--to=danielhb413@gmail.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).