Blame SOURCES/libpfm-aarch64.patch

5e8f80
commit b1a3bf942376a3eaddc6f089c74bf5e322295822
5e8f80
Author: Stephane Eranian <eranian@gmail.com>
5e8f80
Date:   Tue May 6 14:42:23 2014 +0200
5e8f80
5e8f80
    Add ARM Cortex A57 support
5e8f80
    
5e8f80
    This patch adds support for ARM Cortex A57 processor
5e8f80
    for both 64 and 32 bit modes (armv8).
5e8f80
    
5e8f80
    Based on Table 11-24 from the "Cortex A57 Technical Reference Manual"
5e8f80
    
5e8f80
    The validation tests for A57 in 64-bit mode is also added.
5e8f80
    
5e8f80
    Signed-off-by: Stephane Eranian <eranian@gmail.com>
5e8f80
5e8f80
diff --git a/config.mk b/config.mk
5e8f80
index 457d943..9553cbe 100644
5e8f80
--- a/config.mk
5e8f80
+++ b/config.mk
5e8f80
@@ -66,6 +66,15 @@ endif
5e8f80
 ifeq (armv7,$(findstring armv7,$(ARCH)))
5e8f80
 override ARCH=arm
5e8f80
 endif
5e8f80
+ifeq (armv7,$(findstring armv7,$(ARCH)))
5e8f80
+override ARCH=arm
5e8f80
+endif
5e8f80
+ifeq (aarch32,$(findstring aarch32,$(ARCH)))
5e8f80
+override ARCH=arm
5e8f80
+endif
5e8f80
+ifeq (armv8l,$(findstring armv8l,$(ARCH)))
5e8f80
+override ARCH=arm
5e8f80
+endif
5e8f80
 ifeq (mips64,$(findstring mips64,$(ARCH)))
5e8f80
 override ARCH=mips
5e8f80
 endif
5e8f80
@@ -152,6 +161,14 @@ ifeq ($(ARCH),arm)
5e8f80
 CONFIG_PFMLIB_ARCH_ARM=y
5e8f80
 endif
5e8f80
 
5e8f80
+ifeq ($(ARCH),aarch64)
5e8f80
+CONFIG_PFMLIB_ARCH_ARM64=y
5e8f80
+endif
5e8f80
+
5e8f80
+ifeq ($(ARCH),arm64)
5e8f80
+CONFIG_PFMLIB_ARCH_ARM64=y
5e8f80
+endif
5e8f80
+
5e8f80
 ifeq ($(ARCH),s390x)
5e8f80
 CONFIG_PFMLIB_ARCH_S390X=y
5e8f80
 endif
5e8f80
diff --git a/include/perfmon/pfmlib.h b/include/perfmon/pfmlib.h
5e8f80
index dfdd471..b08df66 100644
5e8f80
--- a/include/perfmon/pfmlib.h
5e8f80
+++ b/include/perfmon/pfmlib.h
5e8f80
@@ -237,6 +237,8 @@ typedef enum {
5e8f80
 
5e8f80
 	PFM_PMU_INTEL_HSW_EP,		/* Intel Haswell EP */
5e8f80
 
5e8f80
+	PFM_PMU_ARM_CORTEX_A57,		/* ARM Cortex A57 (ARMv8) */
5e8f80
+
5e8f80
 	/* MUST ADD NEW PMU MODELS HERE */
5e8f80
 
5e8f80
 	PFM_PMU_MAX			/* end marker */
5e8f80
diff --git a/lib/Makefile b/lib/Makefile
5e8f80
index 531167e..6ca3287 100644
5e8f80
--- a/lib/Makefile
5e8f80
+++ b/lib/Makefile
5e8f80
@@ -139,10 +139,21 @@ SRCS += pfmlib_arm_perf_event.c
5e8f80
 endif
5e8f80
 
5e8f80
 INCARCH = $(INC_ARM)
5e8f80
-SRCS   += pfmlib_arm.c pfmlib_arm_armv7_pmuv1.c pfmlib_arm_armv6.c
5e8f80
+SRCS   += pfmlib_arm.c pfmlib_arm_armv7_pmuv1.c pfmlib_arm_armv6.c pfmlib_arm_armv8.c
5e8f80
 CFLAGS += -DCONFIG_PFMLIB_ARCH_ARM
5e8f80
 endif
5e8f80
 
5e8f80
+ifeq ($(CONFIG_PFMLIB_ARCH_ARM64),y)
5e8f80
+
5e8f80
+ifeq ($(SYS),Linux)
5e8f80
+SRCS += pfmlib_arm_perf_event.c
5e8f80
+endif
5e8f80
+
5e8f80
+INCARCH = $(INC_ARM64)
5e8f80
+SRCS   += pfmlib_arm.c pfmlib_arm_armv8.c
5e8f80
+CFLAGS += -DCONFIG_PFMLIB_ARCH_ARM64
5e8f80
+endif
5e8f80
+
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_MIPS),y)
5e8f80
 
5e8f80
 ifeq ($(SYS),Linux)
5e8f80
@@ -272,6 +283,8 @@ INC_ARM=pfmlib_arm_priv.h			\
5e8f80
 	events/arm_cortex_a9_events.h		\
5e8f80
 	events/arm_cortex_a15_events.h
5e8f80
 
5e8f80
+INC_ARM64=events/arm_cortex_a57_events.h
5e8f80
+
5e8f80
 INCDEP=$(INC_COMMON) $(INCARCH)
5e8f80
 
5e8f80
 all: $(TARGETS)
5e8f80
diff --git a/lib/events/arm_cortex_a57_events.h b/lib/events/arm_cortex_a57_events.h
5e8f80
new file mode 100644
5e8f80
index 0000000..9d1d407
5e8f80
--- /dev/null
5e8f80
+++ b/lib/events/arm_cortex_a57_events.h
5e8f80
@@ -0,0 +1,440 @@
5e8f80
+/*
5e8f80
+ * Copyright (c) 2014 Google Inc. All rights reserved
5e8f80
+ * Contributed by Stephane Eranian <eranian@gmail.com>
5e8f80
+ *
5e8f80
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5e8f80
+ * of this software and associated documentation files (the "Software"), to deal
5e8f80
+ * in the Software without restriction, including without limitation the rights
5e8f80
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5e8f80
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
5e8f80
+ * subject to the following conditions:
5e8f80
+ *
5e8f80
+ * The above copyright notice and this permission notice shall be included in all
5e8f80
+ * copies or substantial portions of the Software.
5e8f80
+ *
5e8f80
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5e8f80
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
5e8f80
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
5e8f80
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
5e8f80
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
5e8f80
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5e8f80
+ *
5e8f80
+ * Cortex A57 r1p1
5e8f80
+ * based on Table 11-24 from the "Cortex A57 Technical Reference Manual"
5e8f80
+ */
5e8f80
+
5e8f80
+static const arm_entry_t arm_cortex_a57_pe[]={
5e8f80
+	{.name = "SW_INCR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x00,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Software increment"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x01,
5e8f80
+	 .desc = "Level 1 instruction cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1I_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x02,
5e8f80
+	 .desc = "Level 1 instruction TLB refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x03,
5e8f80
+	 .desc = "Level 1 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x04,
5e8f80
+	 .desc = "Level 1 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x05,
5e8f80
+	 .desc = "Level 1 data TLB refill"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "INST_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x08,
5e8f80
+	 .desc = "Instruction architecturally executed"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TAKEN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x09,
5e8f80
+	 .desc = "Exception taken"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_RETURN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0a,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Exception return"
5e8f80
+	},
5e8f80
+	{.name = "CID_WRITE_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0b,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass)  Write to CONTEXTIDR"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "BRANCH_MISPRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10,
5e8f80
+	 .desc = "Mispredicted or not predicted branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "CPU_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x11,
5e8f80
+	 .desc = "Cycles"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_PRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x12,
5e8f80
+	 .desc = "Predictable branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x13,
5e8f80
+	 .desc = "Data memory access"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x14,
5e8f80
+	 .desc = "Level 1 instruction cache access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_WB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x15,
5e8f80
+	 .desc = "Level 1 data cache WriteBack"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x16,
5e8f80
+	 .desc = "Level 2 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x17,
5e8f80
+	 .desc = "Level 2 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_WB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x18,
5e8f80
+	 .desc = "Level 2 data cache WriteBack"
5e8f80
+	},
5e8f80
+	{.name = "BUS_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x19,
5e8f80
+	 .desc = "Bus access"
5e8f80
+	},
5e8f80
+	{.name = "LOCAL_MEMORY_ERROR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1a,
5e8f80
+	 .desc = "Local memory error"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1b,
5e8f80
+	 .desc = "Instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "TTBR_WRITE_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1c,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass)  Write to translation table base"
5e8f80
+	},
5e8f80
+	{.name = "BUS_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1d,
5e8f80
+	 .desc = "Bus cycle"
5e8f80
+	},
5e8f80
+	{.name = "L1D_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x40,
5e8f80
+	 .desc = "Level 1 data cache read access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x41,
5e8f80
+	 .desc = "Level 1 data cache write access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x42,
5e8f80
+	 .desc = "Level 1 data cache read refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_WRITE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x43,
5e8f80
+	 .desc = "Level 1 data cache write refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_WB_VICTIM",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x46,
5e8f80
+	 .desc = "Level 1 data cache writeback victim"
5e8f80
+	},
5e8f80
+	{.name = "L1D_WB_CLEAN_COHERENCY",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x47,
5e8f80
+	 .desc = "Level 1 data cache writeback cleaning and coherency"
5e8f80
+	},
5e8f80
+	{.name = "L1D_INVALIDATE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x48,
5e8f80
+	 .desc = "Level 1 data cache invalidate"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x4c,
5e8f80
+	 .desc = "Level 1 data TLB read refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_WRITE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x4d,
5e8f80
+	 .desc = "Level 1 data TLB write refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x50,
5e8f80
+	 .desc = "Level 2 data cache read access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x51,
5e8f80
+	 .desc = "Level 2 data cache write access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x52,
5e8f80
+	 .desc = "Level 2 data cache read refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WRITE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x53,
5e8f80
+	 .desc = "Level 2 data cache write refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WB_VICTIM",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x56,
5e8f80
+	 .desc = "Level 2 data cache writeback victim"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WB_CLEAN_COHERENCY",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x57,
5e8f80
+	 .desc = "Level 2 data cache writeback cleaning and coherency"
5e8f80
+	},
5e8f80
+	{.name = "L2D_INVALIDATE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x58,
5e8f80
+	 .desc = "Level 2 data cache invalidate"
5e8f80
+	},
5e8f80
+	{.name = "BUS_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x60,
5e8f80
+	 .desc = "Bus read access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x61,
5e8f80
+	 .desc = "Bus write access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NORMAL_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x62,
5e8f80
+	 .desc = "Bus normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NOT_NORMAL_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x63,
5e8f80
+	 .desc = "Bus not normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NORMAL_ACCESS_2",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x64,
5e8f80
+	 .desc = "Bus normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_PERIPH_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x65,
5e8f80
+	 .desc = "Bus peripheral access"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x66,
5e8f80
+	 .desc = "Data memory read access"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x67,
5e8f80
+	 .desc = "Data memory write access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x68,
5e8f80
+	 .desc = "Unaligned read access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x69,
5e8f80
+	 .desc = "Unaligned read access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6a,
5e8f80
+	 .desc = "Unaligned access"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LDREX",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6c,
5e8f80
+	 .desc = "LDREX exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STREX_PASS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6d,
5e8f80
+	 .desc = "STREX pass exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STREX_FAIL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6e,
5e8f80
+	 .desc = "STREX fail exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LOAD",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x70,
5e8f80
+	 .desc = "Load instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STORE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x71,
5e8f80
+	 .desc = "Store instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LOAD_STORE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x72,
5e8f80
+	 .desc = "Load or store instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_INTEGER_INST",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x73,
5e8f80
+	 .desc = "Integer data processing instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_SIMD",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x74,
5e8f80
+	 .desc = "Advanced SIMD instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_VFP",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x75,
5e8f80
+	 .desc = "VFP instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_SOFT_PC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x76,
5e8f80
+	 .desc = "Software of the PC instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_IMM_BRANCH",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x78,
5e8f80
+	 .desc = "Immediate branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_RET",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x79,
5e8f80
+	 .desc = "Return branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_IND",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7a,
5e8f80
+	 .desc = "Indirect branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_ISB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7c,
5e8f80
+	 .desc = "ISB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_DSB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7d,
5e8f80
+	 .desc = "DSB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_DMB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7e,
5e8f80
+	 .desc = "DMB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_UNDEF",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x81,
5e8f80
+	 .desc = "Exception taken, other synchronous"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_SVC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x82,
5e8f80
+	 .desc = "Exception taken, supervisor call"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_PABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x83,
5e8f80
+	 .desc = "Exception taken, instruction abort"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_DABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x84,
5e8f80
+	 .desc = "Exception taken, data abort or SError"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_IRQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x86,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_FIQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x87,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_SMC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x88,
5e8f80
+	 .desc = "Exception taken, secure monitor call"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_HVC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8a,
5e8f80
+	 .desc = "Exception taken, hypervisor call"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_PABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8b,
5e8f80
+	 .desc = "Exception taken, instruction abort not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_DABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8c,
5e8f80
+	 .desc = "Exception taken, data abort or SError not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_OTHER",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8d,
5e8f80
+	 .desc = "Exception taken, other traps not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_IRQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8e,
5e8f80
+	 .desc = "Exception taken, irq not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_FIQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8f,
5e8f80
+	 .desc = "Exception taken, fiq not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "RC_LD_SPEC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x90,
5e8f80
+	 .desc = "Release consistency instruction speculatively executed (load-acquire)",
5e8f80
+	},
5e8f80
+	{.name = "RC_ST_SPEC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x91,
5e8f80
+	 .desc = "Release consistency instruction speculatively executed (store-release)",
5e8f80
+	},
5e8f80
+	/* END Cortex A47 specific events */
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_arm_armv8.c b/lib/pfmlib_arm_armv8.c
5e8f80
new file mode 100644
5e8f80
index 0000000..880d566
5e8f80
--- /dev/null
5e8f80
+++ b/lib/pfmlib_arm_armv8.c
5e8f80
@@ -0,0 +1,74 @@
5e8f80
+/*
5e8f80
+ * pfmlib_arm_armv8.c : support for ARMv8 processors
5e8f80
+ *
5e8f80
+ * Copyright (c) 2014 Google Inc. All rights reserved
5e8f80
+ * Contributed by Stephane Eranian <eranian@gmail.com>
5e8f80
+ *
5e8f80
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5e8f80
+ * of this software and associated documentation files (the "Software"), to deal
5e8f80
+ * in the Software without restriction, including without limitation the rights
5e8f80
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5e8f80
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
5e8f80
+ * subject to the following conditions:
5e8f80
+ *
5e8f80
+ * The above copyright notice and this permission notice shall be included in all
5e8f80
+ * copies or substantial portions of the Software.
5e8f80
+ *
5e8f80
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5e8f80
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
5e8f80
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
5e8f80
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
5e8f80
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
5e8f80
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5e8f80
+ *
5e8f80
+ */
5e8f80
+#include <sys/types.h>
5e8f80
+#include <string.h>
5e8f80
+#include <stdlib.h>
5e8f80
+
5e8f80
+/* private headers */
5e8f80
+#include "pfmlib_priv.h"			/* library private */
5e8f80
+#include "pfmlib_arm_priv.h"
5e8f80
+
5e8f80
+#include "events/arm_cortex_a57_events.h"    /* event tables */
5e8f80
+
5e8f80
+static int
5e8f80
+pfm_arm_detect_cortex_a57(void *this)
5e8f80
+{
5e8f80
+	int ret;
5e8f80
+
5e8f80
+	ret = pfm_arm_detect(this);
5e8f80
+	if (ret != PFM_SUCCESS)
5e8f80
+		return PFM_ERR_NOTSUPP;
5e8f80
+
5e8f80
+	if ((pfm_arm_cfg.implementer == 0x41) && /* ARM */
5e8f80
+		(pfm_arm_cfg.part == 0xc00)) { /* Cortex A57 */
5e8f80
+			return PFM_SUCCESS;
5e8f80
+	}
5e8f80
+	return PFM_ERR_NOTSUPP;
5e8f80
+}
5e8f80
+
5e8f80
+/* ARM Cortex A57 support */
5e8f80
+pfmlib_pmu_t arm_cortex_a57_support={
5e8f80
+	.desc			= "ARM Cortex A57",
5e8f80
+	.name			= "arm_ac57",
5e8f80
+	.pmu			= PFM_PMU_ARM_CORTEX_A57,
5e8f80
+	.pme_count		= LIBPFM_ARRAY_SIZE(arm_cortex_a57_pe),
5e8f80
+	.type			= PFM_PMU_TYPE_CORE,
5e8f80
+	.pe			= arm_cortex_a57_pe,
5e8f80
+
5e8f80
+	.pmu_detect		= pfm_arm_detect_cortex_a57,
5e8f80
+	.max_encoding		= 1,
5e8f80
+	.num_cntrs		= 6,
5e8f80
+
5e8f80
+	.get_event_encoding[PFM_OS_NONE] = pfm_arm_get_encoding,
5e8f80
+	 PFMLIB_ENCODE_PERF(pfm_arm_get_perf_encoding),
5e8f80
+	.get_event_first	= pfm_arm_get_event_first,
5e8f80
+	.get_event_next		= pfm_arm_get_event_next,
5e8f80
+	.event_is_valid		= pfm_arm_event_is_valid,
5e8f80
+	.validate_table		= pfm_arm_validate_table,
5e8f80
+	.get_event_info		= pfm_arm_get_event_info,
5e8f80
+	.get_event_attr_info	= pfm_arm_get_event_attr_info,
5e8f80
+	 PFMLIB_VALID_PERF_PATTRS(pfm_arm_perf_validate_pattrs),
5e8f80
+	.get_event_nattrs	= pfm_arm_get_event_nattrs,
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_arm_priv.h b/lib/pfmlib_arm_priv.h
5e8f80
index ef367b7..227508b 100644
5e8f80
--- a/lib/pfmlib_arm_priv.h
5e8f80
+++ b/lib/pfmlib_arm_priv.h
5e8f80
@@ -86,6 +86,9 @@ extern int pfm_arm_get_perf_encoding(void *this, pfmlib_event_desc_t *e);
5e8f80
 #define ARMV7_A15_ATTRS	(_ARM_ATTR_K|_ARM_ATTR_U|_ARM_ATTR_HV)
5e8f80
 #define ARMV7_A15_PLM	(PFM_PLM0|PFM_PLM3|PFM_PLMH)
5e8f80
 
5e8f80
+#define ARMV8_ATTRS	(_ARM_ATTR_K|_ARM_ATTR_U|_ARM_ATTR_HV)
5e8f80
+#define ARMV8_PLM	(PFM_PLM0|PFM_PLM3|PFM_PLMH)
5e8f80
+
5e8f80
 static inline int
5e8f80
 arm_has_plm(void *this, pfmlib_event_desc_t *e)
5e8f80
 {
5e8f80
diff --git a/lib/pfmlib_common.c b/lib/pfmlib_common.c
5e8f80
index 8e4b1a1..900d7de 100644
5e8f80
--- a/lib/pfmlib_common.c
5e8f80
+++ b/lib/pfmlib_common.c
5e8f80
@@ -199,7 +199,12 @@ static pfmlib_pmu_t *pfmlib_pmus[]=
5e8f80
 	&arm_cortex_a9_support,
5e8f80
 	&arm_cortex_a15_support,
5e8f80
 	&arm_1176_support,
5e8f80
+	&arm_cortex_a57_support,
5e8f80
 #endif
5e8f80
+#ifdef CONFIG_PFMLIB_ARCH_ARM64
5e8f80
+	&arm_cortex_a57_support,
5e8f80
+#endif
5e8f80
+
5e8f80
 #ifdef CONFIG_PFMLIB_ARCH_S390X
5e8f80
 	&s390x_cpum_cf_support,
5e8f80
 #endif
5e8f80
diff --git a/lib/pfmlib_priv.h b/lib/pfmlib_priv.h
5e8f80
index 715c4b0..3031d3b 100644
5e8f80
--- a/lib/pfmlib_priv.h
5e8f80
+++ b/lib/pfmlib_priv.h
5e8f80
@@ -332,6 +332,7 @@ extern pfmlib_pmu_t arm_cortex_a9_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a9_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a15_support;
5e8f80
 extern pfmlib_pmu_t arm_1176_support;
5e8f80
+extern pfmlib_pmu_t arm_cortex_a57_support;
5e8f80
 extern pfmlib_pmu_t mips_74k_support;
5e8f80
 extern pfmlib_pmu_t s390x_cpum_cf_support;
5e8f80
 
5e8f80
diff --git a/tests/Makefile b/tests/Makefile
5e8f80
index 7076fb7..7dd82c3 100644
5e8f80
--- a/tests/Makefile
5e8f80
+++ b/tests/Makefile
5e8f80
@@ -39,6 +39,10 @@ ifeq ($(CONFIG_PFMLIB_ARCH_ARM),y)
5e8f80
 SRCS += validate_arm.c
5e8f80
 endif
5e8f80
 
5e8f80
+ifeq ($(CONFIG_PFMLIB_ARCH_ARM64),y)
5e8f80
+SRCS += validate_arm64.c
5e8f80
+endif
5e8f80
+
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_POWERPC),y)
5e8f80
 SRCS += validate_power.c
5e8f80
 endif
5e8f80
diff --git a/tests/validate_arm.c b/tests/validate_arm.c
5e8f80
index fe97aa9..d6c0168 100644
5e8f80
--- a/tests/validate_arm.c
5e8f80
+++ b/tests/validate_arm.c
5e8f80
@@ -159,6 +159,34 @@ static const test_event_t arm_test_events[]={
5e8f80
 	  .codes[0] = 0x07,
5e8f80
 	  .fstr = "arm_1176::INSTR_EXEC",
5e8f80
 	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES:k",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x88000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=0:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES:k:u",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::INST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000008,
5e8f80
+	  .fstr = "arm_ac57::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
 };
5e8f80
 #define NUM_TEST_EVENTS (int)(sizeof(arm_test_events)/sizeof(test_event_t))
5e8f80
 
5e8f80
diff --git a/tests/validate_arm64.c b/tests/validate_arm64.c
5e8f80
new file mode 100644
5e8f80
index 0000000..0f0174c
5e8f80
--- /dev/null
5e8f80
+++ b/tests/validate_arm64.c
5e8f80
@@ -0,0 +1,138 @@
5e8f80
+/*
5e8f80
+ * validate_arm64.c - validate ARM64 event tables + encodings
5e8f80
+ *
5e8f80
+ * Copyright (c) 2014 Google, Inc
5e8f80
+ * Contributed by Stephane Eranian <eranian@gmail.com>
5e8f80
+ *
5e8f80
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5e8f80
+ * of this software and associated documentation files (the "Software"), to deal
5e8f80
+ * in the Software without restriction, including without limitation the rights
5e8f80
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5e8f80
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
5e8f80
+ * subject to the following conditions:
5e8f80
+ *
5e8f80
+ * The above copyright notice and this permission notice shall be included in all
5e8f80
+ * copies or substantial portions of the Software.
5e8f80
+ *
5e8f80
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5e8f80
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
5e8f80
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
5e8f80
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
5e8f80
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
5e8f80
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5e8f80
+ *
5e8f80
+ */
5e8f80
+#include <sys/types.h>
5e8f80
+#include <stdio.h>
5e8f80
+#include <stdlib.h>
5e8f80
+#include <inttypes.h>
5e8f80
+#include <stdarg.h>
5e8f80
+#include <errno.h>
5e8f80
+#include <unistd.h>
5e8f80
+#include <string.h>
5e8f80
+
5e8f80
+#include <perfmon/pfmlib.h>
5e8f80
+
5e8f80
+#define MAX_ENCODING	1
5e8f80
+#define SRC_LINE	.line = __LINE__
5e8f80
+
5e8f80
+typedef struct {
5e8f80
+	const char *name;
5e8f80
+	const char *fstr;
5e8f80
+	uint64_t codes[MAX_ENCODING];
5e8f80
+	int ret, count, line;
5e8f80
+} test_event_t;
5e8f80
+
5e8f80
+static const test_event_t arm64_test_events[]={
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES:k",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x88000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=0:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::CPU_CYCLES:k:u",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac57::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac57::INST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000008,
5e8f80
+	  .fstr = "arm_ac57::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+};
5e8f80
+#define NUM_TEST_EVENTS (int)(sizeof(arm64_test_events)/sizeof(test_event_t))
5e8f80
+
5e8f80
+static int check_test_events(FILE *fp)
5e8f80
+{
5e8f80
+	const test_event_t *e;
5e8f80
+	char *fstr;
5e8f80
+	uint64_t *codes;
5e8f80
+	int count, i, j;
5e8f80
+	int ret, errors = 0;
5e8f80
+
5e8f80
+	for (i = 0, e = arm64_test_events; i < NUM_TEST_EVENTS; i++, e++) {
5e8f80
+		codes = NULL;
5e8f80
+		count = 0;
5e8f80
+		fstr = NULL;
5e8f80
+		ret = pfm_get_event_encoding(e->name, PFM_PLM0 | PFM_PLM3, &fstr, NULL, &codes, &count);
5e8f80
+		if (ret != e->ret) {
5e8f80
+			fprintf(fp,"Line %d, Event%d %s, ret=%s(%d) expected %s(%d)\n", e->line, i, e->name, pfm_strerror(ret), ret, pfm_strerror(e->ret), e->ret);
5e8f80
+			errors++;
5e8f80
+		} else {
5e8f80
+			if (ret != PFM_SUCCESS) {
5e8f80
+				if (fstr) {
5e8f80
+					fprintf(fp,"Line %d, Event%d %s, expected fstr NULL but it is not\n", e->line, i, e->name);
5e8f80
+					errors++;
5e8f80
+				}
5e8f80
+				if (count != 0) {
5e8f80
+					fprintf(fp,"Line %d, Event%d %s, expected count=0 instead of %d\n", e->line, i, e->name, count);
5e8f80
+					errors++;
5e8f80
+				}
5e8f80
+				if (codes) {
5e8f80
+					fprintf(fp,"Line %d, Event%d %s, expected codes[] NULL but it is not\n", e->line, i, e->name);
5e8f80
+					errors++;
5e8f80
+				}
5e8f80
+			} else {
5e8f80
+				if (count != e->count) {
5e8f80
+					fprintf(fp,"Line %d, Event%d %s, count=%d expected %d\n", e->line, i, e->name, count, e->count);
5e8f80
+					errors++;
5e8f80
+				}
5e8f80
+				for (j=0; j < count; j++) {
5e8f80
+					if (codes[j] != e->codes[j]) {
5e8f80
+						fprintf(fp,"Line %d, Event%d %s, codes[%d]=%#"PRIx64" expected %#"PRIx64"\n", e->line, i, e->name, j, codes[j], e->codes[j]);
5e8f80
+						errors++;
5e8f80
+					}
5e8f80
+				}
5e8f80
+				if (e->fstr && strcmp(fstr, e->fstr)) {
5e8f80
+					fprintf(fp,"Line %d, Event%d %s, fstr=%s expected %s\n", e->line, i, e->name, fstr, e->fstr);
5e8f80
+					errors++;
5e8f80
+				}
5e8f80
+			}
5e8f80
+		}
5e8f80
+		if (codes)
5e8f80
+			free(codes);
5e8f80
+		if (fstr)
5e8f80
+			free(fstr);
5e8f80
+	}
5e8f80
+	printf("\t %d ARM64 events: %d errors\n", i, errors);
5e8f80
+	return errors;
5e8f80
+}
5e8f80
+
5e8f80
+int
5e8f80
+validate_arch(FILE *fp)
5e8f80
+{
5e8f80
+	return check_test_events(fp);
5e8f80
+}
5e8f80
commit b95de18085dd74738752341e0004b3dd11f00a53
5e8f80
Author: Stephane Eranian <eranian@gmail.com>
5e8f80
Date:   Mon May 12 14:15:57 2014 +0200
5e8f80
5e8f80
    Add ARM Cortex A57 documentation
5e8f80
    
5e8f80
    Signed-off-by: Stephane Eranian <eranian@gmail.com>
5e8f80
5e8f80
diff --git a/docs/Makefile b/docs/Makefile
5e8f80
index ecf6769..9b79ec7 100644
5e8f80
--- a/docs/Makefile
5e8f80
+++ b/docs/Makefile
5e8f80
@@ -76,7 +76,11 @@ endif
5e8f80
 endif
5e8f80
 
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_ARM),y)
5e8f80
-ARCH_MAN += libpfm_arm_ac15.3 libpfm_arm_ac8.3 libpfm_arm_ac9.3
5e8f80
+ARCH_MAN += libpfm_arm_ac57.3 libpfm_arm_ac15.3 libpfm_arm_ac8.3 libpfm_arm_ac9.3
5e8f80
+endif
5e8f80
+
5e8f80
+ifeq ($(CONFIG_PFMLIB_ARCH_ARM64),y)
5e8f80
+ARCH_MAN += libpfm_arm_ac57.3
5e8f80
 endif
5e8f80
 
5e8f80
 
5e8f80
diff --git a/docs/man3/libpfm_arm_ac57.3 b/docs/man3/libpfm_arm_ac57.3
5e8f80
new file mode 100644
5e8f80
index 0000000..c471ff1
5e8f80
--- /dev/null
5e8f80
+++ b/docs/man3/libpfm_arm_ac57.3
5e8f80
@@ -0,0 +1,36 @@
5e8f80
+.TH LIBPFM 4  "May, 2014" "" "Linux Programmer's Manual"
5e8f80
+.SH NAME
5e8f80
+libpfm_arm_ac57 - support for Arm Cortex A57 PMU
5e8f80
+.SH SYNOPSIS
5e8f80
+.nf
5e8f80
+.B #include <perfmon/pfmlib.h>
5e8f80
+.sp
5e8f80
+.B PMU name: arm_ac57
5e8f80
+.B PMU desc: ARM Cortex A57
5e8f80
+.sp
5e8f80
+.SH DESCRIPTION
5e8f80
+The library supports the ARM Cortex A57 core PMU.
5e8f80
+
5e8f80
+This PMU supports 6 counters and privilege levels filtering.
5e8f80
+It can operate in both 32 and 64 bit modes.
5e8f80
+
5e8f80
+.SH MODIFIERS
5e8f80
+The following modifiers are supported on ARM Cortex A57:
5e8f80
+.TP
5e8f80
+.B u
5e8f80
+Measure at the user level. This corresponds to \fBPFM_PLM3\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B k
5e8f80
+Measure at the kernel level. This corresponds to \fBPFM_PLM0\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B hv
5e8f80
+Measure at the hypervisor level. This corresponds to \fBPFM_PLMH\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+
5e8f80
+.SH AUTHORS
5e8f80
+.nf
5e8f80
+Stephane Eranian <eranian@gmail.com>
5e8f80
+.if
5e8f80
+.PP
5e8f80
commit 399aa947ca6f4c58acac8c6be52d2ad4e5268210
5e8f80
Author: Stephane Eranian <eranian@gmail.com>
5e8f80
Date:   Fri May 16 15:42:40 2014 +0200
5e8f80
5e8f80
    fix the ARM Cortex A57 detection
5e8f80
    
5e8f80
    This patch fixes the detection of ARM Cortex A57.
5e8f80
    Was using the wrong part number. Correct number
5e8f80
    is 0xD07.
5e8f80
    
5e8f80
    Signed-off-by: Stephane Eranian <eranian@gmail.com>
5e8f80
5e8f80
diff --git a/lib/pfmlib_arm_armv8.c b/lib/pfmlib_arm_armv8.c
5e8f80
index 880d566..4bc863b 100644
5e8f80
--- a/lib/pfmlib_arm_armv8.c
5e8f80
+++ b/lib/pfmlib_arm_armv8.c
5e8f80
@@ -42,7 +42,7 @@ pfm_arm_detect_cortex_a57(void *this)
5e8f80
 		return PFM_ERR_NOTSUPP;
5e8f80
 
5e8f80
 	if ((pfm_arm_cfg.implementer == 0x41) && /* ARM */
5e8f80
-		(pfm_arm_cfg.part == 0xc00)) { /* Cortex A57 */
5e8f80
+		(pfm_arm_cfg.part == 0xd07)) { /* Cortex A57 */
5e8f80
 			return PFM_SUCCESS;
5e8f80
 	}
5e8f80
 	return PFM_ERR_NOTSUPP;
5e8f80
commit 6d1faa5bd1c0564b24cf030f118cd9782e1b4e0c
5e8f80
Author: Stephane Eranian <eranian@gmail.com>
5e8f80
Date:   Thu May 22 18:44:47 2014 +0200
5e8f80
5e8f80
    Add missing arm_cortex_a57.h header dependency
5e8f80
    
5e8f80
    Was missing. We compile A57 for 32-bit arm as well.
5e8f80
    
5e8f80
    Signed-off-by: Stephane Eranian <eranian@gmail.com>
5e8f80
5e8f80
diff --git a/lib/Makefile b/lib/Makefile
5e8f80
index 6ca3287..585cc3e 100644
5e8f80
--- a/lib/Makefile
5e8f80
+++ b/lib/Makefile
5e8f80
@@ -281,7 +281,8 @@ INC_ARM=events/arm_cortex_a8_events.h		\
5e8f80
 INC_ARM=pfmlib_arm_priv.h			\
5e8f80
 	events/arm_cortex_a8_events.h		\
5e8f80
 	events/arm_cortex_a9_events.h		\
5e8f80
-	events/arm_cortex_a15_events.h
5e8f80
+	events/arm_cortex_a15_events.h		\
5e8f80
+	events/arm_cortex_a57_events.h
5e8f80
 
5e8f80
 INC_ARM64=events/arm_cortex_a57_events.h
5e8f80
 
5e8f80
commit 6af79d5186b7593c4f7e41024b78453debceb45f
5e8f80
Author: Stephane Eranian <eranian@gmail.com>
5e8f80
Date:   Thu May 22 19:14:52 2014 +0200
5e8f80
5e8f80
    Add ARM Cortex A53 support
5e8f80
    
5e8f80
    This patch adds support for the ARM Cortex A53 core PMU as
5e8f80
    documented in r0p2 version f the Cortex-A53 MPCore processor
5e8f80
    technical reference manual Table 12.28.
5e8f80
    
5e8f80
    Support is provided for both 32 and 64-bit modes.
5e8f80
    
5e8f80
    Includes man page, and validation tests.
5e8f80
    
5e8f80
    Signed-off-by: Stephane Eranian <eranian@gmail.com>
5e8f80
5e8f80
diff --git a/README b/README
5e8f80
index 334c78a..e74238f 100644
5e8f80
--- a/README
5e8f80
+++ b/README
5e8f80
@@ -57,6 +57,7 @@ The library supports many PMUs. The current version can handle:
5e8f80
 		ARMV7 Cortex A8
5e8f80
 		ARMV7 Cortex A9
5e8f80
 		ARMV7 Cortex A15
5e8f80
+		ARMV8 Cortex A57, A53
5e8f80
 
5e8f80
 	- For SPARC
5e8f80
 		Ultra I, II
5e8f80
diff --git a/docs/Makefile b/docs/Makefile
5e8f80
index 9b79ec7..c7d797e 100644
5e8f80
--- a/docs/Makefile
5e8f80
+++ b/docs/Makefile
5e8f80
@@ -76,11 +76,16 @@ endif
5e8f80
 endif
5e8f80
 
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_ARM),y)
5e8f80
-ARCH_MAN += libpfm_arm_ac57.3 libpfm_arm_ac15.3 libpfm_arm_ac8.3 libpfm_arm_ac9.3
5e8f80
+ARCH_MAN += libpfm_arm_ac57.3 \
5e8f80
+	    libpfm_arm_ac53.3 \
5e8f80
+	    libpfm_arm_ac15.3 \
5e8f80
+	    libpfm_arm_ac8.3 \
5e8f80
+	    libpfm_arm_ac9.3
5e8f80
 endif
5e8f80
 
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_ARM64),y)
5e8f80
-ARCH_MAN += libpfm_arm_ac57.3
5e8f80
+ARCH_MAN += libpfm_arm_ac57.3 \
5e8f80
+	    libpfm_arm_ac53.3
5e8f80
 endif
5e8f80
 
5e8f80
 
5e8f80
diff --git a/docs/man3/libpfm_arm_ac53.3 b/docs/man3/libpfm_arm_ac53.3
5e8f80
new file mode 100644
5e8f80
index 0000000..319accc
5e8f80
--- /dev/null
5e8f80
+++ b/docs/man3/libpfm_arm_ac53.3
5e8f80
@@ -0,0 +1,36 @@
5e8f80
+.TH LIBPFM 4  "May, 2014" "" "Linux Programmer's Manual"
5e8f80
+.SH NAME
5e8f80
+libpfm_arm_ac53 - support for ARM Cortex A53 PMU
5e8f80
+.SH SYNOPSIS
5e8f80
+.nf
5e8f80
+.B #include <perfmon/pfmlib.h>
5e8f80
+.sp
5e8f80
+.B PMU name: arm_ac53
5e8f80
+.B PMU desc: ARM Cortex A53
5e8f80
+.sp
5e8f80
+.SH DESCRIPTION
5e8f80
+The library supports the ARM Cortex A53 core PMU.
5e8f80
+
5e8f80
+This PMU supports 6 counters and privilege levels filtering.
5e8f80
+It can operate in both 32 and 64 bit modes.
5e8f80
+
5e8f80
+.SH MODIFIERS
5e8f80
+The following modifiers are supported on ARM Cortex A53:
5e8f80
+.TP
5e8f80
+.B u
5e8f80
+Measure at the user level. This corresponds to \fBPFM_PLM3\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B k
5e8f80
+Measure at the kernel level. This corresponds to \fBPFM_PLM0\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B hv
5e8f80
+Measure at the hypervisor level. This corresponds to \fBPFM_PLMH\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+
5e8f80
+.SH AUTHORS
5e8f80
+.nf
5e8f80
+Stephane Eranian <eranian@gmail.com>
5e8f80
+.if
5e8f80
+.PP
5e8f80
diff --git a/include/perfmon/pfmlib.h b/include/perfmon/pfmlib.h
5e8f80
index b08df66..a7ec026 100644
5e8f80
--- a/include/perfmon/pfmlib.h
5e8f80
+++ b/include/perfmon/pfmlib.h
5e8f80
@@ -238,6 +238,7 @@ typedef enum {
5e8f80
 	PFM_PMU_INTEL_HSW_EP,		/* Intel Haswell EP */
5e8f80
 
5e8f80
 	PFM_PMU_ARM_CORTEX_A57,		/* ARM Cortex A57 (ARMv8) */
5e8f80
+	PFM_PMU_ARM_CORTEX_A53,		/* ARM Cortex A53 (ARMv8) */
5e8f80
 
5e8f80
 	/* MUST ADD NEW PMU MODELS HERE */
5e8f80
 
5e8f80
diff --git a/lib/Makefile b/lib/Makefile
5e8f80
index 585cc3e..5aaf4b3 100644
5e8f80
--- a/lib/Makefile
5e8f80
+++ b/lib/Makefile
5e8f80
@@ -282,9 +282,11 @@ INC_ARM=pfmlib_arm_priv.h			\
5e8f80
 	events/arm_cortex_a8_events.h		\
5e8f80
 	events/arm_cortex_a9_events.h		\
5e8f80
 	events/arm_cortex_a15_events.h		\
5e8f80
-	events/arm_cortex_a57_events.h
5e8f80
+	events/arm_cortex_a57_events.h		\
5e8f80
+	events/arm_cortex_a53_events.h
5e8f80
 
5e8f80
-INC_ARM64=events/arm_cortex_a57_events.h
5e8f80
+INC_ARM64=events/arm_cortex_a57_events.h	\
5e8f80
+	  events/arm_cortex_a53_events.h
5e8f80
 
5e8f80
 INCDEP=$(INC_COMMON) $(INCARCH)
5e8f80
 
5e8f80
diff --git a/lib/events/arm_cortex_a53_events.h b/lib/events/arm_cortex_a53_events.h
5e8f80
new file mode 100644
5e8f80
index 0000000..c0d2bb6
5e8f80
--- /dev/null
5e8f80
+++ b/lib/events/arm_cortex_a53_events.h
5e8f80
@@ -0,0 +1,190 @@
5e8f80
+/*
5e8f80
+ * Copyright (c) 2014 Google Inc. All rights reserved
5e8f80
+ * Contributed by Stephane Eranian <eranian@gmail.com>
5e8f80
+ *
5e8f80
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5e8f80
+ * of this software and associated documentation files (the "Software"), to deal
5e8f80
+ * in the Software without restriction, including without limitation the rights
5e8f80
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5e8f80
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
5e8f80
+ * subject to the following conditions:
5e8f80
+ *
5e8f80
+ * The above copyright notice and this permission notice shall be included in all
5e8f80
+ * copies or substantial portions of the Software.
5e8f80
+ *
5e8f80
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5e8f80
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
5e8f80
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
5e8f80
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
5e8f80
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
5e8f80
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5e8f80
+ *
5e8f80
+ * Cortex A53 r0p2
5e8f80
+ * based on Table 12.9 from the "Cortex A53 Technical Reference Manual"
5e8f80
+ */
5e8f80
+
5e8f80
+static const arm_entry_t arm_cortex_a53_pe[]={
5e8f80
+	{.name = "SW_INCR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x00,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Software increment"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x01,
5e8f80
+	 .desc = "Level 1 instruction cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1I_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x02,
5e8f80
+	 .desc = "Level 1 instruction TLB refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x03,
5e8f80
+	 .desc = "Level 1 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x04,
5e8f80
+	 .desc = "Level 1 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x05,
5e8f80
+	 .desc = "Level 1 data TLB refill"
5e8f80
+	},
5e8f80
+	{.name = "LD_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x06,
5e8f80
+	 .desc = "Load Instruction architecturally executed, condition check",
5e8f80
+	},
5e8f80
+	{.name = "ST_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x07,
5e8f80
+	 .desc = "Store Instruction architecturally executed, condition check",
5e8f80
+	},
5e8f80
+	{.name = "INST_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x08,
5e8f80
+	 .desc = "Instruction architecturally executed"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TAKEN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x09,
5e8f80
+	 .desc = "Exception taken"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_RETURN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0a,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Exception return"
5e8f80
+	},
5e8f80
+	{.name = "CID_WRITE_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0b,
5e8f80
+	 .desc = "Change to Context ID retired",
5e8f80
+	},
5e8f80
+	{.name = "PC_WRITE_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0c,
5e8f80
+	 .desc = "Write to CONTEXTIDR, instruction architecturally executed, condition check pass"
5e8f80
+	},
5e8f80
+	{.name = "BR_IMMED_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0d,
5e8f80
+	 .desc = "Software chnage of the PC, instruction architecturally executed, condition check pass"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_LDST_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0f,
5e8f80
+	 .desc = "Procedure return, instruction architecturally executed, condition check pass"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_MISPRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10,
5e8f80
+	 .desc = "Mispredicted or not predicted branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "CPU_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x11,
5e8f80
+	 .desc = "Cycles"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_PRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x12,
5e8f80
+	 .desc = "Predictable branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x13,
5e8f80
+	 .desc = "Data memory access"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x14,
5e8f80
+	 .desc = "Level 1 instruction cache access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_WB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x15,
5e8f80
+	 .desc = "Level 1 data cache WriteBack"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x16,
5e8f80
+	 .desc = "Level 2 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x17,
5e8f80
+	 .desc = "Level 2 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_WB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x18,
5e8f80
+	 .desc = "Level 2 data cache WriteBack"
5e8f80
+	},
5e8f80
+	{.name = "BUS_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x19,
5e8f80
+	 .desc = "Bus access"
5e8f80
+	},
5e8f80
+	{.name = "LOCAL_MEMORY_ERROR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1a,
5e8f80
+	 .desc = "Local memory error"
5e8f80
+	},
5e8f80
+	{.name = "BUS_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1d,
5e8f80
+	 .desc = "Bus cycle"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "BUS_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x60,
5e8f80
+	 .desc = "Bus read access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x61,
5e8f80
+	 .desc = "Bus write access"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_IND",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7a,
5e8f80
+	 .desc = "Indirect branch speculatively executed"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "EXCEPTION_IRQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x86,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_FIQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x87,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_arm_armv8.c b/lib/pfmlib_arm_armv8.c
5e8f80
index 4bc863b..c38bd9b 100644
5e8f80
--- a/lib/pfmlib_arm_armv8.c
5e8f80
+++ b/lib/pfmlib_arm_armv8.c
5e8f80
@@ -30,7 +30,8 @@
5e8f80
 #include "pfmlib_priv.h"			/* library private */
5e8f80
 #include "pfmlib_arm_priv.h"
5e8f80
 
5e8f80
-#include "events/arm_cortex_a57_events.h"    /* event tables */
5e8f80
+#include "events/arm_cortex_a57_events.h"    /* A57 event tables */
5e8f80
+#include "events/arm_cortex_a53_events.h"    /* A53 event tables */
5e8f80
 
5e8f80
 static int
5e8f80
 pfm_arm_detect_cortex_a57(void *this)
5e8f80
@@ -48,6 +49,22 @@ pfm_arm_detect_cortex_a57(void *this)
5e8f80
 	return PFM_ERR_NOTSUPP;
5e8f80
 }
5e8f80
 
5e8f80
+static int
5e8f80
+pfm_arm_detect_cortex_a53(void *this)
5e8f80
+{
5e8f80
+	int ret;
5e8f80
+
5e8f80
+	ret = pfm_arm_detect(this);
5e8f80
+	if (ret != PFM_SUCCESS)
5e8f80
+		return PFM_ERR_NOTSUPP;
5e8f80
+
5e8f80
+	if ((pfm_arm_cfg.implementer == 0x41) && /* ARM */
5e8f80
+		(pfm_arm_cfg.part == 0xd03)) { /* Cortex A53 */
5e8f80
+			return PFM_SUCCESS;
5e8f80
+	}
5e8f80
+	return PFM_ERR_NOTSUPP;
5e8f80
+}
5e8f80
+
5e8f80
 /* ARM Cortex A57 support */
5e8f80
 pfmlib_pmu_t arm_cortex_a57_support={
5e8f80
 	.desc			= "ARM Cortex A57",
5e8f80
@@ -72,3 +89,28 @@ pfmlib_pmu_t arm_cortex_a57_support={
5e8f80
 	 PFMLIB_VALID_PERF_PATTRS(pfm_arm_perf_validate_pattrs),
5e8f80
 	.get_event_nattrs	= pfm_arm_get_event_nattrs,
5e8f80
 };
5e8f80
+
5e8f80
+/* ARM Cortex A53 support */
5e8f80
+pfmlib_pmu_t arm_cortex_a53_support={
5e8f80
+	.desc			= "ARM Cortex A53",
5e8f80
+	.name			= "arm_ac53",
5e8f80
+	.pmu			= PFM_PMU_ARM_CORTEX_A53,
5e8f80
+	.pme_count		= LIBPFM_ARRAY_SIZE(arm_cortex_a53_pe),
5e8f80
+	.type			= PFM_PMU_TYPE_CORE,
5e8f80
+	.pe			= arm_cortex_a53_pe,
5e8f80
+
5e8f80
+	.pmu_detect		= pfm_arm_detect_cortex_a53,
5e8f80
+	.max_encoding		= 1,
5e8f80
+	.num_cntrs		= 6,
5e8f80
+
5e8f80
+	.get_event_encoding[PFM_OS_NONE] = pfm_arm_get_encoding,
5e8f80
+	 PFMLIB_ENCODE_PERF(pfm_arm_get_perf_encoding),
5e8f80
+	.get_event_first	= pfm_arm_get_event_first,
5e8f80
+	.get_event_next		= pfm_arm_get_event_next,
5e8f80
+	.event_is_valid		= pfm_arm_event_is_valid,
5e8f80
+	.validate_table		= pfm_arm_validate_table,
5e8f80
+	.get_event_info		= pfm_arm_get_event_info,
5e8f80
+	.get_event_attr_info	= pfm_arm_get_event_attr_info,
5e8f80
+	 PFMLIB_VALID_PERF_PATTRS(pfm_arm_perf_validate_pattrs),
5e8f80
+	.get_event_nattrs	= pfm_arm_get_event_nattrs,
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_common.c b/lib/pfmlib_common.c
5e8f80
index 900d7de..ebe20da 100644
5e8f80
--- a/lib/pfmlib_common.c
5e8f80
+++ b/lib/pfmlib_common.c
5e8f80
@@ -200,9 +200,11 @@ static pfmlib_pmu_t *pfmlib_pmus[]=
5e8f80
 	&arm_cortex_a15_support,
5e8f80
 	&arm_1176_support,
5e8f80
 	&arm_cortex_a57_support,
5e8f80
+	&arm_cortex_a53_support,
5e8f80
 #endif
5e8f80
 #ifdef CONFIG_PFMLIB_ARCH_ARM64
5e8f80
 	&arm_cortex_a57_support,
5e8f80
+	&arm_cortex_a53_support,
5e8f80
 #endif
5e8f80
 
5e8f80
 #ifdef CONFIG_PFMLIB_ARCH_S390X
5e8f80
diff --git a/lib/pfmlib_priv.h b/lib/pfmlib_priv.h
5e8f80
index 3031d3b..5678cc0 100644
5e8f80
--- a/lib/pfmlib_priv.h
5e8f80
+++ b/lib/pfmlib_priv.h
5e8f80
@@ -333,6 +333,7 @@ extern pfmlib_pmu_t arm_cortex_a15_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a15_support;
5e8f80
 extern pfmlib_pmu_t arm_1176_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a57_support;
5e8f80
+extern pfmlib_pmu_t arm_cortex_a53_support;
5e8f80
 extern pfmlib_pmu_t mips_74k_support;
5e8f80
 extern pfmlib_pmu_t s390x_cpum_cf_support;
5e8f80
 
5e8f80
diff --git a/tests/validate_arm.c b/tests/validate_arm.c
5e8f80
index d6c0168..44eefd4 100644
5e8f80
--- a/tests/validate_arm.c
5e8f80
+++ b/tests/validate_arm.c
5e8f80
@@ -187,6 +187,48 @@ static const test_event_t arm_test_events[]={
5e8f80
 	  .codes[0] = 0x8000008,
5e8f80
 	  .fstr = "arm_ac57::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
 	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES:k",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x88000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=0:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES:k:u",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::INST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000008,
5e8f80
+	  .fstr = "arm_ac53::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::LD_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000006,
5e8f80
+	  .fstr = "arm_ac53::LD_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::ST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000007,
5e8f80
+	  .fstr = "arm_ac53::ST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
 };
5e8f80
 #define NUM_TEST_EVENTS (int)(sizeof(arm_test_events)/sizeof(test_event_t))
5e8f80
 
5e8f80
diff --git a/tests/validate_arm64.c b/tests/validate_arm64.c
5e8f80
index 0f0174c..61400ac 100644
5e8f80
--- a/tests/validate_arm64.c
5e8f80
+++ b/tests/validate_arm64.c
5e8f80
@@ -72,6 +72,48 @@ static const test_event_t arm64_test_events[]={
5e8f80
 	  .codes[0] = 0x8000008,
5e8f80
 	  .fstr = "arm_ac57::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
 	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES:k",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x88000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=0:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::CPU_CYCLES:k:u",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_ac53::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::INST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000008,
5e8f80
+	  .fstr = "arm_ac53::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::LD_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000006,
5e8f80
+	  .fstr = "arm_ac53::LD_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_ac53::ST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000007,
5e8f80
+	  .fstr = "arm_ac53::ST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
 };
5e8f80
 #define NUM_TEST_EVENTS (int)(sizeof(arm64_test_events)/sizeof(test_event_t))
5e8f80
 
5e8f80
Return-Path: wcohen@redhat.com
5e8f80
Received: from zmta06.collab.prod.int.phx2.redhat.com (LHLO
5e8f80
 zmta06.collab.prod.int.phx2.redhat.com) (10.5.81.13) by
5e8f80
 zmail12.collab.prod.int.phx2.redhat.com with LMTP; Wed, 4 Jun 2014 10:54:07
5e8f80
 -0400 (EDT)
5e8f80
Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25])
5e8f80
	by zmta06.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id 1EC57167B59
5e8f80
	for <wcohen@mail.corp.redhat.com>; Wed,  4 Jun 2014 10:54:07 -0400 (EDT)
5e8f80
Received: from santana.rdu.redhat.com (dhcp129-21.rdu.redhat.com [10.13.129.21])
5e8f80
	by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s54Es62r009804;
5e8f80
	Wed, 4 Jun 2014 10:54:06 -0400
5e8f80
From: William Cohen <wcohen@redhat.com>
5e8f80
To: perfmon2-devel@lists.sourceforge.net
5e8f80
Cc: William Cohen <wcohen@redhat.com>
5e8f80
Subject: [PATCH] Add support for Applied Micro X-Gene processor
5e8f80
Date: Wed,  4 Jun 2014 10:54:04 -0400
5e8f80
Message-Id: <1401893644-22326-1-git-send-email-wcohen@redhat.com>
5e8f80
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
5e8f80
5e8f80
---
5e8f80
 README                        |   1 +
5e8f80
 docs/Makefile                 |   6 +-
5e8f80
 docs/man3/libpfm_arm_xgene.3  |  39 ++++
5e8f80
 include/perfmon/pfmlib.h      |   1 +
5e8f80
 lib/events/arm_xgene_events.h | 515 ++++++++++++++++++++++++++++++++++++++++++
5e8f80
 lib/pfmlib_arm_armv8.c        |  42 ++++
5e8f80
 lib/pfmlib_common.c           |   2 +
5e8f80
 lib/pfmlib_priv.h             |   1 +
5e8f80
 tests/validate_arm64.c        |  28 +++
5e8f80
 9 files changed, 633 insertions(+), 2 deletions(-)
5e8f80
 create mode 100644 docs/man3/libpfm_arm_xgene.3
5e8f80
 create mode 100644 lib/events/arm_xgene_events.h
5e8f80
5e8f80
diff --git a/README b/README
5e8f80
index e74238f..f6f45c9 100644
5e8f80
--- a/README
5e8f80
+++ b/README
5e8f80
@@ -58,6 +58,7 @@ The library supports many PMUs. The current version can handle:
5e8f80
 		ARMV7 Cortex A9
5e8f80
 		ARMV7 Cortex A15
5e8f80
 		ARMV8 Cortex A57, A53
5e8f80
+		Applied Micro X-Gene
5e8f80
 
5e8f80
 	- For SPARC
5e8f80
 		Ultra I, II
5e8f80
diff --git a/docs/Makefile b/docs/Makefile
5e8f80
index c7d797e..4ae4bae 100644
5e8f80
--- a/docs/Makefile
5e8f80
+++ b/docs/Makefile
5e8f80
@@ -76,7 +76,8 @@ endif
5e8f80
 endif
5e8f80
 
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_ARM),y)
5e8f80
-ARCH_MAN += libpfm_arm_ac57.3 \
5e8f80
+ARCH_MAN += libpfm_arm_xgene.3 \
5e8f80
+	    libpfm_arm_ac57.3 \
5e8f80
 	    libpfm_arm_ac53.3 \
5e8f80
 	    libpfm_arm_ac15.3 \
5e8f80
 	    libpfm_arm_ac8.3 \
5e8f80
@@ -85,7 +86,8 @@ ARCH_MAN += libpfm_arm_ac57.3 \
5e8f80
 endif
5e8f80
 
5e8f80
 ifeq ($(CONFIG_PFMLIB_ARCH_ARM64),y)
5e8f80
-ARCH_MAN += libpfm_arm_ac57.3 \
5e8f80
+ARCH_MAN += libpfm_arm_xgene.3 \
5e8f80
+	    libpfm_arm_ac57.3 \
5e8f80
 	    libpfm_arm_ac53.3
5e8f80
 endif
5e8f80
 
5e8f80
diff --git a/docs/man3/libpfm_arm_xgene.3 b/docs/man3/libpfm_arm_xgene.3
5e8f80
new file mode 100644
5e8f80
index 0000000..a0a84bc
5e8f80
--- /dev/null
5e8f80
+++ b/docs/man3/libpfm_arm_xgene.3
5e8f80
@@ -0,0 +1,39 @@
5e8f80
+.TH LIBPFM 4  "May, 2014" "" "Linux Programmer's Manual"
5e8f80
+.SH NAME
5e8f80
+libpfm_arm_ac57 - support for Applied Micro X-Gene PMU
5e8f80
+.SH SYNOPSIS
5e8f80
+.nf
5e8f80
+.B #include <perfmon/pfmlib.h>
5e8f80
+.sp
5e8f80
+.B PMU name: arm_xgene
5e8f80
+.B PMU desc: Applied Micro X-Gene
5e8f80
+.sp
5e8f80
+.SH DESCRIPTION
5e8f80
+The library supports the Applied Micro X-Gene PMU.
5e8f80
+
5e8f80
+This PMU supports 6 counters and privilege levels filtering.
5e8f80
+It can operate in both 32 and 64 bit modes.
5e8f80
+
5e8f80
+.SH MODIFIERS
5e8f80
+The following modifiers are supported on Applied Micro X-Gene:
5e8f80
+.TP
5e8f80
+.B u
5e8f80
+Measure at the user level. This corresponds to \fBPFM_PLM3\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B k
5e8f80
+Measure at the kernel level. This corresponds to \fBPFM_PLM0\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+.TP
5e8f80
+.B hv
5e8f80
+Measure at the hypervisor level. This corresponds to \fBPFM_PLMH\fR.
5e8f80
+This is a boolean modifier.
5e8f80
+
5e8f80
+.SH AUTHORS
5e8f80
+.nf
5e8f80
+Stephane Eranian <eranian@gmail.com>
5e8f80
+.if
5e8f80
+.nf
5e8f80
+William Cohen <wcohen@redhat.com>
5e8f80
+.if
5e8f80
+.PP
5e8f80
diff --git a/include/perfmon/pfmlib.h b/include/perfmon/pfmlib.h
5e8f80
index a7ec026..b7b312e 100644
5e8f80
--- a/include/perfmon/pfmlib.h
5e8f80
+++ b/include/perfmon/pfmlib.h
5e8f80
@@ -239,6 +239,7 @@ typedef enum {
5e8f80
 
5e8f80
 	PFM_PMU_ARM_CORTEX_A57,		/* ARM Cortex A57 (ARMv8) */
5e8f80
 	PFM_PMU_ARM_CORTEX_A53,		/* ARM Cortex A53 (ARMv8) */
5e8f80
+	PFM_PMU_ARM_XGENE,		/* Applied Micro X-Gene (ARMv8) */
5e8f80
 
5e8f80
 	/* MUST ADD NEW PMU MODELS HERE */
5e8f80
 
5e8f80
diff --git a/lib/events/arm_xgene_events.h b/lib/events/arm_xgene_events.h
5e8f80
new file mode 100644
5e8f80
index 0000000..856dac1
5e8f80
--- /dev/null
5e8f80
+++ b/lib/events/arm_xgene_events.h
5e8f80
@@ -0,0 +1,515 @@
5e8f80
+/*
5e8f80
+ * Copyright (c) 2014 Google Inc. All rights reserved
5e8f80
+ * Copyright (c) 2014 Red Hat Inc. All rights reserved
5e8f80
+ * Contributed by William Cohen <wcohen@redhat.com>
5e8f80
+ *
5e8f80
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5e8f80
+ * of this software and associated documentation files (the "Software"), to deal
5e8f80
+ * in the Software without restriction, including without limitation the rights
5e8f80
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
5e8f80
+ * of the Software, and to permit persons to whom the Software is furnished to do so,
5e8f80
+ * subject to the following conditions:
5e8f80
+ *
5e8f80
+ * The above copyright notice and this permission notice shall be included in all
5e8f80
+ * copies or substantial portions of the Software.
5e8f80
+ *
5e8f80
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
5e8f80
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
5e8f80
+ * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
5e8f80
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
5e8f80
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
5e8f80
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5e8f80
+ *
5e8f80
+ * Applied Micro X-Gene
5e8f80
+ * based on Mustang (X-Gene) Software User Guide 15.1.2 CPU PMU Event list
5e8f80
+ */
5e8f80
+
5e8f80
+static const arm_entry_t arm_xgene_pe[]={
5e8f80
+	{.name = "SW_INCR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x00,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Software increment"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x01,
5e8f80
+	 .desc = "Level 1 instruction cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1I_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x02,
5e8f80
+	 .desc = "Level 1 instruction TLB refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x03,
5e8f80
+	 .desc = "Level 1 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x04,
5e8f80
+	 .desc = "Level 1 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x05,
5e8f80
+	 .desc = "Level 1 data TLB refill"
5e8f80
+	},
5e8f80
+	{.name = "INST_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x08,
5e8f80
+	 .desc = "Instruction architecturally executed"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TAKEN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x09,
5e8f80
+	 .desc = "Exception taken"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_RETURN",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0a,
5e8f80
+	 .desc = "Instruction architecturally executed (condition check pass) Exception return"
5e8f80
+	},
5e8f80
+	{.name = "CID_WRITE_RETIRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x0b,
5e8f80
+	 .desc = "Change to Context ID retired",
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_MISPRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10,
5e8f80
+	 .desc = "Mispredicted or not predicted branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "CPU_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x11,
5e8f80
+	 .desc = "Cycles"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_PRED",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x12,
5e8f80
+	 .desc = "Predictable branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x13,
5e8f80
+	 .desc = "Data memory access"
5e8f80
+	},
5e8f80
+	{.name = "L1I_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x14,
5e8f80
+	 .desc = "Level 1 instruction cache access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x16,
5e8f80
+	 .desc = "Level 2 data cache access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x17,
5e8f80
+	 .desc = "Level 2 data cache refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_CACHE_WB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x18,
5e8f80
+	 .desc = "Level 2 data cache WriteBack"
5e8f80
+	},
5e8f80
+	{.name = "BUS_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x19,
5e8f80
+	 .desc = "Bus access"
5e8f80
+	},
5e8f80
+	{.name = "LOCAL_MEMORY_ERROR",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x1a,
5e8f80
+	 .desc = "Local memory error"
5e8f80
+	},
5e8f80
+
5e8f80
+	{.name = "L1D_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x40,
5e8f80
+	 .desc = "Level 1 data cache read access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x41,
5e8f80
+	 .desc = "Level 1 data cache write access"
5e8f80
+	},
5e8f80
+	{.name = "L1D_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x42,
5e8f80
+	 .desc = "Level 1 data cache read refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_INVALIDATE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x48,
5e8f80
+	 .desc = "Level 1 data cache invalidate"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x4c,
5e8f80
+	 .desc = "Level 1 data TLB read refill"
5e8f80
+	},
5e8f80
+	{.name = "L1D_TLB_WRITE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x4d,
5e8f80
+	 .desc = "Level 1 data TLB write refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x50,
5e8f80
+	 .desc = "Level 2 data cache read access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x51,
5e8f80
+	 .desc = "Level 2 data cache write access"
5e8f80
+	},
5e8f80
+	{.name = "L2D_READ_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x52,
5e8f80
+	 .desc = "Level 2 data cache read refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WRITE_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x53,
5e8f80
+	 .desc = "Level 2 data cache write refill"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WB_VICTIM",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x56,
5e8f80
+	 .desc = "Level 2 data cache writeback victim"
5e8f80
+	},
5e8f80
+	{.name = "L2D_WB_CLEAN_COHERENCY",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x57,
5e8f80
+	 .desc = "Level 2 data cache writeback cleaning and coherency"
5e8f80
+	},
5e8f80
+	{.name = "L2D_INVALIDATE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x58,
5e8f80
+	 .desc = "Level 2 data cache invalidate"
5e8f80
+	},
5e8f80
+	{.name = "BUS_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x60,
5e8f80
+	 .desc = "Bus read access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x61,
5e8f80
+	 .desc = "Bus write access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NORMAL_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x62,
5e8f80
+	 .desc = "Bus normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NOT_NORMAL_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x63,
5e8f80
+	 .desc = "Bus not normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_NORMAL_ACCESS_2",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x64,
5e8f80
+	 .desc = "Bus normal access"
5e8f80
+	},
5e8f80
+	{.name = "BUS_PERIPH_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x65,
5e8f80
+	 .desc = "Bus peripheral access"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x66,
5e8f80
+	 .desc = "Data memory read access"
5e8f80
+	},
5e8f80
+	{.name = "DATA_MEM_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x67,
5e8f80
+	 .desc = "Data memory write access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_READ_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x68,
5e8f80
+	 .desc = "Unaligned read access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_WRITE_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x69,
5e8f80
+	 .desc = "Unaligned read access"
5e8f80
+	},
5e8f80
+	{.name = "UNALIGNED_ACCESS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6a,
5e8f80
+	 .desc = "Unaligned access"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LDREX",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6c,
5e8f80
+	 .desc = "LDREX exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STREX_PASS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6d,
5e8f80
+	 .desc = "STREX pass exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STREX_FAIL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x6e,
5e8f80
+	 .desc = "STREX fail exclusive instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LOAD",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x70,
5e8f80
+	 .desc = "Load instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_STORE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x71,
5e8f80
+	 .desc = "Store instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_LOAD_STORE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x72,
5e8f80
+	 .desc = "Load or store instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_INTEGER_INST",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x73,
5e8f80
+	 .desc = "Integer data processing instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_SIMD",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x74,
5e8f80
+	 .desc = "Advanced SIMD instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_VFP",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x75,
5e8f80
+	 .desc = "VFP instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_SOFT_PC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x76,
5e8f80
+	 .desc = "Software of the PC instruction speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_IMM_BRANCH",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x78,
5e8f80
+	 .desc = "Immediate branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_RET",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x79,
5e8f80
+	 .desc = "Return branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BRANCH_SPEC_EXEC_IND",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7a,
5e8f80
+	 .desc = "Indirect branch speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_ISB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7c,
5e8f80
+	 .desc = "ISB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_DSB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7d,
5e8f80
+	 .desc = "DSB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "BARRIER_SPEC_EXEC_DMB",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x7e,
5e8f80
+	 .desc = "DMB barrier speculatively executed"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_UNDEF",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x81,
5e8f80
+	 .desc = "Exception taken, other synchronous"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_SVC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x82,
5e8f80
+	 .desc = "Exception taken, supervisor call"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_PABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x83,
5e8f80
+	 .desc = "Exception taken, instruction abort"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_DABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x84,
5e8f80
+	 .desc = "Exception taken, data abort or SError"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_IRQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x86,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_FIQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x87,
5e8f80
+	 .desc = "Exception taken, irq"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_HVC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8a,
5e8f80
+	 .desc = "Exception taken, hypervisor call"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_PABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8b,
5e8f80
+	 .desc = "Exception taken, instruction abort not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_DABORT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8c,
5e8f80
+	 .desc = "Exception taken, data abort or SError not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_OTHER",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8d,
5e8f80
+	 .desc = "Exception taken, other traps not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_IRQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8e,
5e8f80
+	 .desc = "Exception taken, irq not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "EXCEPTION_TRAP_FIQ",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x8f,
5e8f80
+	 .desc = "Exception taken, fiq not taken locally"
5e8f80
+	},
5e8f80
+	{.name = "RC_LD_SPEC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x90,
5e8f80
+	 .desc = "Release consistency instruction speculatively executed (load-acquire)",
5e8f80
+	},
5e8f80
+	{.name = "RC_ST_SPEC",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x91,
5e8f80
+	 .desc = "Release consistency instruction speculatively executed (store-release)",
5e8f80
+	},
5e8f80
+	{.name = "INST_SPEC_EXEC_NOP",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x100,
5e8f80
+	 .desc = "Operation speculatively executed - NOP",
5e8f80
+	},
5e8f80
+	{.name = "FSU_CLOCK_OFF",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x101,
5e8f80
+	 .desc = "FSU clocking gated off cycle",
5e8f80
+	},
5e8f80
+	{.name = "BTB_MISPREDICT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x102,
5e8f80
+	 .desc = "BTB misprediction",
5e8f80
+	},
5e8f80
+	{.name = "ITB_MISS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x103,
5e8f80
+	 .desc = "ITB miss",
5e8f80
+	},
5e8f80
+	{.name = "DTB_MISS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x104,
5e8f80
+	 .desc = "DTB miss",
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_LATE_MISS",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x105,
5e8f80
+	 .desc = "L1 data cache late miss",
5e8f80
+	},
5e8f80
+	{.name = "L1D_CACHE_PREFETCH",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x106,
5e8f80
+	 .desc = "L1 data cache prefetch request",
5e8f80
+	},
5e8f80
+	{.name = "L2_CACHE_PREFETCH",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x107,
5e8f80
+	 .desc = "L2 data prefetch request",
5e8f80
+	},
5e8f80
+	{.name = "STALLED_CYCLES_FRONTEND",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x108,
5e8f80
+	 .desc = "Decode starved for instruction cycle",
5e8f80
+	},
5e8f80
+	{.name = "STALLED_CYCLES_BACKEND",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x109,
5e8f80
+	 .desc = "Op dispatch stalled cycle",
5e8f80
+	},
5e8f80
+	{.name = "IXA_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10A,
5e8f80
+	 .desc = "IXA Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "IXB_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10B,
5e8f80
+	 .desc = "IXB Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "BX_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10C,
5e8f80
+	 .desc = "BX Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "LX_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10D,
5e8f80
+	 .desc = "LX Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "SX_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10E,
5e8f80
+	 .desc = "SX Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "FX_NO_ISSUE",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x10F,
5e8f80
+	 .desc = "FX Op non-issue",
5e8f80
+	},
5e8f80
+	{.name = "WAIT_CYCLES",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x110,
5e8f80
+	 .desc = "Wait state cycle",
5e8f80
+	},
5e8f80
+	{.name = "L1_STAGE2_TLB_REFILL",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x111,
5e8f80
+	 .desc = "L1 stage-2 TLB refill",
5e8f80
+	},
5e8f80
+	{.name = "PAGE_WALK_L0_STAGE1_HIT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x112,
5e8f80
+	 .desc = "Page Walk Cache level-0 stage-1 hit",
5e8f80
+	},
5e8f80
+	{.name = "PAGE_WALK_L1_STAGE1_HIT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x113,
5e8f80
+	 .desc = "Page Walk Cache level-1 stage-1 hit",
5e8f80
+	},
5e8f80
+	{.name = "PAGE_WALK_L2_STAGE1_HIT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x114,
5e8f80
+	 .desc = "Page Walk Cache level-2 stage-1 hit",
5e8f80
+	},
5e8f80
+	{.name = "PAGE_WALK_L1_STAGE2_HIT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x115,
5e8f80
+	 .desc = "Page Walk Cache level-1 stage-2 hit",
5e8f80
+	},
5e8f80
+	{.name = "PAGE_WALK_L2_STAGE2_HIT",
5e8f80
+	 .modmsk = ARMV8_ATTRS,
5e8f80
+	 .code = 0x116,
5e8f80
+	 .desc = "Page Walk Cache level-2 stage-2 hit",
5e8f80
+	},
5e8f80
+	/* END Applied Micro X-Gene specific events */
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_arm_armv8.c b/lib/pfmlib_arm_armv8.c
5e8f80
index c38bd9b..3619508 100644
5e8f80
--- a/lib/pfmlib_arm_armv8.c
5e8f80
+++ b/lib/pfmlib_arm_armv8.c
5e8f80
@@ -32,6 +32,7 @@
5e8f80
 
5e8f80
 #include "events/arm_cortex_a57_events.h"    /* A57 event tables */
5e8f80
 #include "events/arm_cortex_a53_events.h"    /* A53 event tables */
5e8f80
+#include "events/arm_xgene_events.h"         /* Applied Micro X-Gene tables */
5e8f80
 
5e8f80
 static int
5e8f80
 pfm_arm_detect_cortex_a57(void *this)
5e8f80
@@ -65,6 +66,22 @@ pfm_arm_detect_cortex_a53(void *this)
5e8f80
 	return PFM_ERR_NOTSUPP;
5e8f80
 }
5e8f80
 
5e8f80
+static int
5e8f80
+pfm_arm_detect_xgene(void *this)
5e8f80
+{
5e8f80
+	int ret;
5e8f80
+
5e8f80
+	ret = pfm_arm_detect(this);
5e8f80
+	if (ret != PFM_SUCCESS)
5e8f80
+		return PFM_ERR_NOTSUPP;
5e8f80
+
5e8f80
+	if ((pfm_arm_cfg.implementer == 0x50) && /* Applied Micro */
5e8f80
+		(pfm_arm_cfg.part == 0x000)) { /* Applied Micro X-Gene */
5e8f80
+			return PFM_SUCCESS;
5e8f80
+	}
5e8f80
+	return PFM_ERR_NOTSUPP;
5e8f80
+}
5e8f80
+
5e8f80
 /* ARM Cortex A57 support */
5e8f80
 pfmlib_pmu_t arm_cortex_a57_support={
5e8f80
 	.desc			= "ARM Cortex A57",
5e8f80
@@ -114,3 +131,28 @@ pfmlib_pmu_t arm_cortex_a53_support={
5e8f80
 	 PFMLIB_VALID_PERF_PATTRS(pfm_arm_perf_validate_pattrs),
5e8f80
 	.get_event_nattrs	= pfm_arm_get_event_nattrs,
5e8f80
 };
5e8f80
+
5e8f80
+/* Applied Micro X-Gene support */
5e8f80
+pfmlib_pmu_t arm_xgene_support={
5e8f80
+	.desc			= "Applied Micro X-Gene",
5e8f80
+	.name			= "arm_xgene",
5e8f80
+	.pmu			= PFM_PMU_ARM_XGENE,
5e8f80
+	.pme_count		= LIBPFM_ARRAY_SIZE(arm_xgene_pe),
5e8f80
+	.type			= PFM_PMU_TYPE_CORE,
5e8f80
+	.pe			= arm_xgene_pe,
5e8f80
+
5e8f80
+	.pmu_detect		= pfm_arm_detect_xgene,
5e8f80
+	.max_encoding		= 1,
5e8f80
+	.num_cntrs		= 6,
5e8f80
+
5e8f80
+	.get_event_encoding[PFM_OS_NONE] = pfm_arm_get_encoding,
5e8f80
+	 PFMLIB_ENCODE_PERF(pfm_arm_get_perf_encoding),
5e8f80
+	.get_event_first	= pfm_arm_get_event_first,
5e8f80
+	.get_event_next		= pfm_arm_get_event_next,
5e8f80
+	.event_is_valid		= pfm_arm_event_is_valid,
5e8f80
+	.validate_table		= pfm_arm_validate_table,
5e8f80
+	.get_event_info		= pfm_arm_get_event_info,
5e8f80
+	.get_event_attr_info	= pfm_arm_get_event_attr_info,
5e8f80
+	 PFMLIB_VALID_PERF_PATTRS(pfm_arm_perf_validate_pattrs),
5e8f80
+	.get_event_nattrs	= pfm_arm_get_event_nattrs,
5e8f80
+};
5e8f80
diff --git a/lib/pfmlib_common.c b/lib/pfmlib_common.c
5e8f80
index ebe20da..569ce85 100644
5e8f80
--- a/lib/pfmlib_common.c
5e8f80
+++ b/lib/pfmlib_common.c
5e8f80
@@ -201,10 +201,12 @@ static pfmlib_pmu_t *pfmlib_pmus[]=
5e8f80
 	&arm_1176_support,
5e8f80
 	&arm_cortex_a57_support,
5e8f80
 	&arm_cortex_a53_support,
5e8f80
+	&arm_xgene_support,
5e8f80
 #endif
5e8f80
 #ifdef CONFIG_PFMLIB_ARCH_ARM64
5e8f80
 	&arm_cortex_a57_support,
5e8f80
 	&arm_cortex_a53_support,
5e8f80
+	&arm_xgene_support,
5e8f80
 #endif
5e8f80
 
5e8f80
 #ifdef CONFIG_PFMLIB_ARCH_S390X
5e8f80
diff --git a/lib/pfmlib_priv.h b/lib/pfmlib_priv.h
5e8f80
index 5678cc0..1666bcb 100644
5e8f80
--- a/lib/pfmlib_priv.h
5e8f80
+++ b/lib/pfmlib_priv.h
5e8f80
@@ -334,6 +334,7 @@ extern pfmlib_pmu_t arm_1176_support;
5e8f80
 extern pfmlib_pmu_t arm_1176_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a57_support;
5e8f80
 extern pfmlib_pmu_t arm_cortex_a53_support;
5e8f80
+extern pfmlib_pmu_t arm_xgene_support;
5e8f80
 extern pfmlib_pmu_t mips_74k_support;
5e8f80
 extern pfmlib_pmu_t s390x_cpum_cf_support;
5e8f80
 
5e8f80
diff --git a/tests/validate_arm64.c b/tests/validate_arm64.c
5e8f80
index 61400ac..f4593de 100644
5e8f80
--- a/tests/validate_arm64.c
5e8f80
+++ b/tests/validate_arm64.c
5e8f80
@@ -114,6 +114,34 @@ static const test_event_t arm64_test_events[]={
5e8f80
 	  .codes[0] = 0x8000007,
5e8f80
 	  .fstr = "arm_ac53::ST_RETIRED:k=1:u=1:hv=0",
5e8f80
 	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_xgene::CPU_CYCLES",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_xgene::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_xgene::CPU_CYCLES:k",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x88000011,
5e8f80
+	  .fstr = "arm_xgene::CPU_CYCLES:k=1:u=0:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_xgene::CPU_CYCLES:k:u",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000011,
5e8f80
+	  .fstr = "arm_xgene::CPU_CYCLES:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
+	{ SRC_LINE,
5e8f80
+	  .name = "arm_xgene::INST_RETIRED",
5e8f80
+	  .ret  = PFM_SUCCESS,
5e8f80
+	  .count = 1,
5e8f80
+	  .codes[0] = 0x8000008,
5e8f80
+	  .fstr = "arm_xgene::INST_RETIRED:k=1:u=1:hv=0",
5e8f80
+	},
5e8f80
 };
5e8f80
 #define NUM_TEST_EVENTS (int)(sizeof(arm64_test_events)/sizeof(test_event_t))
5e8f80
 
5e8f80
-- 
5e8f80
1.9.3
5e8f80