[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 13/14] target/arm: Implement PMSWINC
From: |
Aaron Lindsay |
Subject: |
[Qemu-devel] [PATCH v10 13/14] target/arm: Implement PMSWINC |
Date: |
Tue, 11 Dec 2018 15:20:52 +0000 |
Signed-off-by: Aaron Lindsay <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
---
target/arm/helper.c | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index af09f757df..881d49c662 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1027,6 +1027,15 @@ static bool event_always_supported(CPUARMState *env)
return true;
}
+static uint64_t swinc_get_count(CPUARMState *env)
+{
+ /*
+ * SW_INCR events are written directly to the pmevcntr's by writes to
+ * PMSWINC, so there is no underlying count maintained by the PMU itself
+ */
+ return 0;
+}
+
/*
* Return the underlying cycle count for the PMU cycle counters. If we're in
* usermode, simply return 0.
@@ -1054,6 +1063,10 @@ static uint64_t instructions_get_count(CPUARMState *env)
#endif
static const pm_event pm_events[] = {
+ { .number = 0x000, /* SW_INCR */
+ .supported = event_always_supported,
+ .get_count = swinc_get_count,
+ },
#ifndef CONFIG_USER_ONLY
{ .number = 0x008, /* INST_RETIRED, Instruction architecturally executed */
.supported = instructions_supported,
@@ -1393,6 +1406,24 @@ static void pmcr_write(CPUARMState *env, const
ARMCPRegInfo *ri,
pmu_op_finish(env);
}
+static void pmswinc_write(CPUARMState *env, const ARMCPRegInfo *ri,
+ uint64_t value)
+{
+ unsigned int i;
+ for (i = 0; i < pmu_num_counters(env); i++) {
+ /* Increment a counter's count iff: */
+ if ((value & (1 << i)) && /* counter's bit is set */
+ /* counter is enabled and not filtered */
+ pmu_counter_enabled(env, i) &&
+ /* counter is SW_INCR */
+ (env->cp15.c14_pmevtyper[i] & PMXEVTYPER_EVTCOUNT) == 0x0) {
+ pmevcntr_op_start(env, i);
+ env->cp15.c14_pmevcntr[i]++;
+ pmevcntr_op_finish(env, i);
+ }
+ }
+}
+
static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri)
{
uint64_t ret;
@@ -1813,9 +1844,13 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
.fieldoffset = offsetof(CPUARMState, cp15.c9_pmovsr),
.writefn = pmovsr_write,
.raw_writefn = raw_write },
- /* Unimplemented so WI. */
{ .name = "PMSWINC", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 4,
- .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NOP },
+ .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW,
+ .writefn = pmswinc_write },
+ { .name = "PMSWINC_EL0", .state = ARM_CP_STATE_AA64,
+ .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 4,
+ .access = PL0_W, .accessfn = pmreg_access_swinc, .type = ARM_CP_NO_RAW,
+ .writefn = pmswinc_write },
{ .name = "PMSELR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 5,
.access = PL0_RW, .type = ARM_CP_ALIAS,
.fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmselr),
--
2.19.2
- [Qemu-devel] [PATCH v10 03/14] target/arm: Swap PMU values before/after migrations, (continued)
- [Qemu-devel] [PATCH v10 03/14] target/arm: Swap PMU values before/after migrations, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 02/14] target/arm: Reorganize PMCCNTR accesses, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 06/14] target/arm: Implement PMOVSSET, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 05/14] target/arm: Allow AArch32 access for PMCCFILTR, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 04/14] target/arm: Filter cycle counter based on PMCCFILTR_EL0, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 07/14] target/arm: Define FIELDs for ID_DFR0, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 10/14] target/arm: Finish implementation of PM[X]EVCNTR and PM[X]EVTYPER, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 08/14] target/arm: Make PMCEID[01]_EL0 64 bit registers, add PMCEID[23], Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 09/14] target/arm: Add array for supported PMU events, generate PMCEID[01]_EL0, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 11/14] target/arm: PMU: Add instruction and cycle events, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 13/14] target/arm: Implement PMSWINC,
Aaron Lindsay <=
- [Qemu-devel] [PATCH v10 12/14] target/arm: PMU: Set PMCR.N to 4, Aaron Lindsay, 2018/12/11
- [Qemu-devel] [PATCH v10 14/14] target/arm: Send interrupts on PMU counter overflow, Aaron Lindsay, 2018/12/11