db39d7
commit 9b38b5435de72ae4253bd8a6d6558e50fff618e7
db39d7
Author: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
Date:   Fri Feb 17 15:50:14 2017 +0100
db39d7
db39d7
    s390/cpumf: add support for IBM z13/z13s counters
db39d7
    
db39d7
    This commit adds the counter definitions for the IBM z13/z13s
db39d7
    specific counters.  These counters are available in the extended
db39d7
    and the new MT-diagnostic counter sets.
db39d7
    
db39d7
    Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
db39d7
diff --git a/lib/events/s390x_cpumf_events.h b/lib/events/s390x_cpumf_events.h
db39d7
index e00b088..be9d7d9 100644
db39d7
--- a/lib/events/s390x_cpumf_events.h
db39d7
+++ b/lib/events/s390x_cpumf_events.h
db39d7
@@ -11,6 +11,7 @@
db39d7
 #define CPUMF_CTRSET_PROBLEM_STATE      4
db39d7
 #define CPUMF_CTRSET_CRYPTO             8
db39d7
 #define CPUMF_CTRSET_EXTENDED           1
db39d7
+#define CPUMF_CTRSET_MT_DIAG            32
db39d7
 
db39d7
 
db39d7
 static const pme_cpumf_ctr_t cpumcf_generic_counters[] = {
db39d7
@@ -840,6 +841,458 @@ static const pme_cpumf_ctr_t cpumcf_zec12_counters[] = {
db39d7
 	},
db39d7
 };
db39d7
 
db39d7
+static const pme_cpumf_ctr_t cpumcf_z13_counters[] = {
db39d7
+	{
db39d7
+		.ctrnum = 128,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_WRITES_RO_EXCL",
db39d7
+		.desc = "Counter:128 Name:L1D_WRITES_RO_EXCL A directory"
db39d7
+			" write to the Level-1 Data cache where the line was"
db39d7
+			" originally in a Read-Only state in the cache but"
db39d7
+			" has been updated to be in the Exclusive state that"
db39d7
+			" allows stores to the cache line.",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 129,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB1_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-1"
db39d7
+			" Data Translation Lookaside Buffer",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 130,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB1_MISSES",
db39d7
+		.desc = "Level-1 Data TLB miss in progress. Incremented by"
db39d7
+			" one for every cycle a DTLB1 miss is in progress.",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 131,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB1_HPAGE_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-1"
db39d7
+			" Data Translation Lookaside Buffer for a one-"
db39d7
+			" megabyte page",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 132,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB1_GPAGE_WRITES",
db39d7
+		.desc = "Counter:132 Name:DTLB1_GPAGE_WRITES A translation"
db39d7
+			" entry has been written to the Level-1 Data"
db39d7
+			" Translation Lookaside Buffer for a two-gigabyte"
db39d7
+			" page.",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 133,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_L2D_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from the Level-2 Data cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 134,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "ITLB1_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-1"
db39d7
+			" Instruction Translation Lookaside Buffer",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 135,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "ITLB1_MISSES",
db39d7
+		.desc = "Level-1 Instruction TLB miss in progress."
db39d7
+			" Incremented by one for every cycle an ITLB1 miss is"
db39d7
+			" in progress",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 136,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_L2I_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from the Level-2 Instruction cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 137,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_PTE_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-2"
db39d7
+			" TLB Page Table Entry arrays",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 138,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_CRSTE_HPAGE_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-2"
db39d7
+			" TLB Combined Region Segment Table Entry arrays for"
db39d7
+			" a one-megabyte large page translation",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 139,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_CRSTE_WRITES",
db39d7
+		.desc = "A translation entry has been written to the Level-2"
db39d7
+			" TLB Combined Region Segment Table Entry arrays",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 140,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TEND",
db39d7
+		.desc = "A TEND instruction has completed in a constrained"
db39d7
+			" transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 141,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_NC_TEND",
db39d7
+		.desc = "A TEND instruction has completed in a non-"
db39d7
+			" constrained transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 143,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1C_TLB1_MISSES",
db39d7
+		.desc = "Increments by one for any cycle where a Level-1"
db39d7
+			" cache or Level-1 TLB miss is in progress.",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 144,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Chip Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 145,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Chip Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 146,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONNODE_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 147,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONNODE_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 148,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONNODE_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 149,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 150,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONDRAWER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 151,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONDRAWER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 152,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_SCOL_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 153,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-3 cache with"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 154,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_SCOL_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-3 cache"
db39d7
+			" without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 155,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_FCOL_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 156,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-3 cache with"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 157,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_FCOL_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 158,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONNODE_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Node memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 159,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONDRAWER_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 160,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 161,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Chip memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 162,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Chip Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 163,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On Chip Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 164,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONNODE_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 165,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONNODE_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 166,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONNODE_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Node Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 167,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 168,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONDRAWER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 169,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONDRAWER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Drawer Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 170,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_SCOL_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 171,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-3 cache with"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 172,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_SCOL_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Same-Column Level-3 cache"
db39d7
+			" without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 173,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_FCOL_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 174,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-3 cache with"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 175,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_FCOL_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Far-Column Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 176,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONNODE_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Node memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 177,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONDRAWER_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 178,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 179,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_MEM_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Chip memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 218,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_NC_TABORT",
db39d7
+		.desc = "A transaction abort has occurred in a non-"
db39d7
+			" constrained transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 219,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TABORT_NO_SPECIAL",
db39d7
+		.desc = "A transaction abort has occurred in a constrained"
db39d7
+			" transactional-execution mode and the CPU is not"
db39d7
+			" using any special logic to allow the transaction to"
db39d7
+			" complete",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 220,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TABORT_SPECIAL",
db39d7
+		.desc = "A transaction abort has occurred in a constrained"
db39d7
+			" transactional-execution mode and the CPU is using"
db39d7
+			" special logic to allow the transaction to complete",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 448,
db39d7
+		.ctrset = CPUMF_CTRSET_MT_DIAG,
db39d7
+		.name = "MT_DIAG_CYCLES_ONE_THR_ACTIVE",
db39d7
+		.desc = "Cycle count with one thread active",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 449,
db39d7
+		.ctrset = CPUMF_CTRSET_MT_DIAG,
db39d7
+		.name = "MT_DIAG_CYCLES_TWO_THR_ACTIVE",
db39d7
+		.desc = "Cycle count with two threads active",
db39d7
+	},
db39d7
+};
db39d7
+
db39d7
 static const pme_cpumf_ctr_t cpumsf_counters[] = {
db39d7
 	{
db39d7
 		.ctrnum = 720896,
db39d7
diff --git a/lib/pfmlib_s390x_cpumf.c b/lib/pfmlib_s390x_cpumf.c
db39d7
index b5444ef..7273962 100644
db39d7
--- a/lib/pfmlib_s390x_cpumf.c
db39d7
+++ b/lib/pfmlib_s390x_cpumf.c
db39d7
@@ -128,6 +128,11 @@ static int pfm_cpumcf_init(void *this)
db39d7
 		ext_set = cpumcf_zec12_counters;
db39d7
 		ext_set_count = LIBPFM_ARRAY_SIZE(cpumcf_zec12_counters);
db39d7
 		break;
db39d7
+	case 2964:  /* IBM z13  */
db39d7
+	case 2965:  /* IBM z13s */
db39d7
+		ext_set = cpumcf_z13_counters;
db39d7
+		ext_set_count = LIBPFM_ARRAY_SIZE(cpumcf_z13_counters);
db39d7
+		break;
db39d7
 	default:
db39d7
 		/* No extended counter set for this machine type or there
db39d7
 		 * was an error retrieving the machine type */
db39d7
commit 8f2653b8e2e18bad44ba1acc7f92c825f226ef71
db39d7
Author: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
Date:   Fri Oct 13 16:57:32 2017 +0200
db39d7
db39d7
    s390/cpumf: add support for IBM z14 counters
db39d7
    
db39d7
    Add counter definitions for the IBM z14 hardware model.  With z14,
db39d7
    the counters in the problem-state set are reduced and the counter
db39d7
    first number version is increased accordingly.  Now, the counters
db39d7
    are processed depending on the counter facility versions.
db39d7
    
db39d7
    Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
db39d7
diff --git a/lib/events/s390x_cpumf_events.h b/lib/events/s390x_cpumf_events.h
db39d7
index be9d7d9..c843bc3 100644
db39d7
--- a/lib/events/s390x_cpumf_events.h
db39d7
+++ b/lib/events/s390x_cpumf_events.h
db39d7
@@ -14,7 +14,7 @@
db39d7
 #define CPUMF_CTRSET_MT_DIAG            32
db39d7
 
db39d7
 
db39d7
-static const pme_cpumf_ctr_t cpumcf_generic_counters[] = {
db39d7
+static const pme_cpumf_ctr_t cpumcf_fvn1_counters[] = {
db39d7
 	{
db39d7
 		.ctrnum = 0,
db39d7
 		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
@@ -87,6 +87,60 @@ static const pme_cpumf_ctr_t cpumcf_generic_counters[] = {
db39d7
 		.name = "PROBLEM_STATE_L1D_PENALTY_CYCLES",
db39d7
 		.desc = "Problem-State Level-1 D-Cache Penalty Cycle Count",
db39d7
 	},
db39d7
+};
db39d7
+
db39d7
+static const pme_cpumf_ctr_t cpumcf_fvn3_counters[] = {
db39d7
+	{
db39d7
+		.ctrnum = 0,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "CPU_CYCLES",
db39d7
+		.desc = "Cycle Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 1,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "INSTRUCTIONS",
db39d7
+		.desc = "Instruction Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 2,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "L1I_DIR_WRITES",
db39d7
+		.desc = "Level-1 I-Cache Directory Write Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 3,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "L1I_PENALTY_CYCLES",
db39d7
+		.desc = "Level-1 I-Cache Penalty Cycle Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 4,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "L1D_DIR_WRITES",
db39d7
+		.desc = "Level-1 D-Cache Directory Write Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 5,
db39d7
+		.ctrset = CPUMF_CTRSET_BASIC,
db39d7
+		.name = "L1D_PENALTY_CYCLES",
db39d7
+		.desc = "Level-1 D-Cache Penalty Cycle Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 32,
db39d7
+		.ctrset = CPUMF_CTRSET_PROBLEM_STATE,
db39d7
+		.name = "PROBLEM_STATE_CPU_CYCLES",
db39d7
+		.desc = "Problem-State Cycle Count",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 33,
db39d7
+		.ctrset = CPUMF_CTRSET_PROBLEM_STATE,
db39d7
+		.name = "PROBLEM_STATE_INSTRUCTIONS",
db39d7
+		.desc = "Problem-State Instruction Count",
db39d7
+	},
db39d7
+};
db39d7
+
db39d7
+static const pme_cpumf_ctr_t cpumcf_svn_generic_counters[] = {
db39d7
 	{
db39d7
 		.ctrnum = 64,
db39d7
 		.ctrset = CPUMF_CTRSET_CRYPTO,
db39d7
@@ -1293,6 +1347,434 @@ static const pme_cpumf_ctr_t cpumcf_z13_counters[] = {
db39d7
 	},
db39d7
 };
db39d7
 
db39d7
+static const pme_cpumf_ctr_t cpumcf_z14_counters[] = {
db39d7
+	{
db39d7
+		.ctrnum = 128,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_WRITES_RO_EXCL",
db39d7
+		.desc = "Counter:128 Name:L1D_WRITES_RO_EXCL A directory"
db39d7
+			" write to the Level-1 Data cache where the line was"
db39d7
+			" originally in a Read-Only state in the cache but"
db39d7
+			" has been updated to be in the Exclusive state that"
db39d7
+			" allows stores to the cache line",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 129,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB2_WRITES",
db39d7
+		.desc = "A translation has been written into The Translation"
db39d7
+			" Lookaside Buffer 2 (TLB2) and the request was made"
db39d7
+			" by the data cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 130,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB2_MISSES",
db39d7
+		.desc = "A TLB2 miss is in progress for a request made by"
db39d7
+			" the data cache. Incremented by one for every TLB2"
db39d7
+			" miss in progress for the Level-1 Data cache on this"
db39d7
+			" cycle",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 131,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB2_HPAGE_WRITES",
db39d7
+		.desc = "A translation entry was written into the Combined"
db39d7
+			" Region and Segment Table Entry array in the Level-2"
db39d7
+			" TLB for a one-megabyte page or a Last Host"
db39d7
+			" Translation was done",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 132,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DTLB2_GPAGE_WRITES",
db39d7
+		.desc = "A translation entry for a two-gigabyte page was"
db39d7
+			" written into the Level-2 TLB",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 133,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_L2D_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from the Level-2 Data cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 134,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "ITLB2_WRITES",
db39d7
+		.desc = "A translation entry has been written into the"
db39d7
+			" Translation Lookaside Buffer 2 (TLB2) and the"
db39d7
+			" request was made by the instruction cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 135,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "ITLB2_MISSES",
db39d7
+		.desc = "A TLB2 miss is in progress for a request made by"
db39d7
+			" the instruction cache. Incremented by one for every"
db39d7
+			" TLB2 miss in progress for the Level-1 Instruction"
db39d7
+			" cache in a cycle",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 136,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_L2I_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from the Level-2 Instruction cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 137,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_PTE_WRITES",
db39d7
+		.desc = "A translation entry was written into the Page Table"
db39d7
+			" Entry array in the Level-2 TLB",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 138,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_CRSTE_WRITES",
db39d7
+		.desc = "Translation entries were written into the Combined"
db39d7
+			" Region and Segment Table Entry array and the Page"
db39d7
+			" Table Entry array in the Level-2 TLB",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 139,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TLB2_ENGINES_BUSY",
db39d7
+		.desc = "The number of Level-2 TLB translation engines busy"
db39d7
+			" in a cycle",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 140,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TEND",
db39d7
+		.desc = "A TEND instruction has completed in a constrained"
db39d7
+			" transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 141,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_NC_TEND",
db39d7
+		.desc = "A TEND instruction has completed in a non-"
db39d7
+			" constrained transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 143,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1C_TLB2_MISSES",
db39d7
+		.desc = "Increments by one for any cycle where a level-1"
db39d7
+			" cache or level-2 TLB miss is in progress",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 144,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Chip Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 145,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Chip memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 146,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Chip Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 147,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCLUSTER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Cluster Level-3 cache withountervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 148,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCLUSTER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Cluster memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 149,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCLUSTER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Cluster Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 150,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFCLUSTER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Cluster Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 151,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFCLUSTER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Cluster memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 152,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFCLUSTER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Cluster Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 153,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 154,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 155,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 156,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 157,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_OFFDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 158,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1D_ONCHIP_L3_SOURCED_WRITES_RO",
db39d7
+		.desc = "A directory write to the Level-1 Data cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Chip L3 but a read-only invalidate was done"
db39d7
+			" to remove other copies of the cache line",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 162,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache ine was sourced"
db39d7
+			" from an On-Chip Level-3 cache without intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 163,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache ine was sourced"
db39d7
+			" from On-Chip memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 164,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCHIP_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache ine was sourced"
db39d7
+			" from an On-Chip Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 165,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCLUSTER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Cluster Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 166,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCLUSTER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an On-Cluster memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 167,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONCLUSTER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Cluster Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 168,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFCLUSTER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Cluster Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 169,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFCLUSTER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Cluster memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 170,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFCLUSTER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Cluster Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 171,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_L3_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Level-3 cache without"
db39d7
+			" intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 172,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_MEMORY_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Drawer memory",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 173,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_L3_SOURCED_WRITES_IV",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from an Off-Drawer Level-3 cache with intervention",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 174,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_ONDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from On-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 175,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "L1I_OFFDRAWER_L4_SOURCED_WRITES",
db39d7
+		.desc = "A directory write to the Level-1 Instruction cache"
db39d7
+			" directory where the returned cache line was sourced"
db39d7
+			" from Off-Drawer Level-4 cache",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 224,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "BCD_DFP_EXECUTION_SLOTS",
db39d7
+		.desc = "Count of floating point execution slots used for"
db39d7
+			" finished Binary Coded Decimal to Decimal Floating"
db39d7
+			" Point conversions. Instructions: CDZT, CXZT, CZDT,"
db39d7
+			" CZXT",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 225,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "VX_BCD_EXECUTION_SLOTS",
db39d7
+		.desc = "Count of floating point execution slots used for"
db39d7
+			" finished vector arithmetic Binary Coded Decimal"
db39d7
+			" instructions. Instructions: VAP, VSP, VMPVMSP, VDP,"
db39d7
+			" VSDP, VRP, VLIP, VSRP, VPSOPVCP, VTP, VPKZ, VUPKZ,"
db39d7
+			" VCVB, VCVBG, VCVDVCVDG",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 226,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "DECIMAL_INSTRUCTIONS",
db39d7
+		.desc = "Decimal instructions dispatched. Instructions: CVB,"
db39d7
+			" CVD, AP, CP, DP, ED, EDMK, MP, SRP, SP, ZAP",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 232,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "LAST_HOST_TRANSLATIONS",
db39d7
+		.desc = "Last Host Translation done",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 243,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_NC_TABORT",
db39d7
+		.desc = "A transaction abort has occurred in a non-"
db39d7
+			" constrained transactional-execution mode",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 244,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TABORT_NO_SPECIAL",
db39d7
+		.desc = "A transaction abort has occurred in a constrained"
db39d7
+			" transactional-execution mode and the CPU is not"
db39d7
+			" using any special logic to allow the transaction to"
db39d7
+			" complete",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 245,
db39d7
+		.ctrset = CPUMF_CTRSET_EXTENDED,
db39d7
+		.name = "TX_C_TABORT_SPECIAL",
db39d7
+		.desc = "A transaction abort has occurred in a constrained"
db39d7
+			" transactional-execution mode and the CPU is using"
db39d7
+			" special logic to allow the transaction to complete",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 448,
db39d7
+		.ctrset = CPUMF_CTRSET_MT_DIAG,
db39d7
+		.name = "MT_DIAG_CYCLES_ONE_THR_ACTIVE",
db39d7
+		.desc = "Cycle count with one thread active",
db39d7
+	},
db39d7
+	{
db39d7
+		.ctrnum = 449,
db39d7
+		.ctrset = CPUMF_CTRSET_MT_DIAG,
db39d7
+		.name = "MT_DIAG_CYCLES_TWO_THR_ACTIVE",
db39d7
+		.desc = "Cycle count with two threads active",
db39d7
+	},
db39d7
+};
db39d7
+
db39d7
 static const pme_cpumf_ctr_t cpumsf_counters[] = {
db39d7
 	{
db39d7
 		.ctrnum = 720896,
db39d7
diff --git a/lib/pfmlib_s390x_cpumf.c b/lib/pfmlib_s390x_cpumf.c
db39d7
index 7273962..62b1457 100644
db39d7
--- a/lib/pfmlib_s390x_cpumf.c
db39d7
+++ b/lib/pfmlib_s390x_cpumf.c
db39d7
@@ -37,6 +37,8 @@
db39d7
 #define CPUM_CF_DEVICE_DIR  "/sys/bus/event_source/devices/cpum_cf"
db39d7
 #define CPUM_SF_DEVICE_DIR  "/sys/bus/event_source/devices/cpum_sf"
db39d7
 #define SYS_INFO	    "/proc/sysinfo"
db39d7
+#define SERVICE_LEVEL	    "/proc/service_levels"
db39d7
+#define CF_VERSION_STR	    "CPU-MF: Counter facility: version="
db39d7
 
db39d7
 
db39d7
 /* CPU-measurement counter list (pmu events) */
db39d7
@@ -99,6 +101,37 @@ out:
db39d7
 	return machine_type;
db39d7
 }
db39d7
 
db39d7
+static void get_cf_version(unsigned int *cfvn, unsigned int *csvn)
db39d7
+{
db39d7
+	int rc;
db39d7
+	FILE *fp;
db39d7
+	char *buffer;
db39d7
+	size_t buflen;
db39d7
+
db39d7
+	*cfvn = *csvn = 0;
db39d7
+	fp = fopen(SERVICE_LEVEL, "r");
db39d7
+	if (fp == NULL)
db39d7
+		return;
db39d7
+
db39d7
+	buffer = NULL;
db39d7
+	while (pfmlib_getl(&buffer, &buflen, fp) != -1) {
db39d7
+		/* skip empty lines */
db39d7
+		if (*buffer == '\n')
db39d7
+			continue;
db39d7
+
db39d7
+		/* look for 'CPU-MF: Counter facility: version=' entry */
db39d7
+		if (!strncmp(CF_VERSION_STR, buffer, strlen(CF_VERSION_STR))) {
db39d7
+			rc = sscanf(buffer + strlen(CF_VERSION_STR), "%u.%u",
db39d7
+				    cfvn, csvn);
db39d7
+			if (rc != 2)
db39d7
+				*cfvn = *csvn = 0;
db39d7
+			break;
db39d7
+		}
db39d7
+	}
db39d7
+	fclose(fp);
db39d7
+	free(buffer);
db39d7
+}
db39d7
+
db39d7
 /* Initialize the PMU representation for CPUMF.
db39d7
  *
db39d7
  * Set up the PMU events array based on
db39d7
@@ -108,8 +141,33 @@ out:
db39d7
 static int pfm_cpumcf_init(void *this)
db39d7
 {
db39d7
 	pfmlib_pmu_t *pmu = this;
db39d7
-	const pme_cpumf_ctr_t *ext_set;
db39d7
-	size_t generic_count, ext_set_count;
db39d7
+	unsigned int cfvn, csvn;
db39d7
+	const pme_cpumf_ctr_t *cfvn_set, *csvn_set, *ext_set;
db39d7
+	size_t cfvn_set_count, csvn_set_count, ext_set_count, pme_count;
db39d7
+
db39d7
+	/* obtain counter first/second version number */
db39d7
+	get_cf_version(&cfvn, &csvn);
db39d7
+
db39d7
+	/* counters based on first version number */
db39d7
+	switch (cfvn)
db39d7
+	{
db39d7
+	case 1:
db39d7
+		cfvn_set = cpumcf_fvn1_counters;
db39d7
+		cfvn_set_count = LIBPFM_ARRAY_SIZE(cpumcf_fvn1_counters);
db39d7
+		break;
db39d7
+	case 3:
db39d7
+		cfvn_set = cpumcf_fvn3_counters;
db39d7
+		cfvn_set_count = LIBPFM_ARRAY_SIZE(cpumcf_fvn3_counters);
db39d7
+		break;
db39d7
+	default:
db39d7
+		cfvn_set = NULL;
db39d7
+		cfvn_set_count = 0;
db39d7
+		break;
db39d7
+	}
db39d7
+
db39d7
+	/* counters based on second version number */
db39d7
+	csvn_set = cpumcf_svn_generic_counters;
db39d7
+	csvn_set_count = LIBPFM_ARRAY_SIZE(cpumcf_svn_generic_counters);
db39d7
 
db39d7
 	/* check and assign a machine-specific extended counter set */
db39d7
 	switch (get_machine_type()) {
db39d7
@@ -133,6 +191,10 @@ static int pfm_cpumcf_init(void *this)
db39d7
 		ext_set = cpumcf_z13_counters;
db39d7
 		ext_set_count = LIBPFM_ARRAY_SIZE(cpumcf_z13_counters);
db39d7
 		break;
db39d7
+	case 3906:  /* IBM z14  */
db39d7
+		ext_set = cpumcf_z14_counters;
db39d7
+		ext_set_count = LIBPFM_ARRAY_SIZE(cpumcf_z14_counters);
db39d7
+		break;
db39d7
 	default:
db39d7
 		/* No extended counter set for this machine type or there
db39d7
 		 * was an error retrieving the machine type */
db39d7
@@ -141,20 +203,30 @@ static int pfm_cpumcf_init(void *this)
db39d7
 		break;
db39d7
 	}
db39d7
 
db39d7
-	generic_count = LIBPFM_ARRAY_SIZE(cpumcf_generic_counters);
db39d7
-
db39d7
-	cpumcf_pe = calloc(sizeof(*cpumcf_pe), generic_count + ext_set_count);
db39d7
+	cpumcf_pe = calloc(sizeof(*cpumcf_pe),
db39d7
+			   cfvn_set_count + csvn_set_count + ext_set_count);
db39d7
 	if (cpumcf_pe == NULL)
db39d7
 		return PFM_ERR_NOMEM;
db39d7
 
db39d7
-	memcpy(cpumcf_pe, cpumcf_generic_counters,
db39d7
-	       sizeof(*cpumcf_pe) * generic_count);
db39d7
+	pme_count = 0;
db39d7
+	memcpy(cpumcf_pe, cfvn_set, sizeof(*cpumcf_pe) * cfvn_set_count);
db39d7
+	pme_count += cfvn_set_count;
db39d7
+	memcpy((void *) (cpumcf_pe + pme_count), csvn_set,
db39d7
+	       sizeof(*cpumcf_pe) * csvn_set_count);
db39d7
+	pme_count += csvn_set_count;
db39d7
 	if (ext_set_count)
db39d7
-		memcpy((void *) (cpumcf_pe + generic_count),
db39d7
+		memcpy((void *) (cpumcf_pe + pme_count),
db39d7
 		       ext_set, sizeof(*cpumcf_pe) * ext_set_count);
db39d7
+	pme_count += ext_set_count;
db39d7
 
db39d7
 	pmu->pe = cpumcf_pe;
db39d7
-	pmu->pme_count = generic_count + ext_set_count;
db39d7
+	pmu->pme_count = pme_count;
db39d7
+
db39d7
+	/* CPUM-CF provides fixed counters only. The number of installed
db39d7
+	 * counters depends on the version and hardware model up to
db39d7
+	 * CPUMF_COUNTER_MAX.
db39d7
+	 */
db39d7
+	pmu->num_fixed_cntrs = pme_count;
db39d7
 
db39d7
 	return PFM_SUCCESS;
db39d7
 }
db39d7
@@ -276,8 +348,8 @@ pfmlib_pmu_t s390x_cpum_cf_support = {
db39d7
 	.num_fixed_cntrs = CPUMF_COUNTER_MAX,	/* fixed counters only */
db39d7
 	.max_encoding	 = 1,
db39d7
 
db39d7
-	.pe		 = cpumcf_generic_counters,
db39d7
-	.pme_count	 = LIBPFM_ARRAY_SIZE(cpumcf_generic_counters),
db39d7
+	.pe		 = NULL,
db39d7
+	.pme_count	 = 0,
db39d7
 
db39d7
 	.pmu_detect    = pfm_cpumcf_detect,
db39d7
 	.pmu_init      = pfm_cpumcf_init,
db39d7
diff --git a/lib/pfmlib_s390x_priv.h b/lib/pfmlib_s390x_priv.h
db39d7
index 22c775a..48a96c3 100644
db39d7
--- a/lib/pfmlib_s390x_priv.h
db39d7
+++ b/lib/pfmlib_s390x_priv.h
db39d7
@@ -1,7 +1,7 @@
db39d7
 #ifndef __PFMLIB_S390X_PRIV_H__
db39d7
 #define __PFMLIB_S390X_PRIV_H__
db39d7
 
db39d7
-#define CPUMF_COUNTER_MAX	    256
db39d7
+#define CPUMF_COUNTER_MAX	    0xffff
db39d7
 typedef struct {
db39d7
 	uint64_t ctrnum;	    /* counter number */
db39d7
 	unsigned int ctrset;	    /* counter set */
db39d7
commit 31ab4b33773750fbd13a1824e485805b70fc0bff
db39d7
Author: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
Date:   Fri Feb 9 09:42:07 2018 +0100
db39d7
db39d7
    s390/cpumf: check for counter facility availability
db39d7
    
db39d7
    If the counter facility is not available, counter information
db39d7
    are not being set up.  Introduce checks to protect against
db39d7
    access to counter information in that case.
db39d7
    
db39d7
    Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
db39d7
db39d7
diff --git a/lib/pfmlib_s390x_cpumf.c b/lib/pfmlib_s390x_cpumf.c
db39d7
index 62b1457..4e03fc4 100644
db39d7
--- a/lib/pfmlib_s390x_cpumf.c
db39d7
+++ b/lib/pfmlib_s390x_cpumf.c
db39d7
@@ -254,7 +254,9 @@ static int pfm_cpumf_get_encoding(void *this, pfmlib_event_desc_t *e)
db39d7
 
db39d7
 static int pfm_cpumf_get_event_first(void *this)
db39d7
 {
db39d7
-	return 0;
db39d7
+	pfmlib_pmu_t *pmu = this;
db39d7
+
db39d7
+	return !!pmu->pme_count ? 0 : -1;
db39d7
 }
db39d7
 
db39d7
 static int pfm_cpumf_get_event_next(void *this, int idx)
db39d7
@@ -317,6 +319,9 @@ static int pfm_cpumf_get_event_info(void *this, int idx,
db39d7
 	pfmlib_pmu_t *pmu = this;
db39d7
 	const pme_cpumf_ctr_t *pe = this_pe(this);
db39d7
 
db39d7
+	if (idx >= pmu->pme_count)
db39d7
+		return PFM_ERR_INVAL;
db39d7
+
db39d7
 	info->name = pe[idx].name;
db39d7
 	info->desc = pe[idx].desc;
db39d7
 	info->code = pe[idx].ctrnum;