[PATCH] perf vendor events arm64: Use regular expressions for matching MIDR

From: William Cohen
Date: Tue Mar 20 2018 - 22:20:24 EST


The arm64 MIDR includes bits that identifying the silicon revision and
patch version of the processor. Previously the identification code
would mask out those bits making it impossible to have the map file
address any errata related to particular pmu events being unavailable
for a specific patch level of the silicon. Using the available
regular expression matching allows handling of these special cases.

Signed-off-by: William Cohen <wcohen@xxxxxxxxxx>
---
tools/perf/arch/arm64/util/header.c | 7 -------
tools/perf/pmu-events/arch/arm64/mapfile.csv | 9 ++++-----
2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/tools/perf/arch/arm64/util/header.c b/tools/perf/arch/arm64/util/header.c
index 534cd2507d83..05d1439c2cff 100644
--- a/tools/perf/arch/arm64/util/header.c
+++ b/tools/perf/arch/arm64/util/header.c
@@ -5,9 +5,6 @@

#define MIDR "/regs/identification/midr_el1"
#define MIDR_SIZE 19
-#define MIDR_REVISION_MASK 0xf
-#define MIDR_VARIANT_SHIFT 20
-#define MIDR_VARIANT_MASK (0xf << MIDR_VARIANT_SHIFT)

char *get_cpuid_str(struct perf_pmu *pmu)
{
@@ -44,11 +41,7 @@ char *get_cpuid_str(struct perf_pmu *pmu)
}
fclose(file);

- /* Ignore/clear Variant[23:20] and
- * Revision[3:0] of MIDR
- */
midr = strtoul(buf, NULL, 16);
- midr &= (~(MIDR_VARIANT_MASK | MIDR_REVISION_MASK));
scnprintf(buf, MIDR_SIZE, "0x%016lx", midr);
/* got midr break loop */
break;
diff --git a/tools/perf/pmu-events/arch/arm64/mapfile.csv b/tools/perf/pmu-events/arch/arm64/mapfile.csv
index f03e26ecb658..4b3403147819 100644
--- a/tools/perf/pmu-events/arch/arm64/mapfile.csv
+++ b/tools/perf/pmu-events/arch/arm64/mapfile.csv
@@ -3,7 +3,6 @@
#
# where
# MIDR Processor version
-# Variant[23:20] and Revision [3:0] should be zero.
# Version could be used to track version of of JSON file
# but currently unused.
# JSON/file/pathname is the path to JSON file, relative
@@ -12,7 +11,7 @@
#
#
#Family-model,Version,Filename,EventType
-0x00000000410fd03[[:xdigit:]],v1,arm/cortex-a53,core
-0x00000000420f5160,v1,cavium/thunderx2,core
-0x00000000430f0af0,v1,cavium/thunderx2,core
-0x00000000480fd010,v1,hisilicon/hip08,core
+0x0000000041[[:xdigit:]]fd03[[:xdigit:]],v1,arm/cortex-a53,core
+0x0000000042[[:xdigit:]]f516[[:xdigit:]],v1,cavium/thunderx2,core
+0x0000000043[[:xdigit:]]f0af[[:xdigit:]],v1,cavium/thunderx2,core
+0x0000000048[[:xdigit:]]fd01[[:xdigit:]],v1,hisilicon/hip08,core
--
2.14.3


--------------27D292F513ED30942EE03486--