Home | History | Annotate | Line # | Download | only in arch
      1  1.19   msaitoh /*	$NetBSD: tprof_x86.c,v 1.19 2023/07/07 04:43:15 msaitoh Exp $	*/
      2   1.1      maxv 
      3   1.1      maxv /*
      4   1.8      maxv  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
      5   1.1      maxv  * All rights reserved.
      6   1.1      maxv  *
      7   1.1      maxv  * This code is derived from software contributed to The NetBSD Foundation
      8   1.1      maxv  * by Maxime Villard.
      9   1.1      maxv  *
     10   1.1      maxv  * Redistribution and use in source and binary forms, with or without
     11   1.1      maxv  * modification, are permitted provided that the following conditions
     12   1.1      maxv  * are met:
     13   1.1      maxv  * 1. Redistributions of source code must retain the above copyright
     14   1.1      maxv  *    notice, this list of conditions and the following disclaimer.
     15   1.1      maxv  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1      maxv  *    notice, this list of conditions and the following disclaimer in the
     17   1.1      maxv  *    documentation and/or other materials provided with the distribution.
     18   1.1      maxv  *
     19   1.1      maxv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20   1.1      maxv  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21   1.1      maxv  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22   1.1      maxv  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23   1.1      maxv  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24   1.1      maxv  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25   1.1      maxv  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26   1.1      maxv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27   1.1      maxv  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28   1.1      maxv  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29   1.1      maxv  * POSSIBILITY OF SUCH DAMAGE.
     30   1.1      maxv  */
     31   1.1      maxv 
     32   1.1      maxv #include <sys/cdefs.h>
     33   1.1      maxv #include <stdio.h>
     34   1.1      maxv #include <stdlib.h>
     35   1.1      maxv #include <stdbool.h>
     36   1.1      maxv #include <string.h>
     37   1.1      maxv #include <unistd.h>
     38   1.1      maxv #include <err.h>
     39   1.1      maxv #include <machine/specialreg.h>
     40   1.1      maxv #include <dev/tprof/tprof_ioctl.h>
     41   1.1      maxv #include "../tprof.h"
     42   1.1      maxv 
     43   1.1      maxv int tprof_event_init(uint32_t);
     44   1.1      maxv void tprof_event_list(void);
     45   1.1      maxv void tprof_event_lookup(const char *, struct tprof_param *);
     46   1.1      maxv 
     47   1.1      maxv struct name_to_event {
     48   1.1      maxv 	const char *name;
     49   1.1      maxv 	uint64_t event;
     50   1.1      maxv 	uint64_t unit;
     51   1.1      maxv 	bool enabled;
     52   1.1      maxv };
     53   1.1      maxv 
     54   1.1      maxv struct event_table {
     55   1.1      maxv 	const char *tablename;
     56   1.1      maxv 	struct name_to_event *names;
     57   1.1      maxv 	size_t nevents;
     58   1.1      maxv 	struct event_table *next;
     59   1.1      maxv };
     60   1.1      maxv 
     61   1.1      maxv static struct event_table *cpuevents = NULL;
     62   1.1      maxv 
     63  1.17   msaitoh static void
     64  1.17   msaitoh x86_cpuid(unsigned int *eax, unsigned int *ebx,
     65   1.1      maxv     unsigned int *ecx, unsigned int *edx)
     66   1.1      maxv {
     67   1.1      maxv 	asm volatile("cpuid"
     68   1.1      maxv 	    : "=a" (*eax),
     69   1.1      maxv 	      "=b" (*ebx),
     70   1.1      maxv 	      "=c" (*ecx),
     71   1.1      maxv 	      "=d" (*edx)
     72   1.1      maxv 	    : "0" (*eax), "2" (*ecx));
     73   1.1      maxv }
     74   1.1      maxv 
     75  1.13   msaitoh /* ------------------------------------------------------------------------- */
     76   1.1      maxv 
     77   1.1      maxv /*
     78   1.1      maxv  * Intel Architectural Version 1.
     79   1.1      maxv  */
     80   1.1      maxv static struct name_to_event intel_arch1_names[] = {
     81   1.1      maxv 	/* Event Name - Event Select - UMask */
     82  1.14   msaitoh 	{ "unhalted-core-cycles",	0x3c, 0x00, true },
     83  1.14   msaitoh 	{ "instruction-retired",	0xc0, 0x00, true },
     84  1.14   msaitoh 	{ "unhalted-reference-cycles",	0x3c, 0x01, true },
     85  1.14   msaitoh 	{ "llc-reference",		0x2e, 0x4f, true },
     86  1.14   msaitoh 	{ "llc-misses",			0x2e, 0x41, true },
     87  1.14   msaitoh 	{ "branch-instruction-retired",	0xc4, 0x00, true },
     88  1.14   msaitoh 	{ "branch-misses-retired",	0xc5, 0x00, true },
     89  1.14   msaitoh 	{ "topdown-slots",		0xa4, 0x01, true },
     90   1.1      maxv };
     91   1.1      maxv 
     92   1.1      maxv static struct event_table intel_arch1 = {
     93   1.1      maxv 	.tablename = "Intel Architectural Version 1",
     94   1.1      maxv 	.names = intel_arch1_names,
     95   1.1      maxv 	.nevents = sizeof(intel_arch1_names) /
     96   1.1      maxv 	    sizeof(struct name_to_event),
     97   1.1      maxv 	.next = NULL
     98   1.1      maxv };
     99   1.1      maxv 
    100   1.1      maxv static struct event_table *
    101   1.1      maxv init_intel_arch1(void)
    102   1.1      maxv {
    103  1.12   msaitoh 	unsigned int eax, ebx, ecx, edx, vectorlen;
    104   1.1      maxv 	struct event_table *table;
    105   1.1      maxv 	size_t i;
    106   1.1      maxv 
    107  1.14   msaitoh 	eax = 0x0a;
    108   1.1      maxv 	ebx = 0;
    109   1.1      maxv 	ecx = 0;
    110   1.1      maxv 	edx = 0;
    111   1.1      maxv 	x86_cpuid(&eax, &ebx, &ecx, &edx);
    112   1.1      maxv 
    113  1.12   msaitoh 	vectorlen = __SHIFTOUT(eax, CPUID_PERF_BVECLEN);
    114  1.12   msaitoh 
    115   1.1      maxv 	table = &intel_arch1;
    116   1.1      maxv 	for (i = 0; i < table->nevents; i++) {
    117  1.12   msaitoh 		/*
    118  1.12   msaitoh 		 * Disable the unsupported events from:
    119  1.12   msaitoh 		 * a) the bit vector length in EAX.
    120  1.12   msaitoh 		 * b) the disable bit in EBX.
    121  1.12   msaitoh 		 */
    122  1.12   msaitoh 		if (i >= vectorlen)
    123  1.12   msaitoh 			table->names[i].enabled = false;
    124   1.1      maxv 		if ((ebx & (i << 1)) != 0)
    125   1.1      maxv 			table->names[i].enabled = false;
    126   1.1      maxv 	}
    127   1.1      maxv 
    128   1.1      maxv 	return table;
    129   1.1      maxv }
    130   1.1      maxv 
    131   1.1      maxv /*
    132   1.5  knakahar  * Intel Silvermont/Airmont.
    133   1.5  knakahar  */
    134   1.5  knakahar static struct name_to_event intel_silvermont_airmont_names[] = {
    135   1.5  knakahar 	{ "REHABQ.LD_BLOCK_ST_FORWARD",		0x03, 0x01, true },
    136   1.5  knakahar 	{ "REHABQ.LD_BLOCK_STD_NOTREADY",	0x03, 0x02, true },
    137   1.5  knakahar 	{ "REHABQ.ST_SPLITS",			0x03, 0x04, true },
    138   1.5  knakahar 	{ "REHABQ.LD_SPLITS",			0x03, 0x08, true },
    139   1.5  knakahar 	{ "REHABQ.LOCK",			0x03, 0x10, true },
    140   1.5  knakahar 	{ "REHABQ.STA_FULL",			0x03, 0x20, true },
    141   1.5  knakahar 	{ "REHABQ.ANY_LD",			0x03, 0x40, true },
    142   1.5  knakahar 	{ "REHABQ.ANY_ST",			0x03, 0x80, true },
    143   1.5  knakahar 	{ "MEM_UOPS_RETIRED.L1_MISS_LOADS",	0x04, 0x01, true },
    144   1.5  knakahar 	{ "MEM_UOPS_RETIRED.L2_HIT_LOADS",	0x04, 0x02, true },
    145   1.5  knakahar 	{ "MEM_UOPS_RETIRED.L2_MISS_LOADS",	0x04, 0x04, true },
    146   1.5  knakahar 	{ "MEM_UOPS_RETIRED.DTLB_MISS_LOADS",	0x04, 0x08, true },
    147   1.5  knakahar 	{ "MEM_UOPS_RETIRED.UTLB_MISS",		0x04, 0x10, true },
    148   1.5  knakahar 	{ "MEM_UOPS_RETIRED.HITM",		0x04, 0x20, true },
    149   1.5  knakahar 	{ "MEM_UOPS_RETIRED.ALL_LOADS",		0x04, 0x40, true },
    150   1.5  knakahar 	{ "MEM_UOP_RETIRED.ALL_STORES",		0x04, 0x80, true },
    151   1.5  knakahar 	{ "PAGE_WALKS.D_SIDE_CYCLES",		0x05, 0x01, true },
    152   1.5  knakahar 	{ "PAGE_WALKS.I_SIDE_CYCLES",		0x05, 0x02, true },
    153   1.5  knakahar 	{ "PAGE_WALKS.WALKS",			0x05, 0x03, true },
    154  1.14   msaitoh 	{ "LONGEST_LAT_CACHE.MISS",		0x2e, 0x41, true },
    155  1.14   msaitoh 	{ "LONGEST_LAT_CACHE.REFERENCE",	0x2e, 0x4f, true },
    156   1.5  knakahar 	{ "L2_REJECT_XQ.ALL",			0x30, 0x00, true },
    157   1.5  knakahar 	{ "CORE_REJECT_L2Q.ALL",		0x31, 0x00, true },
    158  1.14   msaitoh 	{ "CPU_CLK_UNHALTED.CORE_P",		0x3c, 0x00, true },
    159  1.14   msaitoh 	{ "CPU_CLK_UNHALTED.REF_P",		0x3c, 0x01, true },
    160   1.5  knakahar 	{ "ICACHE.HIT",				0x80, 0x01, true },
    161   1.5  knakahar 	{ "ICACHE.MISSES",			0x80, 0x02, true },
    162   1.5  knakahar 	{ "ICACHE.ACCESSES",			0x80, 0x03, true },
    163  1.14   msaitoh 	{ "OFFCORE_RESPONSE_0",			0xb7, 0x01, true },
    164  1.14   msaitoh 	{ "OFFCORE_RESPONSE_1",			0xb7, 0x02, true },
    165  1.14   msaitoh 	{ "INST_RETIRED.ANY_P",			0xc0, 0x00, true },
    166  1.14   msaitoh 	{ "UOPS_RETIRED.MS",			0xc2, 0x01, true },
    167  1.14   msaitoh 	{ "UOPS_RETIRED.ALL",			0xc2, 0x10, true },
    168  1.14   msaitoh 	{ "MACHINE_CLEARS.SMC",			0xc3, 0x01, true },
    169  1.14   msaitoh 	{ "MACHINE_CLEARS.MEMORY_ORDERING",	0xc3, 0x02, true },
    170  1.14   msaitoh 	{ "MACHINE_CLEARS.FP_ASSIST",		0xc3, 0x04, true },
    171  1.14   msaitoh 	{ "MACHINE_CLEARS.ALL",			0xc3, 0x08, true },
    172  1.14   msaitoh 	{ "BR_INST_RETIRED.ALL_BRANCHES",	0xc4, 0x00, true },
    173  1.14   msaitoh 	{ "BR_INST_RETIRED.JCC",		0xc4, 0x7e, true },
    174  1.14   msaitoh 	{ "BR_INST_RETIRED.FAR_BRANCH",		0xc4, 0xbf, true },
    175  1.14   msaitoh 	{ "BR_INST_RETIRED.NON_RETURN_IND",	0xc4, 0xeb, true },
    176  1.14   msaitoh 	{ "BR_INST_RETIRED.RETURN",		0xc4, 0xf7, true },
    177  1.14   msaitoh 	{ "BR_INST_RETIRED.CALL",		0xc4, 0xf9, true },
    178  1.14   msaitoh 	{ "BR_INST_RETIRED.IND_CALL",		0xc4, 0xfb, true },
    179  1.14   msaitoh 	{ "BR_INST_RETIRED.REL_CALL",		0xc4, 0xfd, true },
    180  1.14   msaitoh 	{ "BR_INST_RETIRED.TAKEN_JCC",		0xc4, 0xfe, true },
    181  1.14   msaitoh 	{ "BR_MISP_RETIRED.ALL_BRANCHES",	0xc5, 0x00, true },
    182  1.14   msaitoh 	{ "BR_MISP_RETIRED.JCC",		0xc5, 0x7e, true },
    183  1.14   msaitoh 	{ "BR_MISP_RETIRED.FAR",		0xc5, 0xbf, true },
    184  1.14   msaitoh 	{ "BR_MISP_RETIRED.NON_RETURN_IND",	0xc5, 0xeb, true },
    185  1.14   msaitoh 	{ "BR_MISP_RETIRED.RETURN",		0xc5, 0xf7, true },
    186  1.14   msaitoh 	{ "BR_MISP_RETIRED.CALL",		0xc5, 0xf9, true },
    187  1.14   msaitoh 	{ "BR_MISP_RETIRED.IND_CALL",		0xc5, 0xfb, true },
    188  1.14   msaitoh 	{ "BR_MISP_RETIRED.REL_CALL",		0xc5, 0xfd, true },
    189  1.14   msaitoh 	{ "BR_MISP_RETIRED.TAKEN_JCC",		0xc5, 0xfe, true },
    190  1.14   msaitoh 	{ "NO_ALLOC_CYCLES.ROB_FULL",		0xca, 0x01, true },
    191  1.14   msaitoh 	{ "NO_ALLOC_CYCLES.RAT_STALL",		0xca, 0x20, true },
    192  1.14   msaitoh 	{ "NO_ALLOC_CYCLES.ALL",		0xca, 0x3f, true },
    193  1.14   msaitoh 	{ "NO_ALLOC_CYCLES.NOT_DELIVERED",	0xca, 0x50, true },
    194  1.14   msaitoh 	{ "RS_FULL_STALL.MEC",			0xcb, 0x01, true },
    195  1.14   msaitoh 	{ "RS_FULL_STALL.ALL",			0xcb, 0x1f, true },
    196  1.14   msaitoh 	{ "CYCLES_DIV_BUSY.ANY",		0xcd, 0x01, true },
    197  1.14   msaitoh 	{ "BACLEARS.ALL",			0xe6, 0x01, true },
    198  1.14   msaitoh 	{ "BACLEARS.RETURN",			0xe6, 0x08, true },
    199  1.14   msaitoh 	{ "BACLEARS.COND",			0xe6, 0x10, true },
    200  1.14   msaitoh 	{ "MS_DECODED.MS_ENTRY",		0xe7, 0x01, true },
    201   1.5  knakahar };
    202   1.5  knakahar 
    203   1.5  knakahar static struct event_table intel_silvermont_airmont = {
    204   1.5  knakahar 	.tablename = "Intel Silvermont/Airmont",
    205   1.5  knakahar 	.names = intel_silvermont_airmont_names,
    206   1.5  knakahar 	.nevents = sizeof(intel_silvermont_airmont_names) /
    207   1.5  knakahar 	    sizeof(struct name_to_event),
    208   1.5  knakahar 	.next = NULL
    209   1.5  knakahar };
    210   1.5  knakahar 
    211   1.5  knakahar static struct event_table *
    212   1.5  knakahar init_intel_silvermont_airmont(void)
    213   1.5  knakahar {
    214   1.5  knakahar 
    215   1.5  knakahar 	return &intel_silvermont_airmont;
    216   1.5  knakahar }
    217   1.5  knakahar 
    218   1.5  knakahar /*
    219   1.6  knakahar  * Intel Goldmont
    220   1.6  knakahar  */
    221   1.6  knakahar static struct name_to_event intel_goldmont_names[] = {
    222   1.6  knakahar 	{ "LD_BLOCKS.ALL_BLOCK",			0x03,	0x10, true },
    223   1.6  knakahar 	{ "LD_BLOCKS.UTLB_MISS",			0x03,	0x08, true },
    224   1.6  knakahar 	{ "LD_BLOCKS.STORE_FORWARD",			0x03,	0x02, true },
    225   1.6  knakahar 	{ "LD_BLOCKS.DATA_UNKNOWN",			0x03,	0x01, true },
    226   1.6  knakahar 	{ "LD_BLOCKS.4K_ALIAS",				0x03,	0x04, true },
    227   1.6  knakahar 	{ "PAGE_WALKS.D_SIDE_CYCLES",			0x05,	0x01, true },
    228   1.6  knakahar 	{ "PAGE_WALKS.I_SIDE_CYCLES",			0x05,	0x02, true },
    229   1.6  knakahar 	{ "PAGE_WALKS.CYCLES",				0x05,	0x03, true },
    230  1.14   msaitoh 	{ "UOPS_ISSUED.ANY",				0x0e,	0x00, true },
    231   1.6  knakahar 	{ "MISALIGN_MEM_REF.LOAD_PAGE_SPLIT",		0x13,	0x02, true },
    232   1.6  knakahar 	{ "MISALIGN_MEM_REF.STORE_PAGE_SPLIT",		0x13,	0x04, true },
    233  1.14   msaitoh 	{ "LONGEST_LAT_CACHE.REFERENCE",		0x2e,	0x4f, true },
    234  1.14   msaitoh 	{ "LONGEST_LAT_CACHE.MISS",			0x2e,	0x41, true },
    235   1.6  knakahar 	{ "L2_REJECT_XQ.ALL",				0x30,	0x00, true },
    236   1.6  knakahar 	{ "CORE_REJECT_L2Q.ALL",			0x31,	0x00, true },
    237  1.14   msaitoh 	{ "CPU_CLK_UNHALTED.CORE_P",			0x3c,	0x00, true },
    238  1.14   msaitoh 	{ "CPU_CLK_UNHALTED.REF",			0x3c,	0x01, true },
    239   1.6  knakahar 	{ "DL1.DIRTY_EVICTION",				0x51,	0x01, true },
    240   1.6  knakahar 	{ "ICACHE.HIT",					0x80,	0x01, true },
    241   1.6  knakahar 	{ "ICACHE.MISSES",				0x80,	0x02, true },
    242   1.6  knakahar 	{ "ICACHE.ACCESSES",				0x80,	0x03, true },
    243   1.6  knakahar 	{ "ITLB.MISS",					0x81,	0x04, true },
    244   1.6  knakahar 	{ "FETCH_STALL.ALL",				0x86,	0x00, true },
    245   1.6  knakahar 	{ "FETCH_STALL.ITLB_FILL_PENDING_CYCLES",	0x86,	0x01, true },
    246   1.6  knakahar 	{ "FETCH_STALL.ICACHE_FILL_PENDING_CYCLES",	0x86,	0x02, true },
    247  1.14   msaitoh 	{ "UOPS_NOT_DELIVERED.ANY",			0x9c,	0x00, true },
    248  1.14   msaitoh 	{ "OFFCORE_RESPONSE.0",				0xb7,	0x01, true },
    249  1.14   msaitoh 	{ "OFFCORE_RESPONSE.1",				0xb7,	0x02, true },
    250  1.14   msaitoh 	{ "INST_RETIRED.ANY_P",				0xc0,	0x00, true },
    251  1.14   msaitoh 	{ "UOPS_RETIRED.ANY",				0xc2,	0x00, true },
    252  1.14   msaitoh 	{ "UOPS_RETIRED.MS",				0xc2,	0x01, true },
    253  1.14   msaitoh 	{ "UOPS_RETIRED.FPDIV",				0xc2,	0x08, true },
    254  1.14   msaitoh 	{ "UOPS_RETIRED.IDIV",				0xc2,	0x10, true },
    255  1.14   msaitoh 	{ "MACHINE_CLEARS.SMC",				0xc3,	0x01, true },
    256  1.14   msaitoh 	{ "MACHINE_CLEARS.MEMORY_ORDERING",		0xc3,	0x02, true },
    257  1.14   msaitoh 	{ "MACHINE_CLEARS.FP_ASSIST",			0xc3,	0x04, true },
    258  1.14   msaitoh 	{ "MACHINE_CLEARS.DISAMBIGUATION",		0xc3,	0x08, true },
    259  1.14   msaitoh 	{ "MACHINE_CLEARS.ALL",				0xc3,	0x00, true },
    260  1.14   msaitoh 	{ "BR_INST_RETIRED.ALL_BRANCHES",		0xc4,	0x00, true },
    261  1.14   msaitoh 	{ "BR_INST_RETIRED.JCC",			0xc4,	0x7e, true },
    262  1.14   msaitoh 	{ "BR_INST_RETIRED.ALL_TAKEN_BRANCHES",		0xc4,	0x80, true },
    263  1.14   msaitoh 	{ "BR_INST_RETIRED.TAKEN_JCC",			0xc4,	0xfe, true },
    264  1.14   msaitoh 	{ "BR_INST_RETIRED.CALL",			0xc4,	0xf9, true },
    265  1.14   msaitoh 	{ "BR_INST_RETIRED.REL_CALL",			0xc4,	0xfd, true },
    266  1.14   msaitoh 	{ "BR_INST_RETIRED.IND_CALL",			0xc4,	0xfb, true },
    267  1.14   msaitoh 	{ "BR_INST_RETIRED.RETURN",			0xc4,	0xf7, true },
    268  1.14   msaitoh 	{ "BR_INST_RETIRED.NON_RETURN_IND",		0xc4,	0xeb, true },
    269  1.14   msaitoh 	{ "BR_INST_RETIRED.FAR_BRANCH",			0xc4,	0xbf, true },
    270  1.14   msaitoh 	{ "BR_MISP_RETIRED.ALL_BRANCHES",		0xc5,	0x00, true },
    271  1.14   msaitoh 	{ "BR_MISP_RETIRED.JCC",			0xc5,	0x7e, true },
    272  1.14   msaitoh 	{ "BR_MISP_RETIRED.TAKEN_JCC",			0xc5,	0xfe, true },
    273  1.14   msaitoh 	{ "BR_MISP_RETIRED.IND_CALL",			0xc5,	0xfb, true },
    274  1.14   msaitoh 	{ "BR_MISP_RETIRED.RETURN",			0xc5,	0xf7, true },
    275  1.14   msaitoh 	{ "BR_MISP_RETIRED.NON_RETURN_IND",		0xc5,	0xeb, true },
    276  1.14   msaitoh 	{ "ISSUE_SLOTS_NOT_CONSUMED.RESOURCE_FULL",	0xca,	0x01, true },
    277  1.14   msaitoh 	{ "ISSUE_SLOTS_NOT_CONSUMED.RECOVERY",		0xca,	0x02, true },
    278  1.14   msaitoh 	{ "ISSUE_SLOTS_NOT_CONSUMED.ANY",		0xca,	0x00, true },
    279  1.14   msaitoh 	{ "HW_INTERRUPTS.RECEIVED",			0xcb,	0x01, true },
    280  1.14   msaitoh 	{ "HW_INTERRUPTS.MASKED",			0xcb,	0x02, true },
    281  1.14   msaitoh 	{ "HW_INTERRUPTS.PENDING_AND_MASKED",		0xcb,	0x04, true },
    282  1.14   msaitoh 	{ "CYCLES_DIV_BUSY.ALL",			0xcd,	0x00, true },
    283  1.14   msaitoh 	{ "CYCLES_DIV_BUSY.IDIV",			0xcd,	0x01, true },
    284  1.14   msaitoh 	{ "CYCLES_DIV_BUSY.FPDIV",			0xcd,	0x02, true },
    285  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.ALL_LOADS",			0xd0,	0x81, true },
    286  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.ALL_STORES",		0xd0,	0x82, true },
    287  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.ALL",			0xd0,	0x83, true },
    288  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.DTLB_MISS_LOADS",		0xd0,	0x11, true },
    289  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.DTLB_MISS_STORES",		0xd0,	0x12, true },
    290  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.DTLB_MISS",			0xd0,	0x13, true },
    291  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.LOCK_LOADS",		0xd0,	0x21, true },
    292  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.SPLIT_LOADS",		0xd0,	0x41, true },
    293  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.SPLIT_STORES",		0xd0,	0x42, true },
    294  1.14   msaitoh 	{ "MEM_UOPS_RETIRED.SPLIT",			0xd0,	0x43, true },
    295  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.L1_HIT",		0xd1,	0x01, true },
    296  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.L1_MISS",		0xd1,	0x08, true },
    297  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.L2_HIT",		0xd1,	0x02, true },
    298  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.L2_MISS",		0xd1,	0x10, true },
    299  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.HITM",			0xd1,	0x20, true },
    300  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.WCB_HIT",		0xd1,	0x40, true },
    301  1.14   msaitoh 	{ "MEM_LOAD_UOPS_RETIRED.DRAM_HIT",		0xd1,	0x80, true },
    302  1.14   msaitoh 	{ "BACLEARS.ALL",				0xe6,	0x01, true },
    303  1.14   msaitoh 	{ "BACLEARS.RETURN",				0xe6,	0x08, true },
    304  1.14   msaitoh 	{ "BACLEAR.CONDS",				0xe6,	0x10, true },
    305  1.14   msaitoh 	{ "MS_DECODED.MS_ENTRY",			0xe7,	0x01, true },
    306  1.14   msaitoh 	{ "DECODED_RESTRICTION.PREDECODE_WRONG",	0xe9,	0x01, true },
    307   1.6  knakahar };
    308   1.6  knakahar 
    309   1.6  knakahar static struct event_table intel_goldmont = {
    310   1.6  knakahar 	.tablename = "Intel Goldmont",
    311   1.6  knakahar 	.names = intel_goldmont_names,
    312   1.6  knakahar 	.nevents = sizeof(intel_goldmont_names) /
    313   1.6  knakahar 	    sizeof(struct name_to_event),
    314   1.6  knakahar 	.next = NULL
    315   1.6  knakahar };
    316   1.6  knakahar 
    317   1.6  knakahar static struct event_table *
    318   1.6  knakahar init_intel_goldmont(void)
    319   1.6  knakahar {
    320   1.6  knakahar 
    321   1.6  knakahar 	return &intel_goldmont;
    322   1.6  knakahar }
    323   1.6  knakahar 
    324   1.6  knakahar /*
    325   1.7  knakahar  * Intel Goldmont Plus (Additions from Goldmont)
    326   1.7  knakahar  */
    327   1.7  knakahar static struct name_to_event intel_goldmontplus_names[] = {
    328   1.7  knakahar 	{ "INST_RETIRED.ANY",				0x00,	0x01, true },
    329   1.7  knakahar 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_4K",		0x08,	0x02, true },
    330   1.7  knakahar 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M",	0x08,	0x04, true },
    331   1.7  knakahar 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_1GB",	0x08,	0x08, true },
    332   1.7  knakahar 	{ "DTLB_LOAD_MISSES.WALK_PENDING",		0x08,	0x10, true },
    333   1.7  knakahar 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_4K",	0x49,	0x02, true },
    334   1.7  knakahar 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M",	0x49,	0x04, true },
    335   1.7  knakahar 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_1GB",	0x49,	0x08, true },
    336   1.7  knakahar 	{ "DTLB_STORE_MISSES.WALK_PENDING",		0x49,	0x10, true },
    337  1.14   msaitoh 	{ "EPT.WALK_PENDING",				0x4f,	0x10, true },
    338   1.7  knakahar 	{ "ITLB_MISSES.WALK_COMPLETED_4K",		0x85,	0x08, true },
    339   1.7  knakahar 	{ "ITLB_MISSES.WALK_COMPLETED_2M_4M",		0x85,	0x04, true },
    340   1.7  knakahar 	{ "ITLB_MISSES.WALK_COMPLETED_1GB",		0x85,	0x08, true },
    341   1.7  knakahar 	{ "ITLB_MISSES.WALK_PENDING",			0x85,	0x10, true },
    342  1.14   msaitoh 	{ "TLB_FLUSHES.STLB_ANY",			0xbd,	0x20, true },
    343  1.14   msaitoh 	{ "MACHINE_CLEARS.PAGE_FAULT",			0xc3,	0x20, true },
    344   1.7  knakahar };
    345   1.7  knakahar 
    346   1.7  knakahar static struct event_table intel_goldmontplus = {
    347   1.7  knakahar 	.tablename = "Intel Goldmont Plus",
    348   1.7  knakahar 	.names = intel_goldmontplus_names,
    349   1.7  knakahar 	.nevents = sizeof(intel_goldmontplus_names) /
    350   1.7  knakahar 	    sizeof(struct name_to_event),
    351   1.7  knakahar 	.next = NULL
    352   1.7  knakahar };
    353   1.7  knakahar 
    354   1.7  knakahar static struct event_table *
    355   1.7  knakahar init_intel_goldmontplus(void)
    356   1.7  knakahar {
    357   1.7  knakahar 
    358   1.7  knakahar 	intel_goldmont.next = &intel_goldmontplus;
    359   1.7  knakahar 
    360   1.7  knakahar 	return &intel_goldmont;
    361   1.7  knakahar }
    362   1.7  knakahar 
    363   1.7  knakahar /*
    364   1.4      maxv  * Intel Skylake/Kabylake.
    365   1.4      maxv  *
    366   1.4      maxv  * The events that are not listed, because they are of little interest or
    367   1.4      maxv  * require extra configuration:
    368   1.4      maxv  *     TX_*
    369   1.4      maxv  *     FRONTEND_RETIRED.*
    370   1.4      maxv  *     FP_ARITH_INST_RETIRED.*
    371   1.4      maxv  *     HLE_RETIRED.*
    372   1.4      maxv  *     RTM_RETIRED.*
    373   1.4      maxv  *     MEM_TRANS_RETIRED.*
    374   1.4      maxv  *     UOPS_DISPATCHED_PORT.*
    375   1.1      maxv  */
    376   1.1      maxv static struct name_to_event intel_skylake_kabylake_names[] = {
    377   1.1      maxv 	/* Event Name - Event Select - UMask */
    378  1.13   msaitoh 	{ "LD_BLOCKS.STORE_FORWARD",			0x03, 0x02, true },
    379  1.13   msaitoh 	{ "LD_BLOCKS.NO_SR",				0x03, 0x08, true },
    380  1.13   msaitoh 	{ "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS",		0x07, 0x01, true },
    381  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK",	0x08, 0x01, true },
    382  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_4K",		0x08, 0x02, true },
    383  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M",	0x08, 0x04, true },
    384  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_1G",		0x08, 0x08, true },
    385  1.14   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED",		0x08, 0x0e, true },
    386  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_PENDING",		0x08, 0x10, true },
    387  1.13   msaitoh 	{ "DTLB_LOAD_MISSES.STLB_HIT",			0x08, 0x20, true },
    388  1.14   msaitoh 	{ "INT_MISC.RECOVERY_CYCLES",			0x0d, 0x01, true },
    389  1.14   msaitoh 	{ "INT_MISC.CLEAR_RESTEER_CYCLES",		0x0d, 0x80, true },
    390  1.14   msaitoh 	{ "UOPS_ISSUED.ANY",				0x0e, 0x01, true },
    391  1.14   msaitoh 	{ "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH",		0x0e, 0x02, true },
    392  1.14   msaitoh 	{ "UOPS_ISSUED.SLOW_LEA",			0x0e, 0x20, true },
    393  1.13   msaitoh 	{ "L2_RQSTS.DEMAND_DATA_RD_MISS",		0x24, 0x21, true },
    394  1.13   msaitoh 	{ "L2_RQSTS.RFO_MISS",				0x24, 0x22, true },
    395  1.13   msaitoh 	{ "L2_RQSTS.CODE_RD_MISS",			0x24, 0x24, true },
    396  1.13   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_MISS",			0x24, 0x27, true },
    397  1.13   msaitoh 	{ "L2_RQSTS.PF_MISS",				0x24, 0x38, true },
    398  1.14   msaitoh 	{ "L2_RQSTS.MISS",				0x24, 0x3f, true },
    399  1.13   msaitoh 	{ "L2_RQSTS.DEMAND_DATA_RD_HIT",		0x24, 0x41, true },
    400  1.13   msaitoh 	{ "L2_RQSTS.RFO_HIT",				0x24, 0x42, true },
    401  1.13   msaitoh 	{ "L2_RQSTS.CODE_RD_HIT",			0x24, 0x44, true },
    402  1.14   msaitoh 	{ "L2_RQSTS.PF_HIT",				0x24, 0xd8, true },
    403  1.14   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_DATA_RD",		0x24, 0xe1, true },
    404  1.14   msaitoh 	{ "L2_RQSTS.ALL_RFO",				0x24, 0xe2, true },
    405  1.14   msaitoh 	{ "L2_RQSTS.ALL_CODE_RD",			0x24, 0xe4, true },
    406  1.14   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_REFERENCES",		0x24, 0xe7, true },
    407  1.14   msaitoh 	{ "L2_RQSTS.ALL_PF",				0x24, 0xf8, true },
    408  1.14   msaitoh 	{ "L2_RQSTS.REFERENCES",			0x24, 0xff, true },
    409  1.13   msaitoh 	{ "SW_PREFETCH_ACCESS.NTA",			0x32, 0x01, true },
    410  1.13   msaitoh 	{ "SW_PREFETCH_ACCESS.T0",			0x32, 0x02, true },
    411  1.13   msaitoh 	{ "SW_PREFETCH_ACCESS.T1_T2",			0x32, 0x04, true },
    412  1.13   msaitoh 	{ "SW_PREFETCH_ACCESS.PREFETCHW",		0x32, 0x08, true },
    413  1.14   msaitoh 	{ "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE",	0x3c, 0x02, true },
    414  1.14   msaitoh 	{ "CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE",		0x3c, 0x02, true },
    415  1.13   msaitoh 	{ "L1D_PEND_MISS.PENDING",			0x48, 0x01, true },
    416  1.13   msaitoh 	{ "L1D_PEND_MISS.FB_FULL",			0x48, 0x02, true },
    417  1.13   msaitoh 	{ "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK",	0x49, 0x01, true },
    418  1.13   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_4K",	0x49, 0x02, true },
    419  1.13   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M",	0x49, 0x04, true },
    420  1.13   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_1G",	0x49, 0x08, true },
    421  1.14   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED",		0x49, 0x0e, true },
    422  1.13   msaitoh 	{ "DTLB_STORE_MISSES.WALK_PENDING",		0x49, 0x10, true },
    423  1.13   msaitoh 	{ "DTLB_STORE_MISSES.STLB_HIT",			0x49, 0x20, true },
    424  1.14   msaitoh 	{ "LOAD_HIT_PRE.SW_PF",				0x4c, 0x01, true },
    425  1.14   msaitoh 	{ "EPT.WALK_PENDING",				0x4f, 0x10, true },
    426  1.13   msaitoh 	{ "L1D.REPLACEMENT",				0x51, 0x01, true },
    427  1.14   msaitoh 	{ "RS_EVENTS.EMPTY_CYCLES",			0x5e, 0x01, true },
    428  1.13   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD", 0x60, 0x01, true },
    429  1.13   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD", 0x60, 0x02, true },
    430  1.13   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO",	0x60, 0x04, true },
    431  1.13   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD",	0x60, 0x08, true },
    432  1.13   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",
    433  1.17   msaitoh 							0x60, 0x10, true },
    434  1.13   msaitoh 	{ "IDQ.MITE_UOPS",				0x79, 0x04, true },
    435  1.13   msaitoh 	{ "IDQ.DSB_UOPS",				0x79, 0x08, true },
    436  1.13   msaitoh 	{ "IDQ.MS_MITE_UOPS",				0x79, 0x20, true },
    437  1.13   msaitoh 	{ "IDQ.MS_UOPS",				0x79, 0x30, true },
    438  1.13   msaitoh 	{ "ICACHE_16B.IFDATA_STALL",			0x80, 0x04, true },
    439  1.13   msaitoh 	{ "ICACHE_64B.IFTAG_HIT",			0x83, 0x01, true },
    440  1.13   msaitoh 	{ "ICACHE_64B.IFTAG_MISS",			0x83, 0x02, true },
    441  1.13   msaitoh 	{ "ICACHE_64B.IFTAG_STALL",			0x83, 0x04, true },
    442  1.13   msaitoh 	{ "ITLB_MISSES.MISS_CAUSES_A_WALK",		0x85, 0x01, true },
    443  1.13   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_4K",		0x85, 0x02, true },
    444  1.13   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_2M_4M",		0x85, 0x04, true },
    445  1.13   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_1G",		0x85, 0x08, true },
    446  1.14   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED",			0x85, 0x0e, true },
    447  1.13   msaitoh 	{ "ITLB_MISSES.WALK_PENDING",			0x85, 0x10, true },
    448  1.13   msaitoh 	{ "ITLB_MISSES.STLB_HIT",			0x85, 0x20, true },
    449  1.13   msaitoh 	{ "ILD_STALL.LCP",				0x87, 0x01, true },
    450  1.14   msaitoh 	{ "IDQ_UOPS_NOT_DELIVERED.CORE",		0x9c, 0x01, true },
    451  1.14   msaitoh 	{ "RESOURCE_STALLS.ANY",			0xa2, 0x01, true },
    452  1.14   msaitoh 	{ "RESOURCE_STALLS.SB",				0xa2, 0x08, true },
    453  1.14   msaitoh 	{ "EXE_ACTIVITY.EXE_BOUND_0_PORTS",		0xa6, 0x01, true },
    454  1.14   msaitoh 	{ "EXE_ACTIVITY.1_PORTS_UTIL",			0xa6, 0x02, true },
    455  1.14   msaitoh 	{ "EXE_ACTIVITY.2_PORTS_UTIL",			0xa6, 0x04, true },
    456  1.14   msaitoh 	{ "EXE_ACTIVITY.3_PORTS_UTIL",			0xa6, 0x08, true },
    457  1.14   msaitoh 	{ "EXE_ACTIVITY.4_PORTS_UTIL",			0xa6, 0x10, true },
    458  1.14   msaitoh 	{ "EXE_ACTIVITY.BOUND_ON_STORES",		0xa6, 0x40, true },
    459  1.14   msaitoh 	{ "LSD.UOPS",					0xa8, 0x01, true },
    460  1.14   msaitoh 	{ "DSB2MITE_SWITCHES.PENALTY_CYCLES",		0xab, 0x02, true },
    461  1.14   msaitoh 	{ "ITLB.ITLB_FLUSH",				0xae, 0x01, true },
    462  1.14   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_DATA_RD",		0xb0, 0x01, true },
    463  1.14   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_CODE_RD",		0xb0, 0x02, true },
    464  1.14   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_RFO",		0xb0, 0x04, true },
    465  1.14   msaitoh 	{ "OFFCORE_REQUESTS.ALL_DATA_RD",		0xb0, 0x08, true },
    466  1.14   msaitoh 	{ "OFFCORE_REQUESTS.L3_MISS_DEMAND_DATA_RD",	0xb0, 0x10, true },
    467  1.14   msaitoh 	{ "OFFCORE_REQUESTS.ALL_REQUESTS",		0xb0, 0x80, true },
    468  1.14   msaitoh 	{ "UOPS_EXECUTED.THREAD",			0xb1, 0x01, true },
    469  1.14   msaitoh 	{ "UOPS_EXECUTED.CORE",				0xb1, 0x02, true },
    470  1.14   msaitoh 	{ "UOPS_EXECUTED.X87",				0xb1, 0x10, true },
    471  1.14   msaitoh 	{ "OFFCORE_REQUESTS_BUFFER.SQ_FULL",		0xb2, 0x01, true },
    472  1.14   msaitoh 	{ "TLB_FLUSH.DTLB_THREAD",			0xbd, 0x01, true },
    473  1.14   msaitoh 	{ "TLB_FLUSH.STLB_ANY",				0xbd, 0x20, true },
    474  1.14   msaitoh 	{ "INST_RETIRED.PREC_DIST",			0xc0, 0x01, true },
    475  1.14   msaitoh 	{ "OTHER_ASSISTS.ANY",				0xc1, 0x3f, true },
    476  1.14   msaitoh 	{ "UOPS_RETIRED.RETIRE_SLOTS",			0xc2, 0x02, true },
    477  1.14   msaitoh 	{ "MACHINE_CLEARS.MEMORY_ORDERING",		0xc3, 0x02, true },
    478  1.14   msaitoh 	{ "MACHINE_CLEARS.SMC",				0xc3, 0x04, true },
    479  1.14   msaitoh 	{ "BR_INST_RETIRED.CONDITIONAL",		0xc4, 0x01, true },
    480  1.14   msaitoh 	{ "BR_INST_RETIRED.NEAR_CALL",			0xc4, 0x02, true },
    481  1.14   msaitoh 	{ "BR_INST_RETIRED.NEAR_RETURN",		0xc4, 0x08, true },
    482  1.14   msaitoh 	{ "BR_INST_RETIRED.NOT_TAKEN",			0xc4, 0x10, true },
    483  1.14   msaitoh 	{ "BR_INST_RETIRED.NEAR_TAKEN",			0xc4, 0x20, true },
    484  1.14   msaitoh 	{ "BR_INST_RETIRED.FAR_BRANCH",			0xc4, 0x40, true },
    485  1.14   msaitoh 	{ "BR_MISP_RETIRED.CONDITIONAL",		0xc5, 0x01, true },
    486  1.14   msaitoh 	{ "BR_MISP_RETIRED.NEAR_CALL",			0xc5, 0x02, true },
    487  1.14   msaitoh 	{ "BR_MISP_RETIRED.NEAR_TAKEN",			0xc5, 0x20, true },
    488  1.14   msaitoh 	{ "HW_INTERRUPTS.RECEIVED",			0xcb, 0x01, true },
    489  1.14   msaitoh 	{ "MEM_INST_RETIRED.STLB_MISS_LOADS",		0xd0, 0x11, true },
    490  1.14   msaitoh 	{ "MEM_INST_RETIRED.STLB_MISS_STORES",		0xd0, 0x12, true },
    491  1.14   msaitoh 	{ "MEM_INST_RETIRED.LOCK_LOADS",		0xd0, 0x21, true },
    492  1.14   msaitoh 	{ "MEM_INST_RETIRED.SPLIT_LOADS",		0xd0, 0x41, true },
    493  1.14   msaitoh 	{ "MEM_INST_RETIRED.SPLIT_STORES",		0xd0, 0x42, true },
    494  1.14   msaitoh 	{ "MEM_INST_RETIRED.ALL_LOADS",			0xd0, 0x81, true },
    495  1.14   msaitoh 	{ "MEM_INST_RETIRED.ALL_STORES",		0xd0, 0x82, true },
    496  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L1_HIT",			0xd1, 0x01, true },
    497  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L2_HIT",			0xd1, 0x02, true },
    498  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L3_HIT",			0xd1, 0x04, true },
    499  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L1_MISS",			0xd1, 0x08, true },
    500  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L2_MISS",			0xd1, 0x10, true },
    501  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.L3_MISS",			0xd1, 0x20, true },
    502  1.14   msaitoh 	{ "MEM_LOAD_RETIRED.FB_HIT",			0xd1, 0x40, true },
    503  1.14   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS",		0xd2, 0x01, true },
    504  1.14   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_HIT",		0xd2, 0x02, true },
    505  1.14   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM",		0xd2, 0x04, true },
    506  1.14   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_NONE",		0xd2, 0x08, true },
    507  1.14   msaitoh 	{ "MEM_LOAD_MISC_RETIRED.UC",			0xd4, 0x04, true },
    508  1.14   msaitoh 	{ "BACLEARS.ANY",				0xe6, 0x01, true },
    509  1.14   msaitoh 	{ "L2_TRANS.L2_WB",				0xf0, 0x40, true },
    510  1.14   msaitoh 	{ "L2_LINES_IN.ALL",				0xf1, 0x1f, true },
    511  1.14   msaitoh 	{ "L2_LINES_OUT.SILENT",			0xf2, 0x01, true },
    512  1.14   msaitoh 	{ "L2_LINES_OUT.NON_SILENT",			0xf2, 0x02, true },
    513  1.14   msaitoh 	{ "L2_LINES_OUT.USELESS_HWPF",			0xf2, 0x04, true },
    514  1.14   msaitoh 	{ "SQ_MISC.SPLIT_LOCK",				0xf4, 0x10, true },
    515   1.1      maxv };
    516   1.1      maxv 
    517   1.1      maxv static struct event_table intel_skylake_kabylake = {
    518   1.1      maxv 	.tablename = "Intel Skylake/Kabylake",
    519   1.1      maxv 	.names = intel_skylake_kabylake_names,
    520   1.1      maxv 	.nevents = sizeof(intel_skylake_kabylake_names) /
    521   1.1      maxv 	    sizeof(struct name_to_event),
    522   1.1      maxv 	.next = NULL
    523   1.1      maxv };
    524   1.1      maxv 
    525   1.1      maxv static struct event_table *
    526   1.1      maxv init_intel_skylake_kabylake(void)
    527   1.1      maxv {
    528  1.13   msaitoh 
    529   1.1      maxv 	return &intel_skylake_kabylake;
    530   1.1      maxv }
    531   1.1      maxv 
    532  1.19   msaitoh /*
    533  1.19   msaitoh  * Intel Skylake-X (and Cascade Lake).
    534  1.19   msaitoh  */
    535  1.19   msaitoh static struct name_to_event intel_skylake_x_names[] = {
    536  1.19   msaitoh 	{ "INST_RETIRED.ANY",				0x00, 0x01, true },
    537  1.19   msaitoh 	{ "CPU_CLK_UNHALTED.THREAD",			0x00, 0x02, true },
    538  1.19   msaitoh 	{ "CPU_CLK_UNHALTED.REF_TSC",			0x00, 0x03, true },
    539  1.19   msaitoh 	{ "LD_BLOCKS.STORE_FORWARD",			0x03, 0x02, true },
    540  1.19   msaitoh 	{ "LD_BLOCKS.NO_SR",				0x03, 0x08, true },
    541  1.19   msaitoh 	{ "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS",		0x07, 0x01, true },
    542  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK",	0x08, 0x01, true },
    543  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_4K",		0x08, 0x02, true },
    544  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M",	0x08, 0x04, true },
    545  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_1G",		0x08, 0x08, true },
    546  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_COMPLETED",		0x08, 0x0E, true },
    547  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.WALK_PENDING",		0x08, 0x10, true },
    548  1.19   msaitoh 	{ "DTLB_LOAD_MISSES.STLB_HIT",			0x08, 0x20, true },
    549  1.19   msaitoh 	{ "INT_MISC.RECOVERY_CYCLES",			0x0D, 0x01, true },
    550  1.19   msaitoh 	{ "INT_MISC.CLEAR_RESTEER_CYCLES",		0x0D, 0x80, true },
    551  1.19   msaitoh 	{ "UOPS_ISSUED.ANY",				0x0E, 0x01, true },
    552  1.19   msaitoh 	{ "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH",		0x0E, 0x02, true },
    553  1.19   msaitoh 	{ "UOPS_ISSUED.SLOW_LEA",			0x0E, 0x20, true },
    554  1.19   msaitoh 	{ "ARITH.DIVIDER_ACTIVE",			0x14, 0x01, true },
    555  1.19   msaitoh 	{ "L2_RQSTS.DEMAND_DATA_RD_MISS",		0x24, 0x21, true },
    556  1.19   msaitoh 	{ "L2_RQSTS.RFO_MISS",				0x24, 0x22, true },
    557  1.19   msaitoh 	{ "L2_RQSTS.CODE_RD_MISS",			0x24, 0x24, true },
    558  1.19   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_MISS",			0x24, 0x27, true },
    559  1.19   msaitoh 	{ "L2_RQSTS.PF_MISS",				0x24, 0x38, true },
    560  1.19   msaitoh 	{ "L2_RQSTS.MISS",				0x24, 0x3F, true },
    561  1.19   msaitoh 	{ "L2_RQSTS.DEMAND_DATA_RD_HIT",		0x24, 0x41, true },
    562  1.19   msaitoh 	{ "L2_RQSTS.RFO_HIT",				0x24, 0x42, true },
    563  1.19   msaitoh 	{ "L2_RQSTS.CODE_RD_HIT",			0x24, 0x44, true },
    564  1.19   msaitoh 	{ "L2_RQSTS.PF_HIT",				0x24, 0xD8, true },
    565  1.19   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_DATA_RD",		0x24, 0xE1, true },
    566  1.19   msaitoh 	{ "L2_RQSTS.ALL_RFO",				0x24, 0xE2, true },
    567  1.19   msaitoh 	{ "L2_RQSTS.ALL_CODE_RD",			0x24, 0xE4, true },
    568  1.19   msaitoh 	{ "L2_RQSTS.ALL_DEMAND_REFERENCES",		0x24, 0xE7, true },
    569  1.19   msaitoh 	{ "L2_RQSTS.ALL_PF",				0x24, 0xF8, true },
    570  1.19   msaitoh 	{ "L2_RQSTS.REFERENCES All L2",			0x24, 0xFF, true },
    571  1.19   msaitoh 	{ "CORE_POWER.LVL0_TURBO_LICENSE",		0x28, 0x07, true },
    572  1.19   msaitoh 	{ "CORE_POWER.LVL1_TURBO_LICENSE",		0x28, 0x18, true },
    573  1.19   msaitoh 	{ "CORE_POWER.LVL2_TURBO_LICENSE",		0x28, 0x20, true },
    574  1.19   msaitoh 	{ "CORE_POWER.THROTTLE",			0x28, 0x40, true },
    575  1.19   msaitoh 	{ "LONGEST_LAT_CACHE.MISS",			0x2E, 0x41, true },
    576  1.19   msaitoh 	{ "LONGEST_LAT_CACHE.REFERENCE",		0x2E, 0x4F, true },
    577  1.19   msaitoh 	{ "CPU_CLK_UNHALTED.THREAD_P",			0x3C, 0x00, true },
    578  1.19   msaitoh 	{ "CPU_CLK_THREAD_UNHALTED.REF_XCLK",		0x3C, 0x01, true },
    579  1.19   msaitoh 	{ "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE",	0x3C, 0x02, true },
    580  1.19   msaitoh 	{ "L1D_PEND_MISS.PENDING",			0x48, 0x01, true },
    581  1.19   msaitoh 	{ "L1D_PEND_MISS.FB_FULL",			0x48, 0x02, true },
    582  1.19   msaitoh 	{ "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK",	0x49, 0x01, true },
    583  1.19   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_4K",	0x49, 0x02, true },
    584  1.19   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M",	0x49, 0x04, true },
    585  1.19   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED_1G",	0x49, 0x08, true },
    586  1.19   msaitoh 	{ "DTLB_STORE_MISSES.WALK_COMPLETED",		0x49, 0x0E, true },
    587  1.19   msaitoh 	{ "DTLB_STORE_MISSES.WALK_PENDING",		0x49, 0x10, true },
    588  1.19   msaitoh 	{ "DTLB_STORE_MISSES.STLB_HIT",			0x49, 0x20, true },
    589  1.19   msaitoh 	{ "LOAD_HIT_PRE.SW_PF",				0x4C, 0x01, true },
    590  1.19   msaitoh 	{ "EPT.WALK_PENDING",				0x4F, 0x10, true },
    591  1.19   msaitoh 	{ "L1D.REPLACEMENT",				0x51, 0x01, true },
    592  1.19   msaitoh 	{ "TX_MEM.ABORT_CONFLICT",			0x54, 0x01, true },
    593  1.19   msaitoh 	{ "TX_MEM.ABORT_CAPACITY",			0x54, 0x02, true },
    594  1.19   msaitoh 	{ "TX_MEM.ABORT_HLE_STORE_TO_ELIDED_LOCK",	0x54, 0x04, true },
    595  1.19   msaitoh 	{ "TX_MEM.ABORT_HLE_ELISION_BUFFER_NOT_EMPTY",	0x54, 0x08, true },
    596  1.19   msaitoh 	{ "TX_MEM.ABORT_HLE_ELISION_BUFFER_MISMATCH",	0x54, 0x10, true },
    597  1.19   msaitoh 	{ "TX_MEM.ABORT_HLE_ELISION_BUFFER_UNSUPPORTED_ALIGNMENT",
    598  1.19   msaitoh 							0x54, 0x20, true },
    599  1.19   msaitoh 	{ "TX_MEM.HLE_ELISION_BUFFER_FULL",		0x54, 0x40, true },
    600  1.19   msaitoh 	{ "TX_EXEC.MISC1",				0x5D, 0x01, true },
    601  1.19   msaitoh 	{ "TX_EXEC.MISC2",				0x5D, 0x02, true },
    602  1.19   msaitoh 	{ "TX_EXEC.MISC3",				0x5D, 0x04, true },
    603  1.19   msaitoh 	{ "TX_EXEC.MISC4",				0x5D, 0x08, true },
    604  1.19   msaitoh 	{ "TX_EXEC.MISC5",				0x5D, 0x10, true },
    605  1.19   msaitoh 	{ "RS_EVENTS.EMPTY_CYCLES",			0x5E, 0x01, true },
    606  1.19   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD",
    607  1.19   msaitoh 							0x60, 0x01, true },
    608  1.19   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD",
    609  1.19   msaitoh 							0x60, 0x02, true },
    610  1.19   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO",	0x60, 0x04, true },
    611  1.19   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD",	0x60, 0x08, true },
    612  1.19   msaitoh 	{ "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",
    613  1.19   msaitoh 							0x60, 0x10, true },
    614  1.19   msaitoh 	{ "IDQ.MITE_UOPS",				0x79, 0x04, true },
    615  1.19   msaitoh 	{ "IDQ.DSB_UOPS",				0x79, 0x08, true },
    616  1.19   msaitoh 	{ "IDQ.MS_DSB_CYCLES",				0x79, 0x10, true },
    617  1.19   msaitoh 	{ "IDQ.ALL_DSB_CYCLES_4_UOPS",			0x79, 0x18, true },
    618  1.19   msaitoh 	{ "IDQ.MS_MITE_UOPS",				0x79, 0x20, true },
    619  1.19   msaitoh 	{ "IDQ.ALL_MITE_CYCLES_4_UOPS",			0x79, 0x24, true },
    620  1.19   msaitoh 	{ "IDQ.MS_CYCLES",				0x79, 0x30, true },
    621  1.19   msaitoh 	{ "ICACHE_16B.IFDATA_STALL",			0x80, 0x04, true },
    622  1.19   msaitoh 	{ "ICACHE_64B.IFTAG_HIT",			0x83, 0x01, true },
    623  1.19   msaitoh 	{ "ICACHE_64B.IFTAG_MISS",			0x83, 0x02, true },
    624  1.19   msaitoh 	{ "ICACHE_64B.IFTAG_STALL",			0x83, 0x04, true },
    625  1.19   msaitoh 	{ "ITLB_MISSES.MISS_CAUSES_A_WALK",		0x85, 0x01, true },
    626  1.19   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_4K",		0x85, 0x02, true },
    627  1.19   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_2M_4M",		0x85, 0x04, true },
    628  1.19   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED_1G",		0x85, 0x08, true },
    629  1.19   msaitoh 	{ "ITLB_MISSES.WALK_COMPLETED",			0x85, 0x0E, true },
    630  1.19   msaitoh 	{ "ITLB_MISSES.WALK_PENDING",			0x85, 0x10, true },
    631  1.19   msaitoh 	{ "ITLB_MISSES.STLB_HIT",			0x85, 0x20, true },
    632  1.19   msaitoh 	{ "ILD_STALL.LCP",				0x87, 0x01, true },
    633  1.19   msaitoh 	{ "IDQ_UOPS_NOT_DELIVERED.CORE",		0x9C, 0x01, true },
    634  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_0",		0xa1, 0x01, true },
    635  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_1",		0xa1, 0x02, true },
    636  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_2",		0xa1, 0x04, true },
    637  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_3",		0xa1, 0x08, true },
    638  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_4",		0xa1, 0x10, true },
    639  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_5",		0xa1, 0x20, true },
    640  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_6",		0xa1, 0x40, true },
    641  1.19   msaitoh 	{ "UOPS_DISPATCHED_PORT.PORT_7",		0xa1, 0x80, true },
    642  1.19   msaitoh 	{ "RESOURCE_STALLS.ANY",			0xa2, 0x01, true },
    643  1.19   msaitoh 	{ "RESOURCE_STALLS.SB",				0xa2, 0x08, true },
    644  1.19   msaitoh 	{ "CYCLE_ACTIVITY.CYCLES_L2_MISS",		0xa3, 0x01, true },
    645  1.19   msaitoh 	{ "CYCLE_ACTIVITY.CYCLES_L3_MISS",		0xa3, 0x02, true },
    646  1.19   msaitoh 	{ "CYCLE_ACTIVITY.STALLS_TOTAL",		0xa3, 0x04, true },
    647  1.19   msaitoh 	{ "CYCLE_ACTIVITY.STALLS_L2_MISS",		0xa3, 0x05, true },
    648  1.19   msaitoh 	{ "CYCLE_ACTIVITY.STALLS_L3_MISS",		0xa3, 0x06, true },
    649  1.19   msaitoh 	{ "CYCLE_ACTIVITY.CYCLES_L1D_MISS",		0xa3, 0x08, true },
    650  1.19   msaitoh 	{ "CYCLE_ACTIVITY.STALLS_L1D_MISS",		0xa3, 0x0C, true },
    651  1.19   msaitoh 	{ "CYCLE_ACTIVITY.CYCLES_MEM_ANY",		0xa3, 0x10, true },
    652  1.19   msaitoh 	{ "CYCLE_ACTIVITY.STALLS_MEM_ANY",		0xa3, 0x14, true },
    653  1.19   msaitoh 	{ "EXE_ACTIVITY.EXE_BOUND_0_PORTS",		0xa6, 0x01, true },
    654  1.19   msaitoh 	{ "EXE_ACTIVITY.1_PORTS_UTIL",			0xa6, 0x02, true },
    655  1.19   msaitoh 	{ "EXE_ACTIVITY.2_PORTS_UTIL",			0xa6, 0x04, true },
    656  1.19   msaitoh 	{ "EXE_ACTIVITY.3_PORTS_UTIL",			0xa6, 0x08, true },
    657  1.19   msaitoh 	{ "EXE_ACTIVITY.4_PORTS_UTIL",			0xa6, 0x10, true },
    658  1.19   msaitoh 	{ "EXE_ACTIVITY.BOUND_ON_STORES",		0xa6, 0x40, true },
    659  1.19   msaitoh 	{ "LSD.UOPS",					0xa8, 0x01, true },
    660  1.19   msaitoh 	{ "DSB2MITE_SWITCHES.PENALTY_CYCLES",		0xaB, 0x02, true },
    661  1.19   msaitoh 	{ "ITLB.ITLB_FLUSH",				0xaE, 0x01, true },
    662  1.19   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_DATA_RD",		0xb0, 0x01, true },
    663  1.19   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_CODE_RD",		0xb0, 0x02, true },
    664  1.19   msaitoh 	{ "OFFCORE_REQUESTS.DEMAND_RFO",		0xb0, 0x04, true },
    665  1.19   msaitoh 	{ "OFFCORE_REQUESTS.ALL_DATA_RD",		0xb0, 0x08, true },
    666  1.19   msaitoh 	{ "OFFCORE_REQUESTS.L3_MISS_DEMAND_DATA_RD",	0xb0, 0x10, true },
    667  1.19   msaitoh 	{ "OFFCORE_REQUESTS.ALL_REQUESTS",		0xb0, 0x80, true },
    668  1.19   msaitoh 	{ "UOPS_EXECUTED.THREAD",			0xb1, 0x01, true },
    669  1.19   msaitoh 	{ "UOPS_EXECUTED.CORE",				0xb1, 0x02, true },
    670  1.19   msaitoh 	{ "UOPS_EXECUTED.X87",				0xb1, 0x10, true },
    671  1.19   msaitoh 	{ "OFFCORE_REQUESTS_BUFFER.SQ_FULL",		0xb2, 0x01, true },
    672  1.19   msaitoh 	{ "TLB_FLUSH.DTLB_THREAD",			0xbD, 0x01, true },
    673  1.19   msaitoh 	{ "TLB_FLUSH.STLB_ANY",				0xbD, 0x20, true },
    674  1.19   msaitoh 	{ "INST_RETIRED.ANY_P",				0xc0, 0x00, true },
    675  1.19   msaitoh 	{ "INST_RETIRED.PREC_DIST",			0xc0, 0x01, true },
    676  1.19   msaitoh 	{ "OTHER_ASSISTS.ANY",				0xc1, 0x3F, true },
    677  1.19   msaitoh 	{ "UOPS_RETIRED.STALL_CYCLES",			0xc2, 0x01, true },
    678  1.19   msaitoh 	{ "UOPS_RETIRED.RETIRE_SLOTS",			0xc2, 0x02, true },
    679  1.19   msaitoh 	{ "MACHINE_CLEARS.COUNT",			0xc3, 0x01, true },
    680  1.19   msaitoh 	{ "MACHINE_CLEARS.MEMORY_ORDERING",		0xc3, 0x02, true },
    681  1.19   msaitoh 	{ "MACHINE_CLEARS.SMC",				0xc3, 0x04, true },
    682  1.19   msaitoh 	{ "BR_INST_RETIRED.ALL_BRANCHES",		0xc4, 0x00, true },
    683  1.19   msaitoh 	{ "BR_INST_RETIRED.CONDITIONAL",		0xc4, 0x01, true },
    684  1.19   msaitoh 	{ "BR_INST_RETIRED.NEAR_CALL",			0xc4, 0x02, true },
    685  1.19   msaitoh 	{ "BR_INST_RETIRED.NEAR_RETURN",		0xc4, 0x08, true },
    686  1.19   msaitoh 	{ "BR_INST_RETIRED.NOT_TAKEN",			0xc4, 0x10, true },
    687  1.19   msaitoh 	{ "BR_INST_RETIRED.NEAR_TAKEN",			0xc4, 0x20, true },
    688  1.19   msaitoh 	{ "BR_INST_RETIRED.FAR_BRANCH",			0xc4, 0x40, true },
    689  1.19   msaitoh 	{ "BR_MISP_RETIRED.ALL_BRANCHES",		0xc5, 0x00, true },
    690  1.19   msaitoh 	{ "BR_MISP_RETIRED.CONDITIONAL",		0xc5, 0x01, true },
    691  1.19   msaitoh 	{ "BR_MISP_RETIRED.NEAR_CALL",			0xc5, 0x02, true },
    692  1.19   msaitoh 	{ "BR_MISP_RETIRED.NEAR_TAKEN",			0xc5, 0x20, true },
    693  1.19   msaitoh 	{ "FRONTEND_RETIRED.DSB_MISS",			0xc6, 0x01, true },
    694  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.SCALAR_DOUBLE",	0xc7, 0x01, true },
    695  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.SCALAR_SINGLE",	0xc7, 0x02, true },
    696  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE",	0xc7, 0x04, true },
    697  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.128B_PACKED_SINGLE",	0xc7, 0x08, true },
    698  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE",	0xc7, 0x10, true },
    699  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.256B_PACKED_SINGLE",	0xc7, 0x20, true },
    700  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.512B_PACKED_DOUBLE",	0xc7, 0x40, true },
    701  1.19   msaitoh 	{ "FP_ARITH_INST_RETIRED.512B_PACKED_SINGLE",	0xc7, 0x80, true },
    702  1.19   msaitoh 	{ "HLE_RETIRED.START",				0xc8, 0x01, true },
    703  1.19   msaitoh 	{ "HLE_RETIRED.COMMIT",				0xc8, 0x02, true },
    704  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED",			0xc8, 0x04, true },
    705  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED_MEM",			0xc8, 0x08, true },
    706  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED_TIMER",			0xc8, 0x10, true },
    707  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED_UNFRIENDLY",		0xc8, 0x20, true },
    708  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED_MEMTYPE",		0xc8, 0x40, true },
    709  1.19   msaitoh 	{ "HLE_RETIRED.ABORTED_EVENTS",			0xc8, 0x80, true },
    710  1.19   msaitoh 	{ "RTM_RETIRED.START",				0xc9, 0x01, true },
    711  1.19   msaitoh 	{ "RTM_RETIRED.COMMIT",				0xc9, 0x02, true },
    712  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED",			0xc9, 0x04, true },
    713  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED_MEM",			0xc9, 0x08, true },
    714  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED_TIMER",			0xc9, 0x10, true },
    715  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED_UNFRIENDLY",		0xc9, 0x20, true },
    716  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED_MEMTYPE",		0xc9, 0x40, true },
    717  1.19   msaitoh 	{ "RTM_RETIRED.ABORTED_EVENTS",			0xc9, 0x80, true },
    718  1.19   msaitoh 	{ "FP_ASSIST.ANY",				0xca, 0x1e, true },
    719  1.19   msaitoh 	{ "HW_INTERRUPTS.RECEIVED",			0xcb, 0x01, true },
    720  1.19   msaitoh 	{ "ROB_MISC_EVENTS.LBR_INSERTS",		0xcc, 0x20, true },
    721  1.19   msaitoh 	{ "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_4",	0xcd, 0x01, true },
    722  1.19   msaitoh 	{ "MEM_INST_RETIRED.STLB_MISS_LOADS",		0xd0, 0x11, true },
    723  1.19   msaitoh 	{ "MEM_INST_RETIRED.STLB_MISS_STORES",		0xd0, 0x12, true },
    724  1.19   msaitoh 	{ "MEM_INST_RETIRED.LOCK_LOADS",		0xd0, 0x21, true },
    725  1.19   msaitoh 	{ "MEM_INST_RETIRED.SPLIT_LOADS",		0xd0, 0x41, true },
    726  1.19   msaitoh 	{ "MEM_INST_RETIRED.SPLIT_STORES",		0xd0, 0x42, true },
    727  1.19   msaitoh 	{ "MEM_INST_RETIRED.ALL_LOADS",			0xd0, 0x81, true },
    728  1.19   msaitoh 	{ "MEM_INST_RETIRED.ALL_STORES",		0xd0, 0x82, true },
    729  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L1_HIT",			0xd1, 0x01, true },
    730  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L2_HIT",			0xd1, 0x02, true },
    731  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L3_HIT",			0xd1, 0x04, true },
    732  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L1_MISS",			0xd1, 0x08, true },
    733  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L2_MISS",			0xd1, 0x10, true },
    734  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.L3_MISS",			0xd1, 0x20, true },
    735  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.FB_HIT",			0xd1, 0x40, true },
    736  1.19   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS",		0xd2, 0x01, true },
    737  1.19   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_HIT",		0xd2, 0x02, true },
    738  1.19   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM",		0xd2, 0x04, true },
    739  1.19   msaitoh 	{ "MEM_LOAD_L3_HIT_RETIRED.XSNP_NONE",		0xd2, 0x08, true },
    740  1.19   msaitoh 	{ "MEM_LOAD_L3_MISS_RETIRED.LOCAL_DRAM",	0xd3, 0x01, true },
    741  1.19   msaitoh 	{ "MEM_LOAD_L3_MISS_RETIRED.REMOTE_DRAM",	0xd3, 0x02, true },
    742  1.19   msaitoh 	{ "MEM_LOAD_L3_MISS_RETIRED.REMOTE_HITM",	0xd3, 0x04, true },
    743  1.19   msaitoh 	{ "MEM_LOAD_L3_MISS_RETIRED.REMOTE_FWD",	0xd3, 0x08, true },
    744  1.19   msaitoh 	{ "MEM_LOAD_MISC_RETIRED.UC",			0xd4, 0x04, true },
    745  1.19   msaitoh 	{ "BACLEARS.ANY",				0xe6, 0x01, true },
    746  1.19   msaitoh 	{ "L2_TRANS.L2_WB",				0xf0, 0x40, true },
    747  1.19   msaitoh 	{ "L2_LINES_IN.ALL",				0xf1, 0x1f, true },
    748  1.19   msaitoh 	{ "L2_LINES_OUT.SILENT",			0xf2, 0x01, true },
    749  1.19   msaitoh 	{ "L2_LINES_OUT.NON_SILENT",			0xf2, 0x02, true },
    750  1.19   msaitoh 	{ "L2_LINES_OUT.USELESS_PREF",			0xf2, 0x04, true },
    751  1.19   msaitoh 	{ "SQ_MISC.SPLIT_LOCK",				0xf4, 0x10, true },
    752  1.19   msaitoh 	{ "IDI_MISC.WB_UPGRADE",			0xfe, 0x02, true },
    753  1.19   msaitoh 	{ "IDI_MISC.WB_DOWNGRADE",			0xfe, 0x04, true },
    754  1.19   msaitoh };
    755  1.19   msaitoh 
    756  1.19   msaitoh static struct event_table intel_skylake_x = {
    757  1.19   msaitoh 	.tablename = "Intel Skylake-X",
    758  1.19   msaitoh 	.names = intel_skylake_x_names,
    759  1.19   msaitoh 	.nevents = sizeof(intel_skylake_x_names) /
    760  1.19   msaitoh 	    sizeof(struct name_to_event),
    761  1.19   msaitoh 	.next = NULL
    762  1.19   msaitoh };
    763  1.19   msaitoh 
    764  1.19   msaitoh static struct event_table *
    765  1.19   msaitoh init_intel_skylake_x(void)
    766  1.19   msaitoh {
    767  1.19   msaitoh 
    768  1.19   msaitoh 	return &intel_skylake_x;
    769  1.19   msaitoh }
    770  1.19   msaitoh 
    771  1.19   msaitoh /*
    772  1.19   msaitoh  * Intel Cascade Lake.
    773  1.19   msaitoh  */
    774  1.19   msaitoh static struct name_to_event intel_cascadelake_names[] = {
    775  1.19   msaitoh 	{ "MEM_LOAD_RETIRED.LOCAL_PMM",			0xd1, 0x80, true },
    776  1.19   msaitoh 	{ "MEM_LOAD_L3_MISS_RETIRED.REMOTE_PMM",	0xd3, 0x10, true },
    777  1.19   msaitoh };
    778  1.19   msaitoh 
    779  1.19   msaitoh static struct event_table intel_cascadelake = {
    780  1.19   msaitoh 	.tablename = "Intel Cascade Lake",
    781  1.19   msaitoh 	.names = intel_cascadelake_names,
    782  1.19   msaitoh 	.nevents = sizeof(intel_cascadelake_names) /
    783  1.19   msaitoh 	    sizeof(struct name_to_event),
    784  1.19   msaitoh 	.next = NULL
    785  1.19   msaitoh };
    786  1.19   msaitoh 
    787  1.19   msaitoh static struct event_table *
    788  1.19   msaitoh init_intel_cascadelake(void)
    789  1.19   msaitoh {
    790  1.19   msaitoh 
    791  1.19   msaitoh 	intel_skylake_x.next = &intel_cascadelake;
    792  1.19   msaitoh 
    793  1.19   msaitoh 	return &intel_skylake_x;
    794  1.19   msaitoh }
    795  1.19   msaitoh 
    796   1.1      maxv static struct event_table *
    797   1.1      maxv init_intel_generic(void)
    798   1.1      maxv {
    799   1.1      maxv 	unsigned int eax, ebx, ecx, edx;
    800   1.1      maxv 	struct event_table *table;
    801  1.19   msaitoh 	uint8_t stepping;
    802   1.1      maxv 
    803   1.1      maxv 	/*
    804   1.1      maxv 	 * The kernel made sure the Architectural Version 1 PMCs were
    805   1.1      maxv 	 * present.
    806   1.1      maxv 	 */
    807   1.1      maxv 	table = init_intel_arch1();
    808   1.1      maxv 
    809   1.1      maxv 	/*
    810   1.1      maxv 	 * Now query the additional (non-architectural) events. They
    811   1.1      maxv 	 * depend on the CPU model.
    812   1.1      maxv 	 */
    813   1.1      maxv 	eax = 0x01;
    814   1.1      maxv 	ebx = 0;
    815   1.1      maxv 	ecx = 0;
    816   1.1      maxv 	edx = 0;
    817   1.1      maxv 	x86_cpuid(&eax, &ebx, &ecx, &edx);
    818   1.1      maxv 
    819   1.3      maxv 	if (CPUID_TO_FAMILY(eax) == 6) {
    820   1.3      maxv 		switch (CPUID_TO_MODEL(eax)) {
    821   1.5  knakahar 		case 0x37: /* Silvermont (Bay Trail) */
    822  1.14   msaitoh 		case 0x4a: /* Silvermont (Tangier) */
    823  1.14   msaitoh 		case 0x4c: /* Airmont (Braswell, Cherry Trail) */
    824  1.14   msaitoh 		case 0x4d: /* Silvermont (Avoton, Rangeley) */
    825  1.14   msaitoh 		case 0x5a: /* Silvermont (Anniedale) */
    826  1.14   msaitoh 		case 0x5d: /* Silvermont (SoFIA) */
    827   1.5  knakahar 			table->next = init_intel_silvermont_airmont();
    828   1.5  knakahar 			break;
    829  1.14   msaitoh 		case 0x5c: /* Goldmont (Apollo Lake) */
    830  1.14   msaitoh 		case 0x5f: /* Goldmont (Denverton) */
    831   1.6  knakahar 			table->next = init_intel_goldmont();
    832   1.6  knakahar 			break;
    833  1.14   msaitoh 		case 0x7a: /* Goldmont Plus (Gemini Lake) */
    834   1.7  knakahar 			table->next = init_intel_goldmontplus();
    835   1.7  knakahar 			break;
    836  1.14   msaitoh 		case 0x4e: /* Skylake */
    837  1.14   msaitoh 		case 0x5e: /* Skylake */
    838  1.18   msaitoh 		case 0x8e: /* Kaby Lake */
    839  1.18   msaitoh 		case 0x9e: /* Kaby Lake */
    840  1.18   msaitoh 		case 0xa5: /* Comet Lake */
    841  1.18   msaitoh 		case 0xa6: /* Comet Lake */
    842   1.3      maxv 			table->next = init_intel_skylake_kabylake();
    843   1.3      maxv 			break;
    844  1.19   msaitoh 
    845  1.19   msaitoh 		case 0x55: /* Skylake-X, Cascade Lake */
    846  1.19   msaitoh 			stepping = CPUID_TO_STEPPING(eax);
    847  1.19   msaitoh 			if (stepping <= 4)
    848  1.19   msaitoh 				table->next = init_intel_skylake_x();
    849  1.19   msaitoh 			else
    850  1.19   msaitoh 				table->next = init_intel_cascadelake();
    851  1.19   msaitoh 			break;
    852  1.19   msaitoh 
    853   1.3      maxv 		}
    854   1.1      maxv 	}
    855   1.1      maxv 
    856   1.1      maxv 	return table;
    857   1.1      maxv }
    858   1.1      maxv 
    859  1.13   msaitoh /* ------------------------------------------------------------------------- */
    860   1.1      maxv 
    861   1.1      maxv /*
    862   1.1      maxv  * AMD Family 10h
    863   1.1      maxv  */
    864   1.1      maxv static struct name_to_event amd_f10h_names[] = {
    865   1.2      maxv 	{ "seg-load-all",		0x20, 0x7f, true },
    866   1.2      maxv 	{ "seg-load-es",		0x20, 0x01, true },
    867   1.2      maxv 	{ "seg-load-cs",		0x20, 0x02, true },
    868   1.2      maxv 	{ "seg-load-ss",		0x20, 0x04, true },
    869   1.2      maxv 	{ "seg-load-ds",		0x20, 0x08, true },
    870   1.2      maxv 	{ "seg-load-fs",		0x20, 0x10, true },
    871   1.2      maxv 	{ "seg-load-gs",		0x20, 0x20, true },
    872   1.2      maxv 	{ "seg-load-hs",		0x20, 0x40, true },
    873   1.2      maxv 	{ "l1cache-access",		0x40, 0x00, true },
    874   1.2      maxv 	{ "l1cache-miss",		0x41, 0x00, true },
    875   1.2      maxv 	{ "l1cache-refill",		0x42, 0x1f, true },
    876   1.2      maxv 	{ "l1cache-refill-invalid",	0x42, 0x01, true },
    877   1.2      maxv 	{ "l1cache-refill-shared",	0x42, 0x02, true },
    878   1.2      maxv 	{ "l1cache-refill-exclusive",	0x42, 0x04, true },
    879   1.2      maxv 	{ "l1cache-refill-owner",	0x42, 0x08, true },
    880   1.2      maxv 	{ "l1cache-refill-modified",	0x42, 0x10, true },
    881   1.2      maxv 	{ "l1cache-load",		0x43, 0x1f, true },
    882   1.2      maxv 	{ "l1cache-load-invalid",	0x43, 0x01, true },
    883   1.2      maxv 	{ "l1cache-load-shared",	0x43, 0x02, true },
    884   1.2      maxv 	{ "l1cache-load-exclusive",	0x43, 0x04, true },
    885   1.2      maxv 	{ "l1cache-load-owner",		0x43, 0x08, true },
    886   1.2      maxv 	{ "l1cache-load-modified",	0x43, 0x10, true },
    887   1.2      maxv 	{ "l1cache-writeback",		0x44, 0x1f, true },
    888   1.2      maxv 	{ "l1cache-writeback-invalid",	0x44, 0x01, true },
    889   1.2      maxv 	{ "l1cache-writeback-shared",	0x44, 0x02, true },
    890   1.2      maxv 	{ "l1cache-writeback-exclusive",0x44, 0x04, true },
    891   1.2      maxv 	{ "l1cache-writeback-owner",	0x44, 0x08, true },
    892   1.2      maxv 	{ "l1cache-writeback-modified",	0x44, 0x10, true },
    893  1.14   msaitoh 	{ "l1DTLB-hit-all",		0x4d, 0x07, true },
    894  1.14   msaitoh 	{ "l1DTLB-hit-4Kpage",		0x4d, 0x01, true },
    895  1.14   msaitoh 	{ "l1DTLB-hit-2Mpage",		0x4d, 0x02, true },
    896  1.14   msaitoh 	{ "l1DTLB-hit-1Gpage",		0x4d, 0x04, true },
    897   1.2      maxv 	{ "l1DTLB-miss-all",		0x45, 0x07, true },
    898   1.2      maxv 	{ "l1DTLB-miss-4Kpage",		0x45, 0x01, true },
    899   1.2      maxv 	{ "l1DTLB-miss-2Mpage",		0x45, 0x02, true },
    900   1.2      maxv 	{ "l1DTLB-miss-1Gpage",		0x45, 0x04, true },
    901   1.2      maxv 	{ "l2DTLB-miss-all",		0x46, 0x03, true },
    902   1.2      maxv 	{ "l2DTLB-miss-4Kpage",		0x46, 0x01, true },
    903   1.2      maxv 	{ "l2DTLB-miss-2Mpage",		0x46, 0x02, true },
    904   1.1      maxv 	/* l2DTLB-miss-1Gpage: reserved on some revisions, so disabled */
    905   1.2      maxv 	{ "l1ITLB-miss",		0x84, 0x00, true },
    906   1.2      maxv 	{ "l2ITLB-miss-all",		0x85, 0x03, true },
    907   1.2      maxv 	{ "l2ITLB-miss-4Kpage",		0x85, 0x01, true },
    908   1.2      maxv 	{ "l2ITLB-miss-2Mpage",		0x85, 0x02, true },
    909   1.2      maxv 	{ "mem-misalign-ref",		0x47, 0x00, true },
    910   1.2      maxv 	{ "ins-fetch",			0x80, 0x00, true },
    911   1.2      maxv 	{ "ins-fetch-miss",		0x81, 0x00, true },
    912   1.2      maxv 	{ "ins-refill-l2",		0x82, 0x00, true },
    913   1.2      maxv 	{ "ins-refill-sys",		0x83, 0x00, true },
    914   1.2      maxv 	{ "ins-fetch-stall",		0x87, 0x00, true },
    915  1.14   msaitoh 	{ "ins-retired",		0xc0, 0x00, true },
    916  1.14   msaitoh 	{ "ins-empty",			0xd0, 0x00, true },
    917  1.14   msaitoh 	{ "ops-retired",		0xc1, 0x00, true },
    918  1.14   msaitoh 	{ "branch-retired",		0xc2, 0x00, true },
    919  1.14   msaitoh 	{ "branch-miss-retired",	0xc3, 0x00, true },
    920  1.14   msaitoh 	{ "branch-taken-retired",	0xc4, 0x00, true },
    921  1.14   msaitoh 	{ "branch-taken-miss-retired",	0xc5, 0x00, true },
    922  1.14   msaitoh 	{ "branch-far-retired",		0xc6, 0x00, true },
    923  1.14   msaitoh 	{ "branch-resync-retired",	0xc7, 0x00, true },
    924  1.14   msaitoh 	{ "branch-near-retired",	0xc8, 0x00, true },
    925  1.14   msaitoh 	{ "branch-near-miss-retired",	0xc9, 0x00, true },
    926  1.14   msaitoh 	{ "branch-indirect-miss-retired", 0xca, 0x00, true },
    927  1.14   msaitoh 	{ "int-hw",			0xcf, 0x00, true },
    928  1.14   msaitoh 	{ "int-cycles-masked",		0xcd, 0x00, true },
    929  1.14   msaitoh 	{ "int-cycles-masked-pending",	0xce, 0x00, true },
    930  1.14   msaitoh 	{ "fpu-exceptions",		0xdb, 0x00, true },
    931  1.14   msaitoh 	{ "break-match0",		0xdc, 0x00, true },
    932  1.14   msaitoh 	{ "break-match1",		0xdd, 0x00, true },
    933  1.14   msaitoh 	{ "break-match2",		0xde, 0x00, true },
    934  1.14   msaitoh 	{ "break-match3",		0xdf, 0x00, true },
    935   1.1      maxv };
    936   1.1      maxv 
    937   1.1      maxv static struct event_table amd_f10h = {
    938   1.1      maxv 	.tablename = "AMD Family 10h",
    939   1.1      maxv 	.names = amd_f10h_names,
    940   1.1      maxv 	.nevents = sizeof(amd_f10h_names) /
    941   1.1      maxv 	    sizeof(struct name_to_event),
    942   1.1      maxv 	.next = NULL
    943   1.1      maxv };
    944   1.1      maxv 
    945   1.8      maxv /*
    946   1.9  jmcneill  * AMD Family 15h
    947   1.9  jmcneill  */
    948   1.9  jmcneill static struct name_to_event amd_f15h_names[] = {
    949   1.9  jmcneill 	{ "FpPipeAssignment",		0x000, 0x77, true },
    950   1.9  jmcneill 	{ "FpSchedulerEmpty",		0x001, 0x00, true },
    951   1.9  jmcneill 	{ "FpRetSseAvxOps",		0x003, 0xff, true },
    952   1.9  jmcneill 	{ "FpNumMovElim",		0x004, 0x0f, true },
    953   1.9  jmcneill 	{ "FpRetiredSerOps",		0x005, 0x0f, true },
    954   1.9  jmcneill 	{ "LsSegRegLoads",		0x020, 0x7f, true },
    955   1.9  jmcneill 	{ "LsPipeRestartSelfMod",	0x021, 0x00, true },
    956   1.9  jmcneill 	{ "LsPipeRestartVarious",	0x022, 0x1f, true },
    957   1.9  jmcneill 	{ "LsLoadQueueStoreQFull",	0x023, 0x03, true },
    958   1.9  jmcneill 	{ "LsLockedOps",		0x024, 0x00, true },
    959   1.9  jmcneill 	{ "LsRetClflushInstr",		0x026, 0x00, true },
    960   1.9  jmcneill 	{ "LsRetCpuidInstr",		0x027, 0x00, true },
    961   1.9  jmcneill 	{ "LsDispatch",			0x029, 0x07, true },
    962   1.9  jmcneill 	{ "LsCanStoreToLoadFwOps",	0x02a, 0x03, true },
    963   1.9  jmcneill 	{ "LsSmisReceived",		0x02b, 0x00, true },
    964   1.9  jmcneill 	{ "LsExecClflushInstr",		0x030, 0x00, true },
    965   1.9  jmcneill 	{ "LsMisalignStore",		0x032, 0x00, true },
    966   1.9  jmcneill 	{ "LsFpLoadBufStall",		0x034, 0x00, true },
    967   1.9  jmcneill 	{ "LsStlf",			0x035, 0x00, true },
    968   1.9  jmcneill 	{ "DcCacheAccess",		0x040, 0x00, true },
    969   1.9  jmcneill 	{ "DcCacheMiss",		0x041, 0x00, true },
    970   1.9  jmcneill 	{ "DcCacheFillL2Sys",		0x042, 0x1f, true },
    971   1.9  jmcneill 	{ "DcCacheFillSys",		0x043, 0x00, true },
    972   1.9  jmcneill 	{ "DcUnifiedTlbHit",		0x045, 0x77, true },
    973   1.9  jmcneill 	{ "DcUnifiedTlbMiss",		0x046, 0x77, true },
    974   1.9  jmcneill 	{ "DcMisalignAccess",		0x047, 0x00, true },
    975   1.9  jmcneill 	{ "DcPrefetchInstrDisp",	0x04b, 0x07, true },
    976   1.9  jmcneill 	{ "DcIneffSwPrefetch",		0x052, 0x09, true },
    977   1.9  jmcneill 	{ "CuCmdVictimBuf",		0x060, 0x98, true },
    978   1.9  jmcneill 	{ "CuCmdMaskedOps",		0x061, 0x65, true },
    979   1.9  jmcneill 	{ "CuCmdReadBlkOps",		0x062, 0x77, true },
    980   1.9  jmcneill 	{ "CuCmdChgDirtyOps",		0x063, 0x08, true },
    981   1.9  jmcneill 	{ "CuDramSysReq",		0x064, 0x00, true },
    982   1.9  jmcneill 	{ "CuMemReqByType",		0x065, 0x83, true },
    983   1.9  jmcneill 	{ "CuDataCachePrefetch",	0x067, 0x03, true },
    984   1.9  jmcneill 	{ "CuMabReq",			0x068, 0xff, true },
    985   1.9  jmcneill 	{ "CuMabWaitCyc",		0x069, 0xff, true },
    986   1.9  jmcneill 	{ "CuSysRespCacheFill",		0x06c, 0x3f, true },
    987   1.9  jmcneill 	{ "CuOctwordsWritten",		0x06d, 0x01, true },
    988   1.9  jmcneill 	{ "CuCacheXInv",		0x075, 0x0f, true },
    989   1.9  jmcneill 	{ "CuCpuClkNotHalted",		0x076, 0x00, true },
    990   1.9  jmcneill 	{ "CuL2Req",			0x07d, 0x5f, true },
    991   1.9  jmcneill 	{ "CuL2Miss",			0x07e, 0x17, true },
    992   1.9  jmcneill 	{ "CuL2FillWb",			0x07f, 0x07, true },
    993   1.9  jmcneill 	{ "CuPageSplintering",		0x165, 0x07, true },
    994   1.9  jmcneill 	{ "CuL2PrefetchTrigEv",		0x16c, 0x03, true },
    995   1.9  jmcneill 	{ "CuXabAllocStall",		0x177, 0x03, true },
    996   1.9  jmcneill 	{ "CuFreeXabEntries",		0x17f, 0x01, true },
    997   1.9  jmcneill 	{ "IcCacheFetch",		0x080, 0x00, true },
    998   1.9  jmcneill 	{ "IcCacheMiss",		0x081, 0x00, true },
    999   1.9  jmcneill 	{ "IcCacheFillL2",		0x082, 0x00, true },
   1000   1.9  jmcneill 	{ "IcCacheFillSys",		0x083, 0x00, true },
   1001   1.9  jmcneill 	{ "IcL1TlbMissL2Hit",		0x084, 0x00, true },
   1002   1.9  jmcneill 	{ "IcL1TlbMissL2Miss",		0x085, 0x07, true },
   1003   1.9  jmcneill 	{ "IcPipeRestartInstrStrProbe",	0x086, 0x00, true },
   1004   1.9  jmcneill 	{ "IcFetchStall",		0x087, 0x00, true },
   1005   1.9  jmcneill 	{ "IcRetStackHits",		0x088, 0x00, true },
   1006   1.9  jmcneill 	{ "IcRetStackOver",		0x089, 0x00, true },
   1007   1.9  jmcneill 	{ "IcCacheVictims",		0x08b, 0x00, true },
   1008   1.9  jmcneill 	{ "IcCacheLinesInv",		0x08c, 0x0f, true },
   1009   1.9  jmcneill 	{ "IcTlbReload",		0x099, 0x00, true },
   1010   1.9  jmcneill 	{ "IcTlbReloadAbort",		0x09a, 0x00, true },
   1011   1.9  jmcneill 	{ "IcUopsDispatched",		0x186, 0x01, true },
   1012   1.9  jmcneill 	{ "ExRetInstr",			0x0c0, 0x00, true },
   1013   1.9  jmcneill 	{ "ExRetCops",			0x0c1, 0x00, true },
   1014   1.9  jmcneill 	{ "ExRetBrn",			0x0c2, 0x00, true },
   1015   1.9  jmcneill 	{ "ExRetBrnMisp",		0x0c3, 0x00, true },
   1016   1.9  jmcneill 	{ "ExRetBrnTkn",		0x0c4, 0x00, true },
   1017   1.9  jmcneill 	{ "ExRetBrnTknMisp",		0x0c5, 0x00, true },
   1018   1.9  jmcneill 	{ "ExRetBrnFar",		0x0c6, 0x00, true },
   1019   1.9  jmcneill 	{ "ExRetBrnResync",		0x0c7, 0x00, true },
   1020   1.9  jmcneill 	{ "ExRetNearRet",		0x0c8, 0x00, true },
   1021   1.9  jmcneill 	{ "ExRetNearRetMispred",	0x0c9, 0x00, true },
   1022   1.9  jmcneill 	{ "ExRetBrnIndMisp",		0x0ca, 0x00, true },
   1023   1.9  jmcneill 	{ "ExRetMmxFpInstr@X87",	0x0cb, 0x01, true },
   1024   1.9  jmcneill 	{ "ExRetMmxFpInstr@Mmx",	0x0cb, 0x02, true },
   1025   1.9  jmcneill 	{ "ExRetMmxFpInstr@Sse",	0x0cb, 0x04, true },
   1026   1.9  jmcneill 	{ "ExIntMaskedCyc",		0x0cd, 0x00, true },
   1027   1.9  jmcneill 	{ "ExIntMaskedCycIntPend",	0x0ce, 0x00, true },
   1028   1.9  jmcneill 	{ "ExIntTaken",			0x0cf, 0x00, true },
   1029   1.9  jmcneill 	{ "ExDecEmpty",			0x0d0, 0x00, true },
   1030   1.9  jmcneill 	{ "ExDispStall",		0x0d1, 0x00, true },
   1031   1.9  jmcneill 	{ "ExUseqStallSer",		0x0d2, 0x00, true },
   1032   1.9  jmcneill 	{ "ExDispStallInstrRetQFull",	0x0d5, 0x00, true },
   1033   1.9  jmcneill 	{ "ExDispStallIntSchedQFull",	0x0d6, 0x00, true },
   1034   1.9  jmcneill 	{ "ExDispStallFpSchedQFull",	0x0d7, 0x00, true },
   1035   1.9  jmcneill 	{ "ExDispStallLdqFull",		0x0d8, 0x00, true },
   1036   1.9  jmcneill 	{ "ExUseqStallAllQuiet",	0x0d9, 0x00, true },
   1037   1.9  jmcneill 	{ "ExFpuEx",			0x0db, 0x1f, true },
   1038   1.9  jmcneill 	{ "ExBpDr0",			0x0dc, 0x8f, true },
   1039   1.9  jmcneill 	{ "ExBpDr1",			0x0dd, 0x8f, true },
   1040   1.9  jmcneill 	{ "ExBpDr2",			0x0de, 0x8f, true },
   1041   1.9  jmcneill 	{ "ExBpDr3",			0x0df, 0x8f, true },
   1042   1.9  jmcneill 	{ "ExRetx87FpOps",		0x1c0, 0x07, true },
   1043   1.9  jmcneill 	{ "ExTaggedIbsOps",		0x1cf, 0x07, true },
   1044   1.9  jmcneill 	{ "ExRetFusBrInstr",		0x1d0, 0x00, true },
   1045   1.9  jmcneill 	{ "ExDispStallStqFull",		0x1d8, 0x00, true },
   1046   1.9  jmcneill 	{ "ExCycNoDispIntPrfTok",	0x1dd, 0x00, true },
   1047   1.9  jmcneill 	{ "ExCycNoDispfpPrfTok",	0x1de, 0x00, true },
   1048   1.9  jmcneill 	{ "ExFpDispContention",		0x1df, 0x0f, true },
   1049   1.9  jmcneill };
   1050   1.9  jmcneill 
   1051   1.9  jmcneill static struct event_table amd_f15h = {
   1052   1.9  jmcneill 	.tablename = "AMD Family 15h",
   1053   1.9  jmcneill 	.names = amd_f15h_names,
   1054   1.9  jmcneill 	.nevents = sizeof(amd_f15h_names) /
   1055   1.9  jmcneill 	    sizeof(struct name_to_event),
   1056   1.9  jmcneill 	.next = NULL
   1057   1.9  jmcneill };
   1058   1.9  jmcneill 
   1059   1.9  jmcneill /*
   1060   1.8      maxv  * AMD Family 17h
   1061   1.8      maxv  */
   1062   1.8      maxv static struct name_to_event amd_f17h_names[] = {
   1063   1.8      maxv 	{ "FpRetx87FpOps",		0x02, __BITS(2,0), true },
   1064   1.8      maxv 	{ "FpRetSseAvxOps",		0x03, __BITS(7,0), true },
   1065   1.8      maxv 	{ "FpRetiredSerOps",		0x05, __BITS(3,0), true },
   1066   1.8      maxv 	{ "LsL1DTlbMiss",		0x45, __BITS(7,0), true },
   1067   1.8      maxv 	{ "LsTableWalker",		0x46, __BITS(3,0), true },
   1068   1.8      maxv 	{ "LsMisalAccesses",		0x47, 0x00, true },
   1069   1.8      maxv 	{ "LsInefSwPref",		0x52, __BITS(1,0), true },
   1070   1.8      maxv 	{ "LsNotHaltedCyc",		0x76, 0x00, true },
   1071   1.8      maxv 	{ "IcFw32",			0x80, 0x00, true },
   1072   1.8      maxv 	{ "IcFw32Miss",			0x81, 0x00, true },
   1073   1.8      maxv 	{ "IcCacheFillL2",		0x82, 0x00, true },
   1074   1.8      maxv 	{ "IcCacheFillSys",		0x83, 0x00, true },
   1075   1.8      maxv 	{ "IcFetchStall",		0x87, __BITS(2,0), true },
   1076  1.14   msaitoh 	{ "IcCacheInval",		0x8c, __BITS(1,0), true },
   1077   1.8      maxv 	{ "BpL1TlbMissL2Hit",		0x84, 0x00, true },
   1078   1.8      maxv 	{ "BpL1TlbMissL2Miss",		0x85, 0x00, true },
   1079   1.8      maxv 	{ "BpSnpReSync",		0x86, 0x00, true },
   1080  1.14   msaitoh 	{ "BpL1BTBCorrect",		0x8a, 0x00, true },
   1081  1.14   msaitoh 	{ "BpL2BTBCorrect",		0x8b, 0x00, true },
   1082   1.8      maxv 	{ "BpTlbRel",			0x99, 0x00, true },
   1083  1.14   msaitoh 	{ "ExRetInstr",			0xc0, 0x00, true },
   1084  1.14   msaitoh 	{ "ExRetCops",			0xc1, 0x00, true },
   1085  1.14   msaitoh 	{ "ExRetBrn",			0xc2, 0x00, true },
   1086  1.14   msaitoh 	{ "ExRetBrnMisp",		0xc3, 0x00, true },
   1087  1.14   msaitoh 	{ "ExRetBrnTkn",		0xc4, 0x00, true },
   1088  1.14   msaitoh 	{ "ExRetBrnTknMisp",		0xc5, 0x00, true },
   1089  1.14   msaitoh 	{ "ExRetBrnFar",		0xc6, 0x00, true },
   1090  1.14   msaitoh 	{ "ExRetBrnResync",		0xc7, 0x00, true },
   1091  1.14   msaitoh 	{ "ExRetBrnIndMisp",		0xca, 0x00, true },
   1092  1.14   msaitoh 	{ "ExRetNearRet",		0xc8, 0x00, true },
   1093  1.14   msaitoh 	{ "ExRetNearRetMispred",	0xc9, 0x00, true },
   1094  1.14   msaitoh 	{ "ExRetMmxFpInstr@X87",	0xcb, __BIT(0), true },
   1095  1.14   msaitoh 	{ "ExRetMmxFpInstr@Mmx",	0xcb, __BIT(1), true },
   1096  1.14   msaitoh 	{ "ExRetMmxFpInstr@Sse",	0xcb, __BIT(2), true },
   1097  1.14   msaitoh 	{ "ExRetCond",			0xd1, 0x00, true },
   1098  1.14   msaitoh 	{ "ExRetCondMisp",		0xd2, 0x00, true },
   1099  1.14   msaitoh 	{ "ExDivBusy",			0xd3, 0x00, true },
   1100  1.14   msaitoh 	{ "ExDivCount",			0xd4, 0x00, true },
   1101   1.8      maxv };
   1102   1.8      maxv 
   1103   1.8      maxv static struct event_table amd_f17h = {
   1104   1.8      maxv 	.tablename = "AMD Family 17h",
   1105   1.8      maxv 	.names = amd_f17h_names,
   1106   1.8      maxv 	.nevents = sizeof(amd_f17h_names) /
   1107   1.8      maxv 	    sizeof(struct name_to_event),
   1108   1.8      maxv 	.next = NULL
   1109   1.8      maxv };
   1110   1.1      maxv 
   1111  1.15   msaitoh /*
   1112  1.15   msaitoh  * AMD Family 19h
   1113  1.15   msaitoh  * From PPR:
   1114  1.15   msaitoh  *	- f19h model 01h B1 (zen3)
   1115  1.15   msaitoh  *	- f19h model 11h B1 (zen4)
   1116  1.15   msaitoh  *	- f19h model 21h B1 (zen3)
   1117  1.15   msaitoh  *	- f19h model 51h A1 (zen3)
   1118  1.15   msaitoh  */
   1119  1.15   msaitoh static struct name_to_event amd_f19h_names[] = {
   1120  1.15   msaitoh 	/* Model 1x only */
   1121  1.15   msaitoh 	{ "FpRetx87FpOps",			0x02, __BITS(2,0), true },
   1122  1.15   msaitoh 
   1123  1.15   msaitoh 	/* Only model 1x has bit 4 */
   1124  1.15   msaitoh 	{ "FpRetSseAvxOps",			0x03, __BITS(4,0), true },
   1125  1.15   msaitoh 
   1126  1.15   msaitoh 	{ "FpRetiredSerOps",			0x05, __BITS(3,0), true },
   1127  1.15   msaitoh 
   1128  1.15   msaitoh 	/* Model 1x only */
   1129  1.15   msaitoh 	{ "FpOpsRetiredByWidth",		0x08, __BITS(5,0), true },
   1130  1.15   msaitoh 	{ "FpOpsRetiredByType",			0x0a, __BITS(7,0), true },
   1131  1.15   msaitoh 	{ "SseAvxOpsRetired",			0x0b, __BITS(7,0), true },
   1132  1.15   msaitoh 	{ "FpPackOpsRetired",			0x0c, __BITS(7,0), true },
   1133  1.15   msaitoh 	{ "PackedIntOpType",			0x0d, __BITS(7,0), true },
   1134  1.15   msaitoh 
   1135  1.15   msaitoh 	{ "FpDispFaults",			0x0e, __BITS(3,0), true },
   1136  1.15   msaitoh 	{ "LsBadStatus2",			0x24, __BIT(1),	true },
   1137  1.15   msaitoh 	{ "LsLocks",				0x25, __BIT(0), true },
   1138  1.15   msaitoh 	{ "LsRetClClush",			0x26, 0x00, true },
   1139  1.15   msaitoh 	{ "LsRetCpuid",				0x27, 0x00, true },
   1140  1.15   msaitoh 	{ "LsDispatch",				0x29, __BITS(2,0), true },
   1141  1.15   msaitoh 	{ "LsSmiRx",				0x2b, 0x00, true },
   1142  1.15   msaitoh 	{ "LsIntTaken",				0x2c, 0x00, true },
   1143  1.15   msaitoh 	{ "LsSTLF",				0x35, 0x00, true },
   1144  1.15   msaitoh 	{ "LsStCommitCancel2",			0x37, __BIT(0), true },
   1145  1.15   msaitoh 	{ "LsMabAlloc-ls",			0x41, 0x3f, true },
   1146  1.15   msaitoh 	{ "LsMabAlloc-hp",			0x41, 0x40, true },
   1147  1.15   msaitoh 	{ "LsMabAlloc-all",			0x41, 0x7f, true },
   1148  1.15   msaitoh 	{ "LsDmndFillsFromSys",			0x43, 0x5f, true },
   1149  1.15   msaitoh 
   1150  1.15   msaitoh 	/* Only model 1x has bit 7 */
   1151  1.15   msaitoh 	{ "LsAnyFillsFromSys",			0x44, 0xdf, true },
   1152  1.15   msaitoh 
   1153  1.15   msaitoh 	{ "LsL1DTlbMiss",			0x45, __BITS(7,0), true },
   1154  1.15   msaitoh 	{ "LsMisalLoads-MA64",			0x47, __BIT(0), true },
   1155  1.15   msaitoh 	{ "LsMisalLoads-MA4K",			0x47, __BIT(1), true },
   1156  1.15   msaitoh 	{ "LsMisalLoads-all",			0x47, __BITS(1,0), true },
   1157  1.15   msaitoh 	{ "LsPrefInstrDisp",			0x4b, __BITS(2,0), true },
   1158  1.15   msaitoh 	{ "LsInefSwPref",			0x52, __BITS(1,0), true },
   1159  1.15   msaitoh 
   1160  1.15   msaitoh 	/* Only model 1x has bit 7 */
   1161  1.15   msaitoh 	{ "LsSwPfDcFills",			0x59, 0xdf, true },
   1162  1.15   msaitoh 	{ "LsHwPfDcFills",			0x5a, 0xdf, true },
   1163  1.15   msaitoh 
   1164  1.15   msaitoh 	{ "LsAllocMabCount",			0x5f, 0x00, true },
   1165  1.15   msaitoh 	{ "LsNotHaltedCyc",			0x76, 0x00, true },
   1166  1.15   msaitoh 
   1167  1.15   msaitoh 	/* Model 0x, 1x and 2x only */
   1168  1.15   msaitoh 	{ "LsTlbFlush",				0x78, 0xff, true },
   1169  1.15   msaitoh 
   1170  1.15   msaitoh 	/* Model 1x only */
   1171  1.15   msaitoh 	{ "LsNotHaltedP0Cyc",			0x120, __BIT(0), true },
   1172  1.15   msaitoh 
   1173  1.15   msaitoh 	{ "IcCacheFillL2",			0x82, 0x00, true },
   1174  1.15   msaitoh 	{ "IcCacheFillSys",			0x83, 0x00, true },
   1175  1.15   msaitoh 	{ "BpL1TlbMissL2TlbHit",		0x84, 0x00, true },
   1176  1.15   msaitoh 	{ "BpL1TlbMissL2TlbMiss-IF4K",		0x85, __BIT(0), true },
   1177  1.15   msaitoh 	{ "BpL1TlbMissL2TlbMiss-IF2M",		0x85, __BIT(1), true },
   1178  1.15   msaitoh 	{ "BpL1TlbMissL2TlbMiss-IF1G",		0x85, __BIT(2), true },
   1179  1.15   msaitoh 	{ "BpL1TlbMissL2TlbMiss-Coalesced4K",	0x85, __BIT(3), true },
   1180  1.15   msaitoh 	{ "BpL1TlbMissL2TlbMiss-all",		0x85, __BITS(3,0), true },
   1181  1.15   msaitoh 
   1182  1.15   msaitoh 	{ "BpL2BTBCorrect",			0x8b, 0x00, true },
   1183  1.15   msaitoh 	{ "BpDynIndPred",			0x8e, 0x00, true },
   1184  1.15   msaitoh 	{ "BpDeReDirect",			0x91, 0x00, true },
   1185  1.15   msaitoh 	{ "BpL1TlbFetchHit-IF4K",		0x94, __BIT(0), true },
   1186  1.15   msaitoh 	{ "BpL1TlbFetchHit-IF2M",		0x94, __BIT(1), true },
   1187  1.15   msaitoh 	{ "BpL1TlbFetchHit-IF1G",		0x94, __BIT(2), true },
   1188  1.15   msaitoh 	{ "BpL1TlbFetchHit-all",		0x94, __BITS(2,0), true },
   1189  1.15   msaitoh 
   1190  1.15   msaitoh 	/* Model 1x only */
   1191  1.15   msaitoh 	{ "ResyncsOrNcRedirects",		0x96, 0x00, true },
   1192  1.15   msaitoh 
   1193  1.15   msaitoh 	{ "IcTagHitMiss-hit",			0x18e, 0x07, true },
   1194  1.15   msaitoh 	{ "IcTagHitMiss-miss",			0x18e, 0x18, true },
   1195  1.15   msaitoh 	{ "IcTagHitMiss-all",			0x18e, 0x1f, true },
   1196  1.15   msaitoh 	{ "OpCacheHitMiss-hit",			0x28f, 0x03, true },
   1197  1.15   msaitoh 	{ "OpCacheHitMiss-miss",		0x28f, 0x04, true },
   1198  1.15   msaitoh 	{ "OpCacheHitMiss-all",			0x28f, 0x07, true },
   1199  1.15   msaitoh 	{ "DeOpQueueEmpty",			0xa9, 0x00, true },
   1200  1.15   msaitoh 
   1201  1.15   msaitoh 	/*
   1202  1.15   msaitoh 	 * Model 0x and 1x only.
   1203  1.15   msaitoh 	 * Only model 1x has bit 2.
   1204  1.15   msaitoh 	 */
   1205  1.15   msaitoh 	{ "DeSrcOpDisp",			0xaa, __BITS(2,0), true },
   1206  1.15   msaitoh 
   1207  1.15   msaitoh 	{ "DeDisOpsFromDecoder-Fp-Ibs",		0xab, 0x04, true },
   1208  1.15   msaitoh 	{ "DeDisOpsFromDecoder-Int-Ibs",	0xab, 0x08, true },
   1209  1.15   msaitoh 
   1210  1.15   msaitoh 	/* Model 0x, 2x and newer */
   1211  1.15   msaitoh 	{ "DeDisOpsFromDecoder-Fp-Ret",		0xab, 0x84, true },
   1212  1.15   msaitoh 	{ "DeDisOpsFromDecoder-Int-Ret",	0xab, 0x88, true },
   1213  1.15   msaitoh 
   1214  1.15   msaitoh 	{ "DeDisDispatchTokenStalls1",		0xae, 0xf7, true },
   1215  1.15   msaitoh 	{ "DeDisDispatchTokenStalls2",		0xaf, 0x2f, true },
   1216  1.15   msaitoh 
   1217  1.15   msaitoh 	/* Model 1x only */
   1218  1.15   msaitoh 	{ "DeNoDispatchPerSolt-empty",		0x1a0, 0x01, true },
   1219  1.15   msaitoh 	{ "DeNoDispatchPerSolt-backend",	0x1a0, 0x1e, true },
   1220  1.15   msaitoh 	{ "DeNoDispatchPerSolt-otherSMT",	0x1a0, 0x60, true },
   1221  1.15   msaitoh 	{ "DeAdditionalResourceStalls",		0x1a2, 0x30, true },
   1222  1.15   msaitoh 
   1223  1.15   msaitoh 	{ "ExRetInstr",				0xc0, 0x00, true },
   1224  1.15   msaitoh 	{ "ExRetCops",				0xc1, 0x00, true },
   1225  1.15   msaitoh 	{ "ExRetBrn",				0xc2, 0x00, true },
   1226  1.15   msaitoh 	{ "ExRetBrnMisp",			0xc3, 0x00, true },
   1227  1.15   msaitoh 	{ "ExRetBrnTkn",			0xc4, 0x00, true },
   1228  1.15   msaitoh 	{ "ExRetBrnTknMisp",			0xc5, 0x00, true },
   1229  1.15   msaitoh 	{ "ExRetBrnFar",			0xc6, 0x00, true },
   1230  1.15   msaitoh 	{ "ExRetBrnIndMisp",			0xca, 0x00, true },
   1231  1.15   msaitoh 	{ "ExRetNearRet",			0xc8, 0x00, true },
   1232  1.15   msaitoh 	{ "ExRetNearRetMispred",		0xc9, 0x00, true },
   1233  1.15   msaitoh 	{ "ExRetMmxFpInstr@X87",		0xcb, __BIT(0), true },
   1234  1.15   msaitoh 	{ "ExRetMmxFpInstr@Mmx",		0xcb, __BIT(1), true },
   1235  1.15   msaitoh 	{ "ExRetMmxFpInstr@Sse",		0xcb, __BIT(2), true },
   1236  1.15   msaitoh 	{ "ExRetIndBrchInstr",			0xcc, 0x00, true },
   1237  1.15   msaitoh 	{ "ExRetCond",				0xd1, 0x00, true },
   1238  1.15   msaitoh 	{ "ExDivBusy",				0xd3, 0x00, true },
   1239  1.15   msaitoh 	{ "ExDivCount",				0xd4, 0x00, true },
   1240  1.15   msaitoh 
   1241  1.15   msaitoh 	/* Model 1x only */
   1242  1.15   msaitoh 	{ "ExDivCount-LoadAndALU",		0xd6, 0x1f, true },
   1243  1.15   msaitoh 	{ "ExDivCount-Load",			0xd6, 0xbf, true },
   1244  1.15   msaitoh 	{ "ExRetUcodeInstr",			0x1c1, 0x00, true },
   1245  1.15   msaitoh 	{ "ExRetUcodeOps",			0x1c2, 0x00, true },
   1246  1.15   msaitoh 
   1247  1.15   msaitoh 	{ "ExRetMsprdBrnchInstrDirMsmtch",	0x1c7, 0x00, true },
   1248  1.15   msaitoh 
   1249  1.15   msaitoh 	/* Model 1x only */
   1250  1.15   msaitoh 	{ "ExRetUncondBrnchInstrMspred",	0x1c8, 0x00, true },
   1251  1.15   msaitoh 	{ "ExRetUncondBrnchInstr",		0x1c8, 0x00, true },
   1252  1.15   msaitoh 
   1253  1.15   msaitoh 	{ "ExTaggedIbsOps",			0x1cf, __BITS(2,0), true },
   1254  1.15   msaitoh 	{ "ExRetFusedInstr",			0x1d0, 0x00, true },
   1255  1.15   msaitoh 
   1256  1.15   msaitoh 	/* Only model 1x has bit 0 */
   1257  1.15   msaitoh 	{ "L2RequestG1",			0x60, __BITS(7,1), true },
   1258  1.15   msaitoh 
   1259  1.15   msaitoh 	{ "L2CacheReqStart",			0x64, __BITS(7,0), true },
   1260  1.15   msaitoh 	{ "L2PfHitL2-L2",			0x70, __BITS(4,0), true },
   1261  1.15   msaitoh 	{ "L2PfHitL2-L1",			0x70, __BITS(7,5), true },
   1262  1.15   msaitoh 	{ "L2PfHitL2-all",			0x70, __BITS(7,0), true },
   1263  1.15   msaitoh 	{ "L2PfMissL2HitL3-L2",			0x71, __BITS(4,0), true },
   1264  1.15   msaitoh 	{ "L2PfMissL2HitL3-L1",			0x71, __BITS(7,5), true },
   1265  1.15   msaitoh 	{ "L2PfMIssL2HitL3-all",		0x71, __BITS(7,0), true },
   1266  1.15   msaitoh 	{ "L2PfMissL2L3-L2",			0x72, __BITS(4,0), true },
   1267  1.15   msaitoh 	{ "L2PfMissL2L3-L1",			0x72, __BITS(7,5), true },
   1268  1.15   msaitoh 	{ "L2PfMIssL2L3-all",			0x72, __BITS(7,0), true },
   1269  1.15   msaitoh 
   1270  1.15   msaitoh 	{ "L3LookupState-L3Miss",		0x04, __BIT(0), true },
   1271  1.15   msaitoh 	{ "L3LookupState-L3Hit",		0x04, __BITS(7,1), true },
   1272  1.15   msaitoh 	{ "L3LookupState-all",			0x04, __BITS(7,0), true },
   1273  1.15   msaitoh 
   1274  1.15   msaitoh 	/* Model 0x, 2x and newer */
   1275  1.15   msaitoh 	{ "XiSysFillLatency",			0x90, 0x00, true },
   1276  1.15   msaitoh 	{ "XiCcxSdpReq1",			0x9a, 0x00, true },
   1277  1.15   msaitoh 
   1278  1.15   msaitoh 	/* Model 1x only */
   1279  1.15   msaitoh 	{ "XiSampledLatency",			0xac, 0x00, true },
   1280  1.15   msaitoh 	{ "XiSampledLatencyRequests",		0xad, 0x00, true },
   1281  1.15   msaitoh };
   1282  1.15   msaitoh 
   1283  1.15   msaitoh static struct event_table amd_f19h = {
   1284  1.15   msaitoh 	.tablename = "AMD Family 19h",
   1285  1.15   msaitoh 	.names = amd_f19h_names,
   1286  1.15   msaitoh 	.nevents = sizeof(amd_f19h_names) /
   1287  1.15   msaitoh 	    sizeof(struct name_to_event),
   1288  1.15   msaitoh 	.next = NULL
   1289  1.15   msaitoh };
   1290  1.15   msaitoh 
   1291   1.1      maxv static struct event_table *
   1292   1.1      maxv init_amd_generic(void)
   1293   1.1      maxv {
   1294   1.1      maxv 	unsigned int eax, ebx, ecx, edx;
   1295   1.1      maxv 
   1296   1.1      maxv 	eax = 0x01;
   1297   1.1      maxv 	ebx = 0;
   1298   1.1      maxv 	ecx = 0;
   1299   1.1      maxv 	edx = 0;
   1300   1.1      maxv 	x86_cpuid(&eax, &ebx, &ecx, &edx);
   1301   1.1      maxv 
   1302   1.1      maxv 	switch (CPUID_TO_FAMILY(eax)) {
   1303   1.1      maxv 	case 0x10:
   1304   1.8      maxv 		return &amd_f10h;
   1305   1.9  jmcneill 	case 0x15:
   1306   1.9  jmcneill 		return &amd_f15h;
   1307   1.8      maxv 	case 0x17:
   1308   1.8      maxv 		return &amd_f17h;
   1309  1.15   msaitoh 	case 0x19:
   1310  1.15   msaitoh 		return &amd_f19h;
   1311   1.1      maxv 	}
   1312   1.1      maxv 
   1313   1.1      maxv 	return NULL;
   1314   1.1      maxv }
   1315   1.1      maxv 
   1316  1.13   msaitoh /* ------------------------------------------------------------------------- */
   1317   1.1      maxv 
   1318   1.1      maxv int
   1319   1.1      maxv tprof_event_init(uint32_t ident)
   1320   1.1      maxv {
   1321  1.13   msaitoh 
   1322   1.1      maxv 	switch (ident) {
   1323   1.1      maxv 	case TPROF_IDENT_NONE:
   1324   1.1      maxv 		return -1;
   1325   1.1      maxv 	case TPROF_IDENT_INTEL_GENERIC:
   1326   1.1      maxv 		cpuevents = init_intel_generic();
   1327   1.1      maxv 		break;
   1328   1.1      maxv 	case TPROF_IDENT_AMD_GENERIC:
   1329   1.1      maxv 		cpuevents = init_amd_generic();
   1330   1.1      maxv 		break;
   1331   1.1      maxv 	}
   1332   1.1      maxv 	return (cpuevents == NULL) ? -1 : 0;
   1333   1.1      maxv }
   1334   1.1      maxv 
   1335   1.1      maxv static void
   1336   1.1      maxv recursive_event_list(struct event_table *table)
   1337   1.1      maxv {
   1338   1.1      maxv 	size_t i;
   1339   1.1      maxv 
   1340   1.1      maxv 	printf("%s:\n", table->tablename);
   1341   1.1      maxv 	for (i = 0; i < table->nevents; i++) {
   1342   1.1      maxv 		if (!table->names[i].enabled)
   1343   1.1      maxv 			continue;
   1344   1.1      maxv 		printf("\t%s\n", table->names[i].name);
   1345   1.1      maxv 	}
   1346   1.1      maxv 
   1347  1.13   msaitoh 	if (table->next != NULL)
   1348   1.1      maxv 		recursive_event_list(table->next);
   1349   1.1      maxv }
   1350   1.1      maxv 
   1351   1.1      maxv void
   1352   1.1      maxv tprof_event_list(void)
   1353   1.1      maxv {
   1354  1.13   msaitoh 
   1355   1.1      maxv 	recursive_event_list(cpuevents);
   1356   1.1      maxv }
   1357   1.1      maxv 
   1358   1.1      maxv static void
   1359   1.1      maxv recursive_event_lookup(struct event_table *table, const char *name,
   1360   1.1      maxv     struct tprof_param *param)
   1361   1.1      maxv {
   1362   1.1      maxv 	size_t i;
   1363   1.1      maxv 
   1364   1.1      maxv 	for (i = 0; i < table->nevents; i++) {
   1365   1.1      maxv 		if (!table->names[i].enabled)
   1366   1.1      maxv 			continue;
   1367   1.1      maxv 		if (!strcmp(table->names[i].name, name)) {
   1368   1.1      maxv 			param->p_event = table->names[i].event;
   1369   1.1      maxv 			param->p_unit = table->names[i].unit;
   1370   1.1      maxv 			return;
   1371   1.1      maxv 		}
   1372   1.1      maxv 	}
   1373   1.1      maxv 
   1374  1.13   msaitoh 	if (table->next != NULL)
   1375   1.1      maxv 		recursive_event_lookup(table->next, name, param);
   1376  1.13   msaitoh 	else
   1377   1.1      maxv 		errx(EXIT_FAILURE, "event '%s' unknown", name);
   1378   1.1      maxv }
   1379   1.1      maxv 
   1380   1.1      maxv void
   1381   1.1      maxv tprof_event_lookup(const char *name, struct tprof_param *param)
   1382   1.1      maxv {
   1383  1.13   msaitoh 
   1384   1.1      maxv 	recursive_event_lookup(cpuevents, name, param);
   1385   1.1      maxv }
   1386