From 637ff1a710bbed48c2ea1116e40800bb190ff937 Mon Sep 17 00:00:00 2001 From: CyrIng Date: Fri, 9 Feb 2024 14:27:39 +0100 Subject: [PATCH] [AArch64] Add the number of AMU counters from `AMCGCR` register --- aarch64/arm_reg.h | 13 +++++++++++++ aarch64/corefreqk.c | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/aarch64/arm_reg.h b/aarch64/arm_reg.h index 9e205a57..55aea3d4 100644 --- a/aarch64/arm_reg.h +++ b/aarch64/arm_reg.h @@ -19,6 +19,7 @@ #define MRS_ALLINT sys_reg(0b11, 0b000, 0b0100, 0b0011, 0b000) #define MRS_PM sys_reg(0b11, 0b000, 0b0100, 0b0011, 0b001) #define MRS_SVCR sys_reg(0b11, 0b011, 0b0100, 0b0010, 0b010) +#define AMCGCR_EL0 sys_reg(0b11, 0b011, 0b1101, 0b0010, 0b010) #define CLUSTERCFR_EL1 sys_reg(0b11, 0b000, 0b1111, 0b0011, 0b000) typedef union @@ -308,6 +309,18 @@ typedef union }; } CPACR; +typedef union +{ + unsigned long long value; + struct + { + unsigned long long + CG0NC : 8-0, + CG1NC : 16-8, + RES0 : 64-16; + }; +} AMCGCR; + typedef union { unsigned long long value; diff --git a/aarch64/corefreqk.c b/aarch64/corefreqk.c index f27ecdfa..1e9f4458 100644 --- a/aarch64/corefreqk.c +++ b/aarch64/corefreqk.c @@ -1031,6 +1031,10 @@ static void Query_Features(void *pArg) iArg->Features->AMU_frac = 0; break; } + if (iArg->Features->AMU_vers > 0) { + AMCGCR amcgc = {.value = MOV_SR_GPR(AMCGCR_EL0)}; + iArg->Features->PerfMon.FixCtrs += amcgc.CG0NC + amcgc.CG1NC; + } switch (pfr0.RME) { case 0b0001: iArg->Features->RME = 1;