1*db06c1e0Smsaitoh /* $NetBSD: tprof_x86.c,v 1.19 2023/07/07 04:43:15 msaitoh Exp $ */
2a087cb3cSmaxv
3a087cb3cSmaxv /*
40acc4e3eSmaxv * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
5a087cb3cSmaxv * All rights reserved.
6a087cb3cSmaxv *
7a087cb3cSmaxv * This code is derived from software contributed to The NetBSD Foundation
8a087cb3cSmaxv * by Maxime Villard.
9a087cb3cSmaxv *
10a087cb3cSmaxv * Redistribution and use in source and binary forms, with or without
11a087cb3cSmaxv * modification, are permitted provided that the following conditions
12a087cb3cSmaxv * are met:
13a087cb3cSmaxv * 1. Redistributions of source code must retain the above copyright
14a087cb3cSmaxv * notice, this list of conditions and the following disclaimer.
15a087cb3cSmaxv * 2. Redistributions in binary form must reproduce the above copyright
16a087cb3cSmaxv * notice, this list of conditions and the following disclaimer in the
17a087cb3cSmaxv * documentation and/or other materials provided with the distribution.
18a087cb3cSmaxv *
19a087cb3cSmaxv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20a087cb3cSmaxv * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21a087cb3cSmaxv * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22a087cb3cSmaxv * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23a087cb3cSmaxv * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24a087cb3cSmaxv * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25a087cb3cSmaxv * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26a087cb3cSmaxv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27a087cb3cSmaxv * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28a087cb3cSmaxv * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29a087cb3cSmaxv * POSSIBILITY OF SUCH DAMAGE.
30a087cb3cSmaxv */
31a087cb3cSmaxv
32a087cb3cSmaxv #include <sys/cdefs.h>
33a087cb3cSmaxv #include <stdio.h>
34a087cb3cSmaxv #include <stdlib.h>
35a087cb3cSmaxv #include <stdbool.h>
36a087cb3cSmaxv #include <string.h>
37a087cb3cSmaxv #include <unistd.h>
38a087cb3cSmaxv #include <err.h>
39a087cb3cSmaxv #include <machine/specialreg.h>
40a087cb3cSmaxv #include <dev/tprof/tprof_ioctl.h>
41a087cb3cSmaxv #include "../tprof.h"
42a087cb3cSmaxv
43a087cb3cSmaxv int tprof_event_init(uint32_t);
44a087cb3cSmaxv void tprof_event_list(void);
45a087cb3cSmaxv void tprof_event_lookup(const char *, struct tprof_param *);
46a087cb3cSmaxv
47a087cb3cSmaxv struct name_to_event {
48a087cb3cSmaxv const char *name;
49a087cb3cSmaxv uint64_t event;
50a087cb3cSmaxv uint64_t unit;
51a087cb3cSmaxv bool enabled;
52a087cb3cSmaxv };
53a087cb3cSmaxv
54a087cb3cSmaxv struct event_table {
55a087cb3cSmaxv const char *tablename;
56a087cb3cSmaxv struct name_to_event *names;
57a087cb3cSmaxv size_t nevents;
58a087cb3cSmaxv struct event_table *next;
59a087cb3cSmaxv };
60a087cb3cSmaxv
61a087cb3cSmaxv static struct event_table *cpuevents = NULL;
62a087cb3cSmaxv
63e2b25c5dSmsaitoh static void
x86_cpuid(unsigned int * eax,unsigned int * ebx,unsigned int * ecx,unsigned int * edx)64e2b25c5dSmsaitoh x86_cpuid(unsigned int *eax, unsigned int *ebx,
65a087cb3cSmaxv unsigned int *ecx, unsigned int *edx)
66a087cb3cSmaxv {
67a087cb3cSmaxv asm volatile("cpuid"
68a087cb3cSmaxv : "=a" (*eax),
69a087cb3cSmaxv "=b" (*ebx),
70a087cb3cSmaxv "=c" (*ecx),
71a087cb3cSmaxv "=d" (*edx)
72a087cb3cSmaxv : "0" (*eax), "2" (*ecx));
73a087cb3cSmaxv }
74a087cb3cSmaxv
75f5823b20Smsaitoh /* ------------------------------------------------------------------------- */
76a087cb3cSmaxv
77a087cb3cSmaxv /*
78a087cb3cSmaxv * Intel Architectural Version 1.
79a087cb3cSmaxv */
80a087cb3cSmaxv static struct name_to_event intel_arch1_names[] = {
81a087cb3cSmaxv /* Event Name - Event Select - UMask */
82f1f580f5Smsaitoh { "unhalted-core-cycles", 0x3c, 0x00, true },
83f1f580f5Smsaitoh { "instruction-retired", 0xc0, 0x00, true },
84f1f580f5Smsaitoh { "unhalted-reference-cycles", 0x3c, 0x01, true },
85f1f580f5Smsaitoh { "llc-reference", 0x2e, 0x4f, true },
86f1f580f5Smsaitoh { "llc-misses", 0x2e, 0x41, true },
87f1f580f5Smsaitoh { "branch-instruction-retired", 0xc4, 0x00, true },
88f1f580f5Smsaitoh { "branch-misses-retired", 0xc5, 0x00, true },
89f1f580f5Smsaitoh { "topdown-slots", 0xa4, 0x01, true },
90a087cb3cSmaxv };
91a087cb3cSmaxv
92a087cb3cSmaxv static struct event_table intel_arch1 = {
93a087cb3cSmaxv .tablename = "Intel Architectural Version 1",
94a087cb3cSmaxv .names = intel_arch1_names,
95a087cb3cSmaxv .nevents = sizeof(intel_arch1_names) /
96a087cb3cSmaxv sizeof(struct name_to_event),
97a087cb3cSmaxv .next = NULL
98a087cb3cSmaxv };
99a087cb3cSmaxv
100a087cb3cSmaxv static struct event_table *
init_intel_arch1(void)101a087cb3cSmaxv init_intel_arch1(void)
102a087cb3cSmaxv {
103052df59bSmsaitoh unsigned int eax, ebx, ecx, edx, vectorlen;
104a087cb3cSmaxv struct event_table *table;
105a087cb3cSmaxv size_t i;
106a087cb3cSmaxv
107f1f580f5Smsaitoh eax = 0x0a;
108a087cb3cSmaxv ebx = 0;
109a087cb3cSmaxv ecx = 0;
110a087cb3cSmaxv edx = 0;
111a087cb3cSmaxv x86_cpuid(&eax, &ebx, &ecx, &edx);
112a087cb3cSmaxv
113052df59bSmsaitoh vectorlen = __SHIFTOUT(eax, CPUID_PERF_BVECLEN);
114052df59bSmsaitoh
115a087cb3cSmaxv table = &intel_arch1;
116a087cb3cSmaxv for (i = 0; i < table->nevents; i++) {
117052df59bSmsaitoh /*
118052df59bSmsaitoh * Disable the unsupported events from:
119052df59bSmsaitoh * a) the bit vector length in EAX.
120052df59bSmsaitoh * b) the disable bit in EBX.
121052df59bSmsaitoh */
122052df59bSmsaitoh if (i >= vectorlen)
123052df59bSmsaitoh table->names[i].enabled = false;
124a087cb3cSmaxv if ((ebx & (i << 1)) != 0)
125a087cb3cSmaxv table->names[i].enabled = false;
126a087cb3cSmaxv }
127a087cb3cSmaxv
128a087cb3cSmaxv return table;
129a087cb3cSmaxv }
130a087cb3cSmaxv
131a087cb3cSmaxv /*
132a8700cbeSknakahara * Intel Silvermont/Airmont.
133a8700cbeSknakahara */
134a8700cbeSknakahara static struct name_to_event intel_silvermont_airmont_names[] = {
135a8700cbeSknakahara { "REHABQ.LD_BLOCK_ST_FORWARD", 0x03, 0x01, true },
136a8700cbeSknakahara { "REHABQ.LD_BLOCK_STD_NOTREADY", 0x03, 0x02, true },
137a8700cbeSknakahara { "REHABQ.ST_SPLITS", 0x03, 0x04, true },
138a8700cbeSknakahara { "REHABQ.LD_SPLITS", 0x03, 0x08, true },
139a8700cbeSknakahara { "REHABQ.LOCK", 0x03, 0x10, true },
140a8700cbeSknakahara { "REHABQ.STA_FULL", 0x03, 0x20, true },
141a8700cbeSknakahara { "REHABQ.ANY_LD", 0x03, 0x40, true },
142a8700cbeSknakahara { "REHABQ.ANY_ST", 0x03, 0x80, true },
143a8700cbeSknakahara { "MEM_UOPS_RETIRED.L1_MISS_LOADS", 0x04, 0x01, true },
144a8700cbeSknakahara { "MEM_UOPS_RETIRED.L2_HIT_LOADS", 0x04, 0x02, true },
145a8700cbeSknakahara { "MEM_UOPS_RETIRED.L2_MISS_LOADS", 0x04, 0x04, true },
146a8700cbeSknakahara { "MEM_UOPS_RETIRED.DTLB_MISS_LOADS", 0x04, 0x08, true },
147a8700cbeSknakahara { "MEM_UOPS_RETIRED.UTLB_MISS", 0x04, 0x10, true },
148a8700cbeSknakahara { "MEM_UOPS_RETIRED.HITM", 0x04, 0x20, true },
149a8700cbeSknakahara { "MEM_UOPS_RETIRED.ALL_LOADS", 0x04, 0x40, true },
150a8700cbeSknakahara { "MEM_UOP_RETIRED.ALL_STORES", 0x04, 0x80, true },
151a8700cbeSknakahara { "PAGE_WALKS.D_SIDE_CYCLES", 0x05, 0x01, true },
152a8700cbeSknakahara { "PAGE_WALKS.I_SIDE_CYCLES", 0x05, 0x02, true },
153a8700cbeSknakahara { "PAGE_WALKS.WALKS", 0x05, 0x03, true },
154f1f580f5Smsaitoh { "LONGEST_LAT_CACHE.MISS", 0x2e, 0x41, true },
155f1f580f5Smsaitoh { "LONGEST_LAT_CACHE.REFERENCE", 0x2e, 0x4f, true },
156a8700cbeSknakahara { "L2_REJECT_XQ.ALL", 0x30, 0x00, true },
157a8700cbeSknakahara { "CORE_REJECT_L2Q.ALL", 0x31, 0x00, true },
158f1f580f5Smsaitoh { "CPU_CLK_UNHALTED.CORE_P", 0x3c, 0x00, true },
159f1f580f5Smsaitoh { "CPU_CLK_UNHALTED.REF_P", 0x3c, 0x01, true },
160a8700cbeSknakahara { "ICACHE.HIT", 0x80, 0x01, true },
161a8700cbeSknakahara { "ICACHE.MISSES", 0x80, 0x02, true },
162a8700cbeSknakahara { "ICACHE.ACCESSES", 0x80, 0x03, true },
163f1f580f5Smsaitoh { "OFFCORE_RESPONSE_0", 0xb7, 0x01, true },
164f1f580f5Smsaitoh { "OFFCORE_RESPONSE_1", 0xb7, 0x02, true },
165f1f580f5Smsaitoh { "INST_RETIRED.ANY_P", 0xc0, 0x00, true },
166f1f580f5Smsaitoh { "UOPS_RETIRED.MS", 0xc2, 0x01, true },
167f1f580f5Smsaitoh { "UOPS_RETIRED.ALL", 0xc2, 0x10, true },
168f1f580f5Smsaitoh { "MACHINE_CLEARS.SMC", 0xc3, 0x01, true },
169f1f580f5Smsaitoh { "MACHINE_CLEARS.MEMORY_ORDERING", 0xc3, 0x02, true },
170f1f580f5Smsaitoh { "MACHINE_CLEARS.FP_ASSIST", 0xc3, 0x04, true },
171f1f580f5Smsaitoh { "MACHINE_CLEARS.ALL", 0xc3, 0x08, true },
172f1f580f5Smsaitoh { "BR_INST_RETIRED.ALL_BRANCHES", 0xc4, 0x00, true },
173f1f580f5Smsaitoh { "BR_INST_RETIRED.JCC", 0xc4, 0x7e, true },
174f1f580f5Smsaitoh { "BR_INST_RETIRED.FAR_BRANCH", 0xc4, 0xbf, true },
175f1f580f5Smsaitoh { "BR_INST_RETIRED.NON_RETURN_IND", 0xc4, 0xeb, true },
176f1f580f5Smsaitoh { "BR_INST_RETIRED.RETURN", 0xc4, 0xf7, true },
177f1f580f5Smsaitoh { "BR_INST_RETIRED.CALL", 0xc4, 0xf9, true },
178f1f580f5Smsaitoh { "BR_INST_RETIRED.IND_CALL", 0xc4, 0xfb, true },
179f1f580f5Smsaitoh { "BR_INST_RETIRED.REL_CALL", 0xc4, 0xfd, true },
180f1f580f5Smsaitoh { "BR_INST_RETIRED.TAKEN_JCC", 0xc4, 0xfe, true },
181f1f580f5Smsaitoh { "BR_MISP_RETIRED.ALL_BRANCHES", 0xc5, 0x00, true },
182f1f580f5Smsaitoh { "BR_MISP_RETIRED.JCC", 0xc5, 0x7e, true },
183f1f580f5Smsaitoh { "BR_MISP_RETIRED.FAR", 0xc5, 0xbf, true },
184f1f580f5Smsaitoh { "BR_MISP_RETIRED.NON_RETURN_IND", 0xc5, 0xeb, true },
185f1f580f5Smsaitoh { "BR_MISP_RETIRED.RETURN", 0xc5, 0xf7, true },
186f1f580f5Smsaitoh { "BR_MISP_RETIRED.CALL", 0xc5, 0xf9, true },
187f1f580f5Smsaitoh { "BR_MISP_RETIRED.IND_CALL", 0xc5, 0xfb, true },
188f1f580f5Smsaitoh { "BR_MISP_RETIRED.REL_CALL", 0xc5, 0xfd, true },
189f1f580f5Smsaitoh { "BR_MISP_RETIRED.TAKEN_JCC", 0xc5, 0xfe, true },
190f1f580f5Smsaitoh { "NO_ALLOC_CYCLES.ROB_FULL", 0xca, 0x01, true },
191f1f580f5Smsaitoh { "NO_ALLOC_CYCLES.RAT_STALL", 0xca, 0x20, true },
192f1f580f5Smsaitoh { "NO_ALLOC_CYCLES.ALL", 0xca, 0x3f, true },
193f1f580f5Smsaitoh { "NO_ALLOC_CYCLES.NOT_DELIVERED", 0xca, 0x50, true },
194f1f580f5Smsaitoh { "RS_FULL_STALL.MEC", 0xcb, 0x01, true },
195f1f580f5Smsaitoh { "RS_FULL_STALL.ALL", 0xcb, 0x1f, true },
196f1f580f5Smsaitoh { "CYCLES_DIV_BUSY.ANY", 0xcd, 0x01, true },
197f1f580f5Smsaitoh { "BACLEARS.ALL", 0xe6, 0x01, true },
198f1f580f5Smsaitoh { "BACLEARS.RETURN", 0xe6, 0x08, true },
199f1f580f5Smsaitoh { "BACLEARS.COND", 0xe6, 0x10, true },
200f1f580f5Smsaitoh { "MS_DECODED.MS_ENTRY", 0xe7, 0x01, true },
201a8700cbeSknakahara };
202a8700cbeSknakahara
203a8700cbeSknakahara static struct event_table intel_silvermont_airmont = {
204a8700cbeSknakahara .tablename = "Intel Silvermont/Airmont",
205a8700cbeSknakahara .names = intel_silvermont_airmont_names,
206a8700cbeSknakahara .nevents = sizeof(intel_silvermont_airmont_names) /
207a8700cbeSknakahara sizeof(struct name_to_event),
208a8700cbeSknakahara .next = NULL
209a8700cbeSknakahara };
210a8700cbeSknakahara
211a8700cbeSknakahara static struct event_table *
init_intel_silvermont_airmont(void)212a8700cbeSknakahara init_intel_silvermont_airmont(void)
213a8700cbeSknakahara {
214a8700cbeSknakahara
215a8700cbeSknakahara return &intel_silvermont_airmont;
216a8700cbeSknakahara }
217a8700cbeSknakahara
218a8700cbeSknakahara /*
2194fd01caaSknakahara * Intel Goldmont
2204fd01caaSknakahara */
2214fd01caaSknakahara static struct name_to_event intel_goldmont_names[] = {
2224fd01caaSknakahara { "LD_BLOCKS.ALL_BLOCK", 0x03, 0x10, true },
2234fd01caaSknakahara { "LD_BLOCKS.UTLB_MISS", 0x03, 0x08, true },
2244fd01caaSknakahara { "LD_BLOCKS.STORE_FORWARD", 0x03, 0x02, true },
2254fd01caaSknakahara { "LD_BLOCKS.DATA_UNKNOWN", 0x03, 0x01, true },
2264fd01caaSknakahara { "LD_BLOCKS.4K_ALIAS", 0x03, 0x04, true },
2274fd01caaSknakahara { "PAGE_WALKS.D_SIDE_CYCLES", 0x05, 0x01, true },
2284fd01caaSknakahara { "PAGE_WALKS.I_SIDE_CYCLES", 0x05, 0x02, true },
2294fd01caaSknakahara { "PAGE_WALKS.CYCLES", 0x05, 0x03, true },
230f1f580f5Smsaitoh { "UOPS_ISSUED.ANY", 0x0e, 0x00, true },
2314fd01caaSknakahara { "MISALIGN_MEM_REF.LOAD_PAGE_SPLIT", 0x13, 0x02, true },
2324fd01caaSknakahara { "MISALIGN_MEM_REF.STORE_PAGE_SPLIT", 0x13, 0x04, true },
233f1f580f5Smsaitoh { "LONGEST_LAT_CACHE.REFERENCE", 0x2e, 0x4f, true },
234f1f580f5Smsaitoh { "LONGEST_LAT_CACHE.MISS", 0x2e, 0x41, true },
2354fd01caaSknakahara { "L2_REJECT_XQ.ALL", 0x30, 0x00, true },
2364fd01caaSknakahara { "CORE_REJECT_L2Q.ALL", 0x31, 0x00, true },
237f1f580f5Smsaitoh { "CPU_CLK_UNHALTED.CORE_P", 0x3c, 0x00, true },
238f1f580f5Smsaitoh { "CPU_CLK_UNHALTED.REF", 0x3c, 0x01, true },
2394fd01caaSknakahara { "DL1.DIRTY_EVICTION", 0x51, 0x01, true },
2404fd01caaSknakahara { "ICACHE.HIT", 0x80, 0x01, true },
2414fd01caaSknakahara { "ICACHE.MISSES", 0x80, 0x02, true },
2424fd01caaSknakahara { "ICACHE.ACCESSES", 0x80, 0x03, true },
2434fd01caaSknakahara { "ITLB.MISS", 0x81, 0x04, true },
2444fd01caaSknakahara { "FETCH_STALL.ALL", 0x86, 0x00, true },
2454fd01caaSknakahara { "FETCH_STALL.ITLB_FILL_PENDING_CYCLES", 0x86, 0x01, true },
2464fd01caaSknakahara { "FETCH_STALL.ICACHE_FILL_PENDING_CYCLES", 0x86, 0x02, true },
247f1f580f5Smsaitoh { "UOPS_NOT_DELIVERED.ANY", 0x9c, 0x00, true },
248f1f580f5Smsaitoh { "OFFCORE_RESPONSE.0", 0xb7, 0x01, true },
249f1f580f5Smsaitoh { "OFFCORE_RESPONSE.1", 0xb7, 0x02, true },
250f1f580f5Smsaitoh { "INST_RETIRED.ANY_P", 0xc0, 0x00, true },
251f1f580f5Smsaitoh { "UOPS_RETIRED.ANY", 0xc2, 0x00, true },
252f1f580f5Smsaitoh { "UOPS_RETIRED.MS", 0xc2, 0x01, true },
253f1f580f5Smsaitoh { "UOPS_RETIRED.FPDIV", 0xc2, 0x08, true },
254f1f580f5Smsaitoh { "UOPS_RETIRED.IDIV", 0xc2, 0x10, true },
255f1f580f5Smsaitoh { "MACHINE_CLEARS.SMC", 0xc3, 0x01, true },
256f1f580f5Smsaitoh { "MACHINE_CLEARS.MEMORY_ORDERING", 0xc3, 0x02, true },
257f1f580f5Smsaitoh { "MACHINE_CLEARS.FP_ASSIST", 0xc3, 0x04, true },
258f1f580f5Smsaitoh { "MACHINE_CLEARS.DISAMBIGUATION", 0xc3, 0x08, true },
259f1f580f5Smsaitoh { "MACHINE_CLEARS.ALL", 0xc3, 0x00, true },
260f1f580f5Smsaitoh { "BR_INST_RETIRED.ALL_BRANCHES", 0xc4, 0x00, true },
261f1f580f5Smsaitoh { "BR_INST_RETIRED.JCC", 0xc4, 0x7e, true },
262f1f580f5Smsaitoh { "BR_INST_RETIRED.ALL_TAKEN_BRANCHES", 0xc4, 0x80, true },
263f1f580f5Smsaitoh { "BR_INST_RETIRED.TAKEN_JCC", 0xc4, 0xfe, true },
264f1f580f5Smsaitoh { "BR_INST_RETIRED.CALL", 0xc4, 0xf9, true },
265f1f580f5Smsaitoh { "BR_INST_RETIRED.REL_CALL", 0xc4, 0xfd, true },
266f1f580f5Smsaitoh { "BR_INST_RETIRED.IND_CALL", 0xc4, 0xfb, true },
267f1f580f5Smsaitoh { "BR_INST_RETIRED.RETURN", 0xc4, 0xf7, true },
268f1f580f5Smsaitoh { "BR_INST_RETIRED.NON_RETURN_IND", 0xc4, 0xeb, true },
269f1f580f5Smsaitoh { "BR_INST_RETIRED.FAR_BRANCH", 0xc4, 0xbf, true },
270f1f580f5Smsaitoh { "BR_MISP_RETIRED.ALL_BRANCHES", 0xc5, 0x00, true },
271f1f580f5Smsaitoh { "BR_MISP_RETIRED.JCC", 0xc5, 0x7e, true },
272f1f580f5Smsaitoh { "BR_MISP_RETIRED.TAKEN_JCC", 0xc5, 0xfe, true },
273f1f580f5Smsaitoh { "BR_MISP_RETIRED.IND_CALL", 0xc5, 0xfb, true },
274f1f580f5Smsaitoh { "BR_MISP_RETIRED.RETURN", 0xc5, 0xf7, true },
275f1f580f5Smsaitoh { "BR_MISP_RETIRED.NON_RETURN_IND", 0xc5, 0xeb, true },
276f1f580f5Smsaitoh { "ISSUE_SLOTS_NOT_CONSUMED.RESOURCE_FULL", 0xca, 0x01, true },
277f1f580f5Smsaitoh { "ISSUE_SLOTS_NOT_CONSUMED.RECOVERY", 0xca, 0x02, true },
278f1f580f5Smsaitoh { "ISSUE_SLOTS_NOT_CONSUMED.ANY", 0xca, 0x00, true },
279f1f580f5Smsaitoh { "HW_INTERRUPTS.RECEIVED", 0xcb, 0x01, true },
280f1f580f5Smsaitoh { "HW_INTERRUPTS.MASKED", 0xcb, 0x02, true },
281f1f580f5Smsaitoh { "HW_INTERRUPTS.PENDING_AND_MASKED", 0xcb, 0x04, true },
282f1f580f5Smsaitoh { "CYCLES_DIV_BUSY.ALL", 0xcd, 0x00, true },
283f1f580f5Smsaitoh { "CYCLES_DIV_BUSY.IDIV", 0xcd, 0x01, true },
284f1f580f5Smsaitoh { "CYCLES_DIV_BUSY.FPDIV", 0xcd, 0x02, true },
285f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.ALL_LOADS", 0xd0, 0x81, true },
286f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.ALL_STORES", 0xd0, 0x82, true },
287f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.ALL", 0xd0, 0x83, true },
288f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.DTLB_MISS_LOADS", 0xd0, 0x11, true },
289f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.DTLB_MISS_STORES", 0xd0, 0x12, true },
290f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.DTLB_MISS", 0xd0, 0x13, true },
291f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.LOCK_LOADS", 0xd0, 0x21, true },
292f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.SPLIT_LOADS", 0xd0, 0x41, true },
293f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.SPLIT_STORES", 0xd0, 0x42, true },
294f1f580f5Smsaitoh { "MEM_UOPS_RETIRED.SPLIT", 0xd0, 0x43, true },
295f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.L1_HIT", 0xd1, 0x01, true },
296f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.L1_MISS", 0xd1, 0x08, true },
297f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.L2_HIT", 0xd1, 0x02, true },
298f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.L2_MISS", 0xd1, 0x10, true },
299f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.HITM", 0xd1, 0x20, true },
300f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.WCB_HIT", 0xd1, 0x40, true },
301f1f580f5Smsaitoh { "MEM_LOAD_UOPS_RETIRED.DRAM_HIT", 0xd1, 0x80, true },
302f1f580f5Smsaitoh { "BACLEARS.ALL", 0xe6, 0x01, true },
303f1f580f5Smsaitoh { "BACLEARS.RETURN", 0xe6, 0x08, true },
304f1f580f5Smsaitoh { "BACLEAR.CONDS", 0xe6, 0x10, true },
305f1f580f5Smsaitoh { "MS_DECODED.MS_ENTRY", 0xe7, 0x01, true },
306f1f580f5Smsaitoh { "DECODED_RESTRICTION.PREDECODE_WRONG", 0xe9, 0x01, true },
3074fd01caaSknakahara };
3084fd01caaSknakahara
3094fd01caaSknakahara static struct event_table intel_goldmont = {
3104fd01caaSknakahara .tablename = "Intel Goldmont",
3114fd01caaSknakahara .names = intel_goldmont_names,
3124fd01caaSknakahara .nevents = sizeof(intel_goldmont_names) /
3134fd01caaSknakahara sizeof(struct name_to_event),
3144fd01caaSknakahara .next = NULL
3154fd01caaSknakahara };
3164fd01caaSknakahara
3174fd01caaSknakahara static struct event_table *
init_intel_goldmont(void)3184fd01caaSknakahara init_intel_goldmont(void)
3194fd01caaSknakahara {
3204fd01caaSknakahara
3214fd01caaSknakahara return &intel_goldmont;
3224fd01caaSknakahara }
3234fd01caaSknakahara
3244fd01caaSknakahara /*
3254ed6c77eSknakahara * Intel Goldmont Plus (Additions from Goldmont)
3264ed6c77eSknakahara */
3274ed6c77eSknakahara static struct name_to_event intel_goldmontplus_names[] = {
3284ed6c77eSknakahara { "INST_RETIRED.ANY", 0x00, 0x01, true },
3294ed6c77eSknakahara { "DTLB_LOAD_MISSES.WALK_COMPLETED_4K", 0x08, 0x02, true },
3304ed6c77eSknakahara { "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M", 0x08, 0x04, true },
3314ed6c77eSknakahara { "DTLB_LOAD_MISSES.WALK_COMPLETED_1GB", 0x08, 0x08, true },
3324ed6c77eSknakahara { "DTLB_LOAD_MISSES.WALK_PENDING", 0x08, 0x10, true },
3334ed6c77eSknakahara { "DTLB_STORE_MISSES.WALK_COMPLETED_4K", 0x49, 0x02, true },
3344ed6c77eSknakahara { "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M", 0x49, 0x04, true },
3354ed6c77eSknakahara { "DTLB_STORE_MISSES.WALK_COMPLETED_1GB", 0x49, 0x08, true },
3364ed6c77eSknakahara { "DTLB_STORE_MISSES.WALK_PENDING", 0x49, 0x10, true },
337f1f580f5Smsaitoh { "EPT.WALK_PENDING", 0x4f, 0x10, true },
3384ed6c77eSknakahara { "ITLB_MISSES.WALK_COMPLETED_4K", 0x85, 0x08, true },
3394ed6c77eSknakahara { "ITLB_MISSES.WALK_COMPLETED_2M_4M", 0x85, 0x04, true },
3404ed6c77eSknakahara { "ITLB_MISSES.WALK_COMPLETED_1GB", 0x85, 0x08, true },
3414ed6c77eSknakahara { "ITLB_MISSES.WALK_PENDING", 0x85, 0x10, true },
342f1f580f5Smsaitoh { "TLB_FLUSHES.STLB_ANY", 0xbd, 0x20, true },
343f1f580f5Smsaitoh { "MACHINE_CLEARS.PAGE_FAULT", 0xc3, 0x20, true },
3444ed6c77eSknakahara };
3454ed6c77eSknakahara
3464ed6c77eSknakahara static struct event_table intel_goldmontplus = {
3474ed6c77eSknakahara .tablename = "Intel Goldmont Plus",
3484ed6c77eSknakahara .names = intel_goldmontplus_names,
3494ed6c77eSknakahara .nevents = sizeof(intel_goldmontplus_names) /
3504ed6c77eSknakahara sizeof(struct name_to_event),
3514ed6c77eSknakahara .next = NULL
3524ed6c77eSknakahara };
3534ed6c77eSknakahara
3544ed6c77eSknakahara static struct event_table *
init_intel_goldmontplus(void)3554ed6c77eSknakahara init_intel_goldmontplus(void)
3564ed6c77eSknakahara {
3574ed6c77eSknakahara
3584ed6c77eSknakahara intel_goldmont.next = &intel_goldmontplus;
3594ed6c77eSknakahara
3604ed6c77eSknakahara return &intel_goldmont;
3614ed6c77eSknakahara }
3624ed6c77eSknakahara
3634ed6c77eSknakahara /*
3649896bc73Smaxv * Intel Skylake/Kabylake.
3659896bc73Smaxv *
3669896bc73Smaxv * The events that are not listed, because they are of little interest or
3679896bc73Smaxv * require extra configuration:
3689896bc73Smaxv * TX_*
3699896bc73Smaxv * FRONTEND_RETIRED.*
3709896bc73Smaxv * FP_ARITH_INST_RETIRED.*
3719896bc73Smaxv * HLE_RETIRED.*
3729896bc73Smaxv * RTM_RETIRED.*
3739896bc73Smaxv * MEM_TRANS_RETIRED.*
3749896bc73Smaxv * UOPS_DISPATCHED_PORT.*
375a087cb3cSmaxv */
376a087cb3cSmaxv static struct name_to_event intel_skylake_kabylake_names[] = {
377a087cb3cSmaxv /* Event Name - Event Select - UMask */
3789896bc73Smaxv { "LD_BLOCKS.STORE_FORWARD", 0x03, 0x02, true },
3799896bc73Smaxv { "LD_BLOCKS.NO_SR", 0x03, 0x08, true },
3809896bc73Smaxv { "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS", 0x07, 0x01, true },
3819896bc73Smaxv { "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK", 0x08, 0x01, true },
3829896bc73Smaxv { "DTLB_LOAD_MISSES.WALK_COMPLETED_4K", 0x08, 0x02, true },
3839896bc73Smaxv { "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M", 0x08, 0x04, true },
3849896bc73Smaxv { "DTLB_LOAD_MISSES.WALK_COMPLETED_1G", 0x08, 0x08, true },
385f1f580f5Smsaitoh { "DTLB_LOAD_MISSES.WALK_COMPLETED", 0x08, 0x0e, true },
3869896bc73Smaxv { "DTLB_LOAD_MISSES.WALK_PENDING", 0x08, 0x10, true },
3879896bc73Smaxv { "DTLB_LOAD_MISSES.STLB_HIT", 0x08, 0x20, true },
388f1f580f5Smsaitoh { "INT_MISC.RECOVERY_CYCLES", 0x0d, 0x01, true },
389f1f580f5Smsaitoh { "INT_MISC.CLEAR_RESTEER_CYCLES", 0x0d, 0x80, true },
390f1f580f5Smsaitoh { "UOPS_ISSUED.ANY", 0x0e, 0x01, true },
391f1f580f5Smsaitoh { "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH", 0x0e, 0x02, true },
392f1f580f5Smsaitoh { "UOPS_ISSUED.SLOW_LEA", 0x0e, 0x20, true },
3939896bc73Smaxv { "L2_RQSTS.DEMAND_DATA_RD_MISS", 0x24, 0x21, true },
3949896bc73Smaxv { "L2_RQSTS.RFO_MISS", 0x24, 0x22, true },
3959896bc73Smaxv { "L2_RQSTS.CODE_RD_MISS", 0x24, 0x24, true },
3969896bc73Smaxv { "L2_RQSTS.ALL_DEMAND_MISS", 0x24, 0x27, true },
3979896bc73Smaxv { "L2_RQSTS.PF_MISS", 0x24, 0x38, true },
398f1f580f5Smsaitoh { "L2_RQSTS.MISS", 0x24, 0x3f, true },
3999896bc73Smaxv { "L2_RQSTS.DEMAND_DATA_RD_HIT", 0x24, 0x41, true },
4009896bc73Smaxv { "L2_RQSTS.RFO_HIT", 0x24, 0x42, true },
4019896bc73Smaxv { "L2_RQSTS.CODE_RD_HIT", 0x24, 0x44, true },
402f1f580f5Smsaitoh { "L2_RQSTS.PF_HIT", 0x24, 0xd8, true },
403f1f580f5Smsaitoh { "L2_RQSTS.ALL_DEMAND_DATA_RD", 0x24, 0xe1, true },
404f1f580f5Smsaitoh { "L2_RQSTS.ALL_RFO", 0x24, 0xe2, true },
405f1f580f5Smsaitoh { "L2_RQSTS.ALL_CODE_RD", 0x24, 0xe4, true },
406f1f580f5Smsaitoh { "L2_RQSTS.ALL_DEMAND_REFERENCES", 0x24, 0xe7, true },
407f1f580f5Smsaitoh { "L2_RQSTS.ALL_PF", 0x24, 0xf8, true },
408f1f580f5Smsaitoh { "L2_RQSTS.REFERENCES", 0x24, 0xff, true },
4099896bc73Smaxv { "SW_PREFETCH_ACCESS.NTA", 0x32, 0x01, true },
4109896bc73Smaxv { "SW_PREFETCH_ACCESS.T0", 0x32, 0x02, true },
4119896bc73Smaxv { "SW_PREFETCH_ACCESS.T1_T2", 0x32, 0x04, true },
4129896bc73Smaxv { "SW_PREFETCH_ACCESS.PREFETCHW", 0x32, 0x08, true },
413f1f580f5Smsaitoh { "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE", 0x3c, 0x02, true },
414f1f580f5Smsaitoh { "CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE", 0x3c, 0x02, true },
4159896bc73Smaxv { "L1D_PEND_MISS.PENDING", 0x48, 0x01, true },
4169896bc73Smaxv { "L1D_PEND_MISS.FB_FULL", 0x48, 0x02, true },
4179896bc73Smaxv { "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK", 0x49, 0x01, true },
4189896bc73Smaxv { "DTLB_STORE_MISSES.WALK_COMPLETED_4K", 0x49, 0x02, true },
4199896bc73Smaxv { "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M", 0x49, 0x04, true },
4209896bc73Smaxv { "DTLB_STORE_MISSES.WALK_COMPLETED_1G", 0x49, 0x08, true },
421f1f580f5Smsaitoh { "DTLB_STORE_MISSES.WALK_COMPLETED", 0x49, 0x0e, true },
4229896bc73Smaxv { "DTLB_STORE_MISSES.WALK_PENDING", 0x49, 0x10, true },
4239896bc73Smaxv { "DTLB_STORE_MISSES.STLB_HIT", 0x49, 0x20, true },
424f1f580f5Smsaitoh { "LOAD_HIT_PRE.SW_PF", 0x4c, 0x01, true },
425f1f580f5Smsaitoh { "EPT.WALK_PENDING", 0x4f, 0x10, true },
4269896bc73Smaxv { "L1D.REPLACEMENT", 0x51, 0x01, true },
427f1f580f5Smsaitoh { "RS_EVENTS.EMPTY_CYCLES", 0x5e, 0x01, true },
4289896bc73Smaxv { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD", 0x60, 0x01, true },
4299896bc73Smaxv { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD", 0x60, 0x02, true },
4309896bc73Smaxv { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO", 0x60, 0x04, true },
4319896bc73Smaxv { "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD", 0x60, 0x08, true },
432f5823b20Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",
433f5823b20Smsaitoh 0x60, 0x10, true },
4349896bc73Smaxv { "IDQ.MITE_UOPS", 0x79, 0x04, true },
4359896bc73Smaxv { "IDQ.DSB_UOPS", 0x79, 0x08, true },
4369896bc73Smaxv { "IDQ.MS_MITE_UOPS", 0x79, 0x20, true },
4379896bc73Smaxv { "IDQ.MS_UOPS", 0x79, 0x30, true },
4389896bc73Smaxv { "ICACHE_16B.IFDATA_STALL", 0x80, 0x04, true },
4399896bc73Smaxv { "ICACHE_64B.IFTAG_HIT", 0x83, 0x01, true },
4409896bc73Smaxv { "ICACHE_64B.IFTAG_MISS", 0x83, 0x02, true },
4419896bc73Smaxv { "ICACHE_64B.IFTAG_STALL", 0x83, 0x04, true },
4429896bc73Smaxv { "ITLB_MISSES.MISS_CAUSES_A_WALK", 0x85, 0x01, true },
4439896bc73Smaxv { "ITLB_MISSES.WALK_COMPLETED_4K", 0x85, 0x02, true },
4449896bc73Smaxv { "ITLB_MISSES.WALK_COMPLETED_2M_4M", 0x85, 0x04, true },
4459896bc73Smaxv { "ITLB_MISSES.WALK_COMPLETED_1G", 0x85, 0x08, true },
446f1f580f5Smsaitoh { "ITLB_MISSES.WALK_COMPLETED", 0x85, 0x0e, true },
4479896bc73Smaxv { "ITLB_MISSES.WALK_PENDING", 0x85, 0x10, true },
4489896bc73Smaxv { "ITLB_MISSES.STLB_HIT", 0x85, 0x20, true },
4499896bc73Smaxv { "ILD_STALL.LCP", 0x87, 0x01, true },
450f1f580f5Smsaitoh { "IDQ_UOPS_NOT_DELIVERED.CORE", 0x9c, 0x01, true },
451f1f580f5Smsaitoh { "RESOURCE_STALLS.ANY", 0xa2, 0x01, true },
452f1f580f5Smsaitoh { "RESOURCE_STALLS.SB", 0xa2, 0x08, true },
453f1f580f5Smsaitoh { "EXE_ACTIVITY.EXE_BOUND_0_PORTS", 0xa6, 0x01, true },
454f1f580f5Smsaitoh { "EXE_ACTIVITY.1_PORTS_UTIL", 0xa6, 0x02, true },
455f1f580f5Smsaitoh { "EXE_ACTIVITY.2_PORTS_UTIL", 0xa6, 0x04, true },
456f1f580f5Smsaitoh { "EXE_ACTIVITY.3_PORTS_UTIL", 0xa6, 0x08, true },
457f1f580f5Smsaitoh { "EXE_ACTIVITY.4_PORTS_UTIL", 0xa6, 0x10, true },
458f1f580f5Smsaitoh { "EXE_ACTIVITY.BOUND_ON_STORES", 0xa6, 0x40, true },
459f1f580f5Smsaitoh { "LSD.UOPS", 0xa8, 0x01, true },
460f1f580f5Smsaitoh { "DSB2MITE_SWITCHES.PENALTY_CYCLES", 0xab, 0x02, true },
461f1f580f5Smsaitoh { "ITLB.ITLB_FLUSH", 0xae, 0x01, true },
462f1f580f5Smsaitoh { "OFFCORE_REQUESTS.DEMAND_DATA_RD", 0xb0, 0x01, true },
463f1f580f5Smsaitoh { "OFFCORE_REQUESTS.DEMAND_CODE_RD", 0xb0, 0x02, true },
464f1f580f5Smsaitoh { "OFFCORE_REQUESTS.DEMAND_RFO", 0xb0, 0x04, true },
465f1f580f5Smsaitoh { "OFFCORE_REQUESTS.ALL_DATA_RD", 0xb0, 0x08, true },
466f1f580f5Smsaitoh { "OFFCORE_REQUESTS.L3_MISS_DEMAND_DATA_RD", 0xb0, 0x10, true },
467f1f580f5Smsaitoh { "OFFCORE_REQUESTS.ALL_REQUESTS", 0xb0, 0x80, true },
468f1f580f5Smsaitoh { "UOPS_EXECUTED.THREAD", 0xb1, 0x01, true },
469f1f580f5Smsaitoh { "UOPS_EXECUTED.CORE", 0xb1, 0x02, true },
470f1f580f5Smsaitoh { "UOPS_EXECUTED.X87", 0xb1, 0x10, true },
471f1f580f5Smsaitoh { "OFFCORE_REQUESTS_BUFFER.SQ_FULL", 0xb2, 0x01, true },
472f1f580f5Smsaitoh { "TLB_FLUSH.DTLB_THREAD", 0xbd, 0x01, true },
473f1f580f5Smsaitoh { "TLB_FLUSH.STLB_ANY", 0xbd, 0x20, true },
474f1f580f5Smsaitoh { "INST_RETIRED.PREC_DIST", 0xc0, 0x01, true },
475f1f580f5Smsaitoh { "OTHER_ASSISTS.ANY", 0xc1, 0x3f, true },
476f1f580f5Smsaitoh { "UOPS_RETIRED.RETIRE_SLOTS", 0xc2, 0x02, true },
477f1f580f5Smsaitoh { "MACHINE_CLEARS.MEMORY_ORDERING", 0xc3, 0x02, true },
478f1f580f5Smsaitoh { "MACHINE_CLEARS.SMC", 0xc3, 0x04, true },
479f1f580f5Smsaitoh { "BR_INST_RETIRED.CONDITIONAL", 0xc4, 0x01, true },
480f1f580f5Smsaitoh { "BR_INST_RETIRED.NEAR_CALL", 0xc4, 0x02, true },
481f1f580f5Smsaitoh { "BR_INST_RETIRED.NEAR_RETURN", 0xc4, 0x08, true },
482f1f580f5Smsaitoh { "BR_INST_RETIRED.NOT_TAKEN", 0xc4, 0x10, true },
483f1f580f5Smsaitoh { "BR_INST_RETIRED.NEAR_TAKEN", 0xc4, 0x20, true },
484f1f580f5Smsaitoh { "BR_INST_RETIRED.FAR_BRANCH", 0xc4, 0x40, true },
485f1f580f5Smsaitoh { "BR_MISP_RETIRED.CONDITIONAL", 0xc5, 0x01, true },
486f1f580f5Smsaitoh { "BR_MISP_RETIRED.NEAR_CALL", 0xc5, 0x02, true },
487f1f580f5Smsaitoh { "BR_MISP_RETIRED.NEAR_TAKEN", 0xc5, 0x20, true },
488f1f580f5Smsaitoh { "HW_INTERRUPTS.RECEIVED", 0xcb, 0x01, true },
489f1f580f5Smsaitoh { "MEM_INST_RETIRED.STLB_MISS_LOADS", 0xd0, 0x11, true },
490f1f580f5Smsaitoh { "MEM_INST_RETIRED.STLB_MISS_STORES", 0xd0, 0x12, true },
491f1f580f5Smsaitoh { "MEM_INST_RETIRED.LOCK_LOADS", 0xd0, 0x21, true },
492f1f580f5Smsaitoh { "MEM_INST_RETIRED.SPLIT_LOADS", 0xd0, 0x41, true },
493f1f580f5Smsaitoh { "MEM_INST_RETIRED.SPLIT_STORES", 0xd0, 0x42, true },
494f1f580f5Smsaitoh { "MEM_INST_RETIRED.ALL_LOADS", 0xd0, 0x81, true },
495f1f580f5Smsaitoh { "MEM_INST_RETIRED.ALL_STORES", 0xd0, 0x82, true },
496f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L1_HIT", 0xd1, 0x01, true },
497f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L2_HIT", 0xd1, 0x02, true },
498f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L3_HIT", 0xd1, 0x04, true },
499f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L1_MISS", 0xd1, 0x08, true },
500f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L2_MISS", 0xd1, 0x10, true },
501f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.L3_MISS", 0xd1, 0x20, true },
502f1f580f5Smsaitoh { "MEM_LOAD_RETIRED.FB_HIT", 0xd1, 0x40, true },
503f1f580f5Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS", 0xd2, 0x01, true },
504f1f580f5Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_HIT", 0xd2, 0x02, true },
505f1f580f5Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM", 0xd2, 0x04, true },
506f1f580f5Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_NONE", 0xd2, 0x08, true },
507f1f580f5Smsaitoh { "MEM_LOAD_MISC_RETIRED.UC", 0xd4, 0x04, true },
508f1f580f5Smsaitoh { "BACLEARS.ANY", 0xe6, 0x01, true },
509f1f580f5Smsaitoh { "L2_TRANS.L2_WB", 0xf0, 0x40, true },
510f1f580f5Smsaitoh { "L2_LINES_IN.ALL", 0xf1, 0x1f, true },
511f1f580f5Smsaitoh { "L2_LINES_OUT.SILENT", 0xf2, 0x01, true },
512f1f580f5Smsaitoh { "L2_LINES_OUT.NON_SILENT", 0xf2, 0x02, true },
513f1f580f5Smsaitoh { "L2_LINES_OUT.USELESS_HWPF", 0xf2, 0x04, true },
514f1f580f5Smsaitoh { "SQ_MISC.SPLIT_LOCK", 0xf4, 0x10, true },
515a087cb3cSmaxv };
516a087cb3cSmaxv
517a087cb3cSmaxv static struct event_table intel_skylake_kabylake = {
518a087cb3cSmaxv .tablename = "Intel Skylake/Kabylake",
519a087cb3cSmaxv .names = intel_skylake_kabylake_names,
520a087cb3cSmaxv .nevents = sizeof(intel_skylake_kabylake_names) /
521a087cb3cSmaxv sizeof(struct name_to_event),
522a087cb3cSmaxv .next = NULL
523a087cb3cSmaxv };
524a087cb3cSmaxv
525a087cb3cSmaxv static struct event_table *
init_intel_skylake_kabylake(void)526a087cb3cSmaxv init_intel_skylake_kabylake(void)
527a087cb3cSmaxv {
528f5823b20Smsaitoh
529a087cb3cSmaxv return &intel_skylake_kabylake;
530a087cb3cSmaxv }
531a087cb3cSmaxv
532*db06c1e0Smsaitoh /*
533*db06c1e0Smsaitoh * Intel Skylake-X (and Cascade Lake).
534*db06c1e0Smsaitoh */
535*db06c1e0Smsaitoh static struct name_to_event intel_skylake_x_names[] = {
536*db06c1e0Smsaitoh { "INST_RETIRED.ANY", 0x00, 0x01, true },
537*db06c1e0Smsaitoh { "CPU_CLK_UNHALTED.THREAD", 0x00, 0x02, true },
538*db06c1e0Smsaitoh { "CPU_CLK_UNHALTED.REF_TSC", 0x00, 0x03, true },
539*db06c1e0Smsaitoh { "LD_BLOCKS.STORE_FORWARD", 0x03, 0x02, true },
540*db06c1e0Smsaitoh { "LD_BLOCKS.NO_SR", 0x03, 0x08, true },
541*db06c1e0Smsaitoh { "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS", 0x07, 0x01, true },
542*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK", 0x08, 0x01, true },
543*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.WALK_COMPLETED_4K", 0x08, 0x02, true },
544*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M", 0x08, 0x04, true },
545*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.WALK_COMPLETED_1G", 0x08, 0x08, true },
546*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.WALK_COMPLETED", 0x08, 0x0E, true },
547*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.WALK_PENDING", 0x08, 0x10, true },
548*db06c1e0Smsaitoh { "DTLB_LOAD_MISSES.STLB_HIT", 0x08, 0x20, true },
549*db06c1e0Smsaitoh { "INT_MISC.RECOVERY_CYCLES", 0x0D, 0x01, true },
550*db06c1e0Smsaitoh { "INT_MISC.CLEAR_RESTEER_CYCLES", 0x0D, 0x80, true },
551*db06c1e0Smsaitoh { "UOPS_ISSUED.ANY", 0x0E, 0x01, true },
552*db06c1e0Smsaitoh { "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH", 0x0E, 0x02, true },
553*db06c1e0Smsaitoh { "UOPS_ISSUED.SLOW_LEA", 0x0E, 0x20, true },
554*db06c1e0Smsaitoh { "ARITH.DIVIDER_ACTIVE", 0x14, 0x01, true },
555*db06c1e0Smsaitoh { "L2_RQSTS.DEMAND_DATA_RD_MISS", 0x24, 0x21, true },
556*db06c1e0Smsaitoh { "L2_RQSTS.RFO_MISS", 0x24, 0x22, true },
557*db06c1e0Smsaitoh { "L2_RQSTS.CODE_RD_MISS", 0x24, 0x24, true },
558*db06c1e0Smsaitoh { "L2_RQSTS.ALL_DEMAND_MISS", 0x24, 0x27, true },
559*db06c1e0Smsaitoh { "L2_RQSTS.PF_MISS", 0x24, 0x38, true },
560*db06c1e0Smsaitoh { "L2_RQSTS.MISS", 0x24, 0x3F, true },
561*db06c1e0Smsaitoh { "L2_RQSTS.DEMAND_DATA_RD_HIT", 0x24, 0x41, true },
562*db06c1e0Smsaitoh { "L2_RQSTS.RFO_HIT", 0x24, 0x42, true },
563*db06c1e0Smsaitoh { "L2_RQSTS.CODE_RD_HIT", 0x24, 0x44, true },
564*db06c1e0Smsaitoh { "L2_RQSTS.PF_HIT", 0x24, 0xD8, true },
565*db06c1e0Smsaitoh { "L2_RQSTS.ALL_DEMAND_DATA_RD", 0x24, 0xE1, true },
566*db06c1e0Smsaitoh { "L2_RQSTS.ALL_RFO", 0x24, 0xE2, true },
567*db06c1e0Smsaitoh { "L2_RQSTS.ALL_CODE_RD", 0x24, 0xE4, true },
568*db06c1e0Smsaitoh { "L2_RQSTS.ALL_DEMAND_REFERENCES", 0x24, 0xE7, true },
569*db06c1e0Smsaitoh { "L2_RQSTS.ALL_PF", 0x24, 0xF8, true },
570*db06c1e0Smsaitoh { "L2_RQSTS.REFERENCES All L2", 0x24, 0xFF, true },
571*db06c1e0Smsaitoh { "CORE_POWER.LVL0_TURBO_LICENSE", 0x28, 0x07, true },
572*db06c1e0Smsaitoh { "CORE_POWER.LVL1_TURBO_LICENSE", 0x28, 0x18, true },
573*db06c1e0Smsaitoh { "CORE_POWER.LVL2_TURBO_LICENSE", 0x28, 0x20, true },
574*db06c1e0Smsaitoh { "CORE_POWER.THROTTLE", 0x28, 0x40, true },
575*db06c1e0Smsaitoh { "LONGEST_LAT_CACHE.MISS", 0x2E, 0x41, true },
576*db06c1e0Smsaitoh { "LONGEST_LAT_CACHE.REFERENCE", 0x2E, 0x4F, true },
577*db06c1e0Smsaitoh { "CPU_CLK_UNHALTED.THREAD_P", 0x3C, 0x00, true },
578*db06c1e0Smsaitoh { "CPU_CLK_THREAD_UNHALTED.REF_XCLK", 0x3C, 0x01, true },
579*db06c1e0Smsaitoh { "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE", 0x3C, 0x02, true },
580*db06c1e0Smsaitoh { "L1D_PEND_MISS.PENDING", 0x48, 0x01, true },
581*db06c1e0Smsaitoh { "L1D_PEND_MISS.FB_FULL", 0x48, 0x02, true },
582*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK", 0x49, 0x01, true },
583*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.WALK_COMPLETED_4K", 0x49, 0x02, true },
584*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M", 0x49, 0x04, true },
585*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.WALK_COMPLETED_1G", 0x49, 0x08, true },
586*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.WALK_COMPLETED", 0x49, 0x0E, true },
587*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.WALK_PENDING", 0x49, 0x10, true },
588*db06c1e0Smsaitoh { "DTLB_STORE_MISSES.STLB_HIT", 0x49, 0x20, true },
589*db06c1e0Smsaitoh { "LOAD_HIT_PRE.SW_PF", 0x4C, 0x01, true },
590*db06c1e0Smsaitoh { "EPT.WALK_PENDING", 0x4F, 0x10, true },
591*db06c1e0Smsaitoh { "L1D.REPLACEMENT", 0x51, 0x01, true },
592*db06c1e0Smsaitoh { "TX_MEM.ABORT_CONFLICT", 0x54, 0x01, true },
593*db06c1e0Smsaitoh { "TX_MEM.ABORT_CAPACITY", 0x54, 0x02, true },
594*db06c1e0Smsaitoh { "TX_MEM.ABORT_HLE_STORE_TO_ELIDED_LOCK", 0x54, 0x04, true },
595*db06c1e0Smsaitoh { "TX_MEM.ABORT_HLE_ELISION_BUFFER_NOT_EMPTY", 0x54, 0x08, true },
596*db06c1e0Smsaitoh { "TX_MEM.ABORT_HLE_ELISION_BUFFER_MISMATCH", 0x54, 0x10, true },
597*db06c1e0Smsaitoh { "TX_MEM.ABORT_HLE_ELISION_BUFFER_UNSUPPORTED_ALIGNMENT",
598*db06c1e0Smsaitoh 0x54, 0x20, true },
599*db06c1e0Smsaitoh { "TX_MEM.HLE_ELISION_BUFFER_FULL", 0x54, 0x40, true },
600*db06c1e0Smsaitoh { "TX_EXEC.MISC1", 0x5D, 0x01, true },
601*db06c1e0Smsaitoh { "TX_EXEC.MISC2", 0x5D, 0x02, true },
602*db06c1e0Smsaitoh { "TX_EXEC.MISC3", 0x5D, 0x04, true },
603*db06c1e0Smsaitoh { "TX_EXEC.MISC4", 0x5D, 0x08, true },
604*db06c1e0Smsaitoh { "TX_EXEC.MISC5", 0x5D, 0x10, true },
605*db06c1e0Smsaitoh { "RS_EVENTS.EMPTY_CYCLES", 0x5E, 0x01, true },
606*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD",
607*db06c1e0Smsaitoh 0x60, 0x01, true },
608*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD",
609*db06c1e0Smsaitoh 0x60, 0x02, true },
610*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO", 0x60, 0x04, true },
611*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD", 0x60, 0x08, true },
612*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",
613*db06c1e0Smsaitoh 0x60, 0x10, true },
614*db06c1e0Smsaitoh { "IDQ.MITE_UOPS", 0x79, 0x04, true },
615*db06c1e0Smsaitoh { "IDQ.DSB_UOPS", 0x79, 0x08, true },
616*db06c1e0Smsaitoh { "IDQ.MS_DSB_CYCLES", 0x79, 0x10, true },
617*db06c1e0Smsaitoh { "IDQ.ALL_DSB_CYCLES_4_UOPS", 0x79, 0x18, true },
618*db06c1e0Smsaitoh { "IDQ.MS_MITE_UOPS", 0x79, 0x20, true },
619*db06c1e0Smsaitoh { "IDQ.ALL_MITE_CYCLES_4_UOPS", 0x79, 0x24, true },
620*db06c1e0Smsaitoh { "IDQ.MS_CYCLES", 0x79, 0x30, true },
621*db06c1e0Smsaitoh { "ICACHE_16B.IFDATA_STALL", 0x80, 0x04, true },
622*db06c1e0Smsaitoh { "ICACHE_64B.IFTAG_HIT", 0x83, 0x01, true },
623*db06c1e0Smsaitoh { "ICACHE_64B.IFTAG_MISS", 0x83, 0x02, true },
624*db06c1e0Smsaitoh { "ICACHE_64B.IFTAG_STALL", 0x83, 0x04, true },
625*db06c1e0Smsaitoh { "ITLB_MISSES.MISS_CAUSES_A_WALK", 0x85, 0x01, true },
626*db06c1e0Smsaitoh { "ITLB_MISSES.WALK_COMPLETED_4K", 0x85, 0x02, true },
627*db06c1e0Smsaitoh { "ITLB_MISSES.WALK_COMPLETED_2M_4M", 0x85, 0x04, true },
628*db06c1e0Smsaitoh { "ITLB_MISSES.WALK_COMPLETED_1G", 0x85, 0x08, true },
629*db06c1e0Smsaitoh { "ITLB_MISSES.WALK_COMPLETED", 0x85, 0x0E, true },
630*db06c1e0Smsaitoh { "ITLB_MISSES.WALK_PENDING", 0x85, 0x10, true },
631*db06c1e0Smsaitoh { "ITLB_MISSES.STLB_HIT", 0x85, 0x20, true },
632*db06c1e0Smsaitoh { "ILD_STALL.LCP", 0x87, 0x01, true },
633*db06c1e0Smsaitoh { "IDQ_UOPS_NOT_DELIVERED.CORE", 0x9C, 0x01, true },
634*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_0", 0xa1, 0x01, true },
635*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_1", 0xa1, 0x02, true },
636*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_2", 0xa1, 0x04, true },
637*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_3", 0xa1, 0x08, true },
638*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_4", 0xa1, 0x10, true },
639*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_5", 0xa1, 0x20, true },
640*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_6", 0xa1, 0x40, true },
641*db06c1e0Smsaitoh { "UOPS_DISPATCHED_PORT.PORT_7", 0xa1, 0x80, true },
642*db06c1e0Smsaitoh { "RESOURCE_STALLS.ANY", 0xa2, 0x01, true },
643*db06c1e0Smsaitoh { "RESOURCE_STALLS.SB", 0xa2, 0x08, true },
644*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.CYCLES_L2_MISS", 0xa3, 0x01, true },
645*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.CYCLES_L3_MISS", 0xa3, 0x02, true },
646*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.STALLS_TOTAL", 0xa3, 0x04, true },
647*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.STALLS_L2_MISS", 0xa3, 0x05, true },
648*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.STALLS_L3_MISS", 0xa3, 0x06, true },
649*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.CYCLES_L1D_MISS", 0xa3, 0x08, true },
650*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.STALLS_L1D_MISS", 0xa3, 0x0C, true },
651*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.CYCLES_MEM_ANY", 0xa3, 0x10, true },
652*db06c1e0Smsaitoh { "CYCLE_ACTIVITY.STALLS_MEM_ANY", 0xa3, 0x14, true },
653*db06c1e0Smsaitoh { "EXE_ACTIVITY.EXE_BOUND_0_PORTS", 0xa6, 0x01, true },
654*db06c1e0Smsaitoh { "EXE_ACTIVITY.1_PORTS_UTIL", 0xa6, 0x02, true },
655*db06c1e0Smsaitoh { "EXE_ACTIVITY.2_PORTS_UTIL", 0xa6, 0x04, true },
656*db06c1e0Smsaitoh { "EXE_ACTIVITY.3_PORTS_UTIL", 0xa6, 0x08, true },
657*db06c1e0Smsaitoh { "EXE_ACTIVITY.4_PORTS_UTIL", 0xa6, 0x10, true },
658*db06c1e0Smsaitoh { "EXE_ACTIVITY.BOUND_ON_STORES", 0xa6, 0x40, true },
659*db06c1e0Smsaitoh { "LSD.UOPS", 0xa8, 0x01, true },
660*db06c1e0Smsaitoh { "DSB2MITE_SWITCHES.PENALTY_CYCLES", 0xaB, 0x02, true },
661*db06c1e0Smsaitoh { "ITLB.ITLB_FLUSH", 0xaE, 0x01, true },
662*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.DEMAND_DATA_RD", 0xb0, 0x01, true },
663*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.DEMAND_CODE_RD", 0xb0, 0x02, true },
664*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.DEMAND_RFO", 0xb0, 0x04, true },
665*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.ALL_DATA_RD", 0xb0, 0x08, true },
666*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.L3_MISS_DEMAND_DATA_RD", 0xb0, 0x10, true },
667*db06c1e0Smsaitoh { "OFFCORE_REQUESTS.ALL_REQUESTS", 0xb0, 0x80, true },
668*db06c1e0Smsaitoh { "UOPS_EXECUTED.THREAD", 0xb1, 0x01, true },
669*db06c1e0Smsaitoh { "UOPS_EXECUTED.CORE", 0xb1, 0x02, true },
670*db06c1e0Smsaitoh { "UOPS_EXECUTED.X87", 0xb1, 0x10, true },
671*db06c1e0Smsaitoh { "OFFCORE_REQUESTS_BUFFER.SQ_FULL", 0xb2, 0x01, true },
672*db06c1e0Smsaitoh { "TLB_FLUSH.DTLB_THREAD", 0xbD, 0x01, true },
673*db06c1e0Smsaitoh { "TLB_FLUSH.STLB_ANY", 0xbD, 0x20, true },
674*db06c1e0Smsaitoh { "INST_RETIRED.ANY_P", 0xc0, 0x00, true },
675*db06c1e0Smsaitoh { "INST_RETIRED.PREC_DIST", 0xc0, 0x01, true },
676*db06c1e0Smsaitoh { "OTHER_ASSISTS.ANY", 0xc1, 0x3F, true },
677*db06c1e0Smsaitoh { "UOPS_RETIRED.STALL_CYCLES", 0xc2, 0x01, true },
678*db06c1e0Smsaitoh { "UOPS_RETIRED.RETIRE_SLOTS", 0xc2, 0x02, true },
679*db06c1e0Smsaitoh { "MACHINE_CLEARS.COUNT", 0xc3, 0x01, true },
680*db06c1e0Smsaitoh { "MACHINE_CLEARS.MEMORY_ORDERING", 0xc3, 0x02, true },
681*db06c1e0Smsaitoh { "MACHINE_CLEARS.SMC", 0xc3, 0x04, true },
682*db06c1e0Smsaitoh { "BR_INST_RETIRED.ALL_BRANCHES", 0xc4, 0x00, true },
683*db06c1e0Smsaitoh { "BR_INST_RETIRED.CONDITIONAL", 0xc4, 0x01, true },
684*db06c1e0Smsaitoh { "BR_INST_RETIRED.NEAR_CALL", 0xc4, 0x02, true },
685*db06c1e0Smsaitoh { "BR_INST_RETIRED.NEAR_RETURN", 0xc4, 0x08, true },
686*db06c1e0Smsaitoh { "BR_INST_RETIRED.NOT_TAKEN", 0xc4, 0x10, true },
687*db06c1e0Smsaitoh { "BR_INST_RETIRED.NEAR_TAKEN", 0xc4, 0x20, true },
688*db06c1e0Smsaitoh { "BR_INST_RETIRED.FAR_BRANCH", 0xc4, 0x40, true },
689*db06c1e0Smsaitoh { "BR_MISP_RETIRED.ALL_BRANCHES", 0xc5, 0x00, true },
690*db06c1e0Smsaitoh { "BR_MISP_RETIRED.CONDITIONAL", 0xc5, 0x01, true },
691*db06c1e0Smsaitoh { "BR_MISP_RETIRED.NEAR_CALL", 0xc5, 0x02, true },
692*db06c1e0Smsaitoh { "BR_MISP_RETIRED.NEAR_TAKEN", 0xc5, 0x20, true },
693*db06c1e0Smsaitoh { "FRONTEND_RETIRED.DSB_MISS", 0xc6, 0x01, true },
694*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.SCALAR_DOUBLE", 0xc7, 0x01, true },
695*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.SCALAR_SINGLE", 0xc7, 0x02, true },
696*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.128B_PACKED_DOUBLE", 0xc7, 0x04, true },
697*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.128B_PACKED_SINGLE", 0xc7, 0x08, true },
698*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.256B_PACKED_DOUBLE", 0xc7, 0x10, true },
699*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.256B_PACKED_SINGLE", 0xc7, 0x20, true },
700*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.512B_PACKED_DOUBLE", 0xc7, 0x40, true },
701*db06c1e0Smsaitoh { "FP_ARITH_INST_RETIRED.512B_PACKED_SINGLE", 0xc7, 0x80, true },
702*db06c1e0Smsaitoh { "HLE_RETIRED.START", 0xc8, 0x01, true },
703*db06c1e0Smsaitoh { "HLE_RETIRED.COMMIT", 0xc8, 0x02, true },
704*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED", 0xc8, 0x04, true },
705*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED_MEM", 0xc8, 0x08, true },
706*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED_TIMER", 0xc8, 0x10, true },
707*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED_UNFRIENDLY", 0xc8, 0x20, true },
708*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED_MEMTYPE", 0xc8, 0x40, true },
709*db06c1e0Smsaitoh { "HLE_RETIRED.ABORTED_EVENTS", 0xc8, 0x80, true },
710*db06c1e0Smsaitoh { "RTM_RETIRED.START", 0xc9, 0x01, true },
711*db06c1e0Smsaitoh { "RTM_RETIRED.COMMIT", 0xc9, 0x02, true },
712*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED", 0xc9, 0x04, true },
713*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED_MEM", 0xc9, 0x08, true },
714*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED_TIMER", 0xc9, 0x10, true },
715*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED_UNFRIENDLY", 0xc9, 0x20, true },
716*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED_MEMTYPE", 0xc9, 0x40, true },
717*db06c1e0Smsaitoh { "RTM_RETIRED.ABORTED_EVENTS", 0xc9, 0x80, true },
718*db06c1e0Smsaitoh { "FP_ASSIST.ANY", 0xca, 0x1e, true },
719*db06c1e0Smsaitoh { "HW_INTERRUPTS.RECEIVED", 0xcb, 0x01, true },
720*db06c1e0Smsaitoh { "ROB_MISC_EVENTS.LBR_INSERTS", 0xcc, 0x20, true },
721*db06c1e0Smsaitoh { "MEM_TRANS_RETIRED.LOAD_LATENCY_GT_4", 0xcd, 0x01, true },
722*db06c1e0Smsaitoh { "MEM_INST_RETIRED.STLB_MISS_LOADS", 0xd0, 0x11, true },
723*db06c1e0Smsaitoh { "MEM_INST_RETIRED.STLB_MISS_STORES", 0xd0, 0x12, true },
724*db06c1e0Smsaitoh { "MEM_INST_RETIRED.LOCK_LOADS", 0xd0, 0x21, true },
725*db06c1e0Smsaitoh { "MEM_INST_RETIRED.SPLIT_LOADS", 0xd0, 0x41, true },
726*db06c1e0Smsaitoh { "MEM_INST_RETIRED.SPLIT_STORES", 0xd0, 0x42, true },
727*db06c1e0Smsaitoh { "MEM_INST_RETIRED.ALL_LOADS", 0xd0, 0x81, true },
728*db06c1e0Smsaitoh { "MEM_INST_RETIRED.ALL_STORES", 0xd0, 0x82, true },
729*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L1_HIT", 0xd1, 0x01, true },
730*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L2_HIT", 0xd1, 0x02, true },
731*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L3_HIT", 0xd1, 0x04, true },
732*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L1_MISS", 0xd1, 0x08, true },
733*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L2_MISS", 0xd1, 0x10, true },
734*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.L3_MISS", 0xd1, 0x20, true },
735*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.FB_HIT", 0xd1, 0x40, true },
736*db06c1e0Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_MISS", 0xd2, 0x01, true },
737*db06c1e0Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_HIT", 0xd2, 0x02, true },
738*db06c1e0Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_HITM", 0xd2, 0x04, true },
739*db06c1e0Smsaitoh { "MEM_LOAD_L3_HIT_RETIRED.XSNP_NONE", 0xd2, 0x08, true },
740*db06c1e0Smsaitoh { "MEM_LOAD_L3_MISS_RETIRED.LOCAL_DRAM", 0xd3, 0x01, true },
741*db06c1e0Smsaitoh { "MEM_LOAD_L3_MISS_RETIRED.REMOTE_DRAM", 0xd3, 0x02, true },
742*db06c1e0Smsaitoh { "MEM_LOAD_L3_MISS_RETIRED.REMOTE_HITM", 0xd3, 0x04, true },
743*db06c1e0Smsaitoh { "MEM_LOAD_L3_MISS_RETIRED.REMOTE_FWD", 0xd3, 0x08, true },
744*db06c1e0Smsaitoh { "MEM_LOAD_MISC_RETIRED.UC", 0xd4, 0x04, true },
745*db06c1e0Smsaitoh { "BACLEARS.ANY", 0xe6, 0x01, true },
746*db06c1e0Smsaitoh { "L2_TRANS.L2_WB", 0xf0, 0x40, true },
747*db06c1e0Smsaitoh { "L2_LINES_IN.ALL", 0xf1, 0x1f, true },
748*db06c1e0Smsaitoh { "L2_LINES_OUT.SILENT", 0xf2, 0x01, true },
749*db06c1e0Smsaitoh { "L2_LINES_OUT.NON_SILENT", 0xf2, 0x02, true },
750*db06c1e0Smsaitoh { "L2_LINES_OUT.USELESS_PREF", 0xf2, 0x04, true },
751*db06c1e0Smsaitoh { "SQ_MISC.SPLIT_LOCK", 0xf4, 0x10, true },
752*db06c1e0Smsaitoh { "IDI_MISC.WB_UPGRADE", 0xfe, 0x02, true },
753*db06c1e0Smsaitoh { "IDI_MISC.WB_DOWNGRADE", 0xfe, 0x04, true },
754*db06c1e0Smsaitoh };
755*db06c1e0Smsaitoh
756*db06c1e0Smsaitoh static struct event_table intel_skylake_x = {
757*db06c1e0Smsaitoh .tablename = "Intel Skylake-X",
758*db06c1e0Smsaitoh .names = intel_skylake_x_names,
759*db06c1e0Smsaitoh .nevents = sizeof(intel_skylake_x_names) /
760*db06c1e0Smsaitoh sizeof(struct name_to_event),
761*db06c1e0Smsaitoh .next = NULL
762*db06c1e0Smsaitoh };
763*db06c1e0Smsaitoh
764*db06c1e0Smsaitoh static struct event_table *
init_intel_skylake_x(void)765*db06c1e0Smsaitoh init_intel_skylake_x(void)
766*db06c1e0Smsaitoh {
767*db06c1e0Smsaitoh
768*db06c1e0Smsaitoh return &intel_skylake_x;
769*db06c1e0Smsaitoh }
770*db06c1e0Smsaitoh
771*db06c1e0Smsaitoh /*
772*db06c1e0Smsaitoh * Intel Cascade Lake.
773*db06c1e0Smsaitoh */
774*db06c1e0Smsaitoh static struct name_to_event intel_cascadelake_names[] = {
775*db06c1e0Smsaitoh { "MEM_LOAD_RETIRED.LOCAL_PMM", 0xd1, 0x80, true },
776*db06c1e0Smsaitoh { "MEM_LOAD_L3_MISS_RETIRED.REMOTE_PMM", 0xd3, 0x10, true },
777*db06c1e0Smsaitoh };
778*db06c1e0Smsaitoh
779*db06c1e0Smsaitoh static struct event_table intel_cascadelake = {
780*db06c1e0Smsaitoh .tablename = "Intel Cascade Lake",
781*db06c1e0Smsaitoh .names = intel_cascadelake_names,
782*db06c1e0Smsaitoh .nevents = sizeof(intel_cascadelake_names) /
783*db06c1e0Smsaitoh sizeof(struct name_to_event),
784*db06c1e0Smsaitoh .next = NULL
785*db06c1e0Smsaitoh };
786*db06c1e0Smsaitoh
787*db06c1e0Smsaitoh static struct event_table *
init_intel_cascadelake(void)788*db06c1e0Smsaitoh init_intel_cascadelake(void)
789*db06c1e0Smsaitoh {
790*db06c1e0Smsaitoh
791*db06c1e0Smsaitoh intel_skylake_x.next = &intel_cascadelake;
792*db06c1e0Smsaitoh
793*db06c1e0Smsaitoh return &intel_skylake_x;
794*db06c1e0Smsaitoh }
795*db06c1e0Smsaitoh
796a087cb3cSmaxv static struct event_table *
init_intel_generic(void)797a087cb3cSmaxv init_intel_generic(void)
798a087cb3cSmaxv {
799a087cb3cSmaxv unsigned int eax, ebx, ecx, edx;
800a087cb3cSmaxv struct event_table *table;
801*db06c1e0Smsaitoh uint8_t stepping;
802a087cb3cSmaxv
803a087cb3cSmaxv /*
804a087cb3cSmaxv * The kernel made sure the Architectural Version 1 PMCs were
805a087cb3cSmaxv * present.
806a087cb3cSmaxv */
807a087cb3cSmaxv table = init_intel_arch1();
808a087cb3cSmaxv
809a087cb3cSmaxv /*
810a087cb3cSmaxv * Now query the additional (non-architectural) events. They
811a087cb3cSmaxv * depend on the CPU model.
812a087cb3cSmaxv */
813a087cb3cSmaxv eax = 0x01;
814a087cb3cSmaxv ebx = 0;
815a087cb3cSmaxv ecx = 0;
816a087cb3cSmaxv edx = 0;
817a087cb3cSmaxv x86_cpuid(&eax, &ebx, &ecx, &edx);
818a087cb3cSmaxv
81948aa8146Smaxv if (CPUID_TO_FAMILY(eax) == 6) {
820a087cb3cSmaxv switch (CPUID_TO_MODEL(eax)) {
821a8700cbeSknakahara case 0x37: /* Silvermont (Bay Trail) */
822f1f580f5Smsaitoh case 0x4a: /* Silvermont (Tangier) */
823f1f580f5Smsaitoh case 0x4c: /* Airmont (Braswell, Cherry Trail) */
824f1f580f5Smsaitoh case 0x4d: /* Silvermont (Avoton, Rangeley) */
825f1f580f5Smsaitoh case 0x5a: /* Silvermont (Anniedale) */
826f1f580f5Smsaitoh case 0x5d: /* Silvermont (SoFIA) */
827a8700cbeSknakahara table->next = init_intel_silvermont_airmont();
828a8700cbeSknakahara break;
829f1f580f5Smsaitoh case 0x5c: /* Goldmont (Apollo Lake) */
830f1f580f5Smsaitoh case 0x5f: /* Goldmont (Denverton) */
8314fd01caaSknakahara table->next = init_intel_goldmont();
8324fd01caaSknakahara break;
833f1f580f5Smsaitoh case 0x7a: /* Goldmont Plus (Gemini Lake) */
8344ed6c77eSknakahara table->next = init_intel_goldmontplus();
8354ed6c77eSknakahara break;
836f1f580f5Smsaitoh case 0x4e: /* Skylake */
837f1f580f5Smsaitoh case 0x5e: /* Skylake */
83806806094Smsaitoh case 0x8e: /* Kaby Lake */
83906806094Smsaitoh case 0x9e: /* Kaby Lake */
84006806094Smsaitoh case 0xa5: /* Comet Lake */
84106806094Smsaitoh case 0xa6: /* Comet Lake */
842a087cb3cSmaxv table->next = init_intel_skylake_kabylake();
843a087cb3cSmaxv break;
844*db06c1e0Smsaitoh
845*db06c1e0Smsaitoh case 0x55: /* Skylake-X, Cascade Lake */
846*db06c1e0Smsaitoh stepping = CPUID_TO_STEPPING(eax);
847*db06c1e0Smsaitoh if (stepping <= 4)
848*db06c1e0Smsaitoh table->next = init_intel_skylake_x();
849*db06c1e0Smsaitoh else
850*db06c1e0Smsaitoh table->next = init_intel_cascadelake();
851*db06c1e0Smsaitoh break;
852*db06c1e0Smsaitoh
853a087cb3cSmaxv }
85448aa8146Smaxv }
855a087cb3cSmaxv
856a087cb3cSmaxv return table;
857a087cb3cSmaxv }
858a087cb3cSmaxv
859f5823b20Smsaitoh /* ------------------------------------------------------------------------- */
860a087cb3cSmaxv
861a087cb3cSmaxv /*
862a087cb3cSmaxv * AMD Family 10h
863a087cb3cSmaxv */
864a087cb3cSmaxv static struct name_to_event amd_f10h_names[] = {
8658dd2f31aSmaxv { "seg-load-all", 0x20, 0x7f, true },
8668dd2f31aSmaxv { "seg-load-es", 0x20, 0x01, true },
8678dd2f31aSmaxv { "seg-load-cs", 0x20, 0x02, true },
8688dd2f31aSmaxv { "seg-load-ss", 0x20, 0x04, true },
8698dd2f31aSmaxv { "seg-load-ds", 0x20, 0x08, true },
8708dd2f31aSmaxv { "seg-load-fs", 0x20, 0x10, true },
8718dd2f31aSmaxv { "seg-load-gs", 0x20, 0x20, true },
8728dd2f31aSmaxv { "seg-load-hs", 0x20, 0x40, true },
8738dd2f31aSmaxv { "l1cache-access", 0x40, 0x00, true },
8748dd2f31aSmaxv { "l1cache-miss", 0x41, 0x00, true },
8758dd2f31aSmaxv { "l1cache-refill", 0x42, 0x1f, true },
8768dd2f31aSmaxv { "l1cache-refill-invalid", 0x42, 0x01, true },
8778dd2f31aSmaxv { "l1cache-refill-shared", 0x42, 0x02, true },
8788dd2f31aSmaxv { "l1cache-refill-exclusive", 0x42, 0x04, true },
8798dd2f31aSmaxv { "l1cache-refill-owner", 0x42, 0x08, true },
8808dd2f31aSmaxv { "l1cache-refill-modified", 0x42, 0x10, true },
8818dd2f31aSmaxv { "l1cache-load", 0x43, 0x1f, true },
8828dd2f31aSmaxv { "l1cache-load-invalid", 0x43, 0x01, true },
8838dd2f31aSmaxv { "l1cache-load-shared", 0x43, 0x02, true },
8848dd2f31aSmaxv { "l1cache-load-exclusive", 0x43, 0x04, true },
8858dd2f31aSmaxv { "l1cache-load-owner", 0x43, 0x08, true },
8868dd2f31aSmaxv { "l1cache-load-modified", 0x43, 0x10, true },
8878dd2f31aSmaxv { "l1cache-writeback", 0x44, 0x1f, true },
8888dd2f31aSmaxv { "l1cache-writeback-invalid", 0x44, 0x01, true },
8898dd2f31aSmaxv { "l1cache-writeback-shared", 0x44, 0x02, true },
8908dd2f31aSmaxv { "l1cache-writeback-exclusive",0x44, 0x04, true },
8918dd2f31aSmaxv { "l1cache-writeback-owner", 0x44, 0x08, true },
8928dd2f31aSmaxv { "l1cache-writeback-modified", 0x44, 0x10, true },
893f1f580f5Smsaitoh { "l1DTLB-hit-all", 0x4d, 0x07, true },
894f1f580f5Smsaitoh { "l1DTLB-hit-4Kpage", 0x4d, 0x01, true },
895f1f580f5Smsaitoh { "l1DTLB-hit-2Mpage", 0x4d, 0x02, true },
896f1f580f5Smsaitoh { "l1DTLB-hit-1Gpage", 0x4d, 0x04, true },
8978dd2f31aSmaxv { "l1DTLB-miss-all", 0x45, 0x07, true },
8988dd2f31aSmaxv { "l1DTLB-miss-4Kpage", 0x45, 0x01, true },
8998dd2f31aSmaxv { "l1DTLB-miss-2Mpage", 0x45, 0x02, true },
9008dd2f31aSmaxv { "l1DTLB-miss-1Gpage", 0x45, 0x04, true },
9018dd2f31aSmaxv { "l2DTLB-miss-all", 0x46, 0x03, true },
9028dd2f31aSmaxv { "l2DTLB-miss-4Kpage", 0x46, 0x01, true },
9038dd2f31aSmaxv { "l2DTLB-miss-2Mpage", 0x46, 0x02, true },
904a087cb3cSmaxv /* l2DTLB-miss-1Gpage: reserved on some revisions, so disabled */
9058dd2f31aSmaxv { "l1ITLB-miss", 0x84, 0x00, true },
9068dd2f31aSmaxv { "l2ITLB-miss-all", 0x85, 0x03, true },
9078dd2f31aSmaxv { "l2ITLB-miss-4Kpage", 0x85, 0x01, true },
9088dd2f31aSmaxv { "l2ITLB-miss-2Mpage", 0x85, 0x02, true },
9098dd2f31aSmaxv { "mem-misalign-ref", 0x47, 0x00, true },
9108dd2f31aSmaxv { "ins-fetch", 0x80, 0x00, true },
9118dd2f31aSmaxv { "ins-fetch-miss", 0x81, 0x00, true },
9128dd2f31aSmaxv { "ins-refill-l2", 0x82, 0x00, true },
9138dd2f31aSmaxv { "ins-refill-sys", 0x83, 0x00, true },
9148dd2f31aSmaxv { "ins-fetch-stall", 0x87, 0x00, true },
915f1f580f5Smsaitoh { "ins-retired", 0xc0, 0x00, true },
916f1f580f5Smsaitoh { "ins-empty", 0xd0, 0x00, true },
917f1f580f5Smsaitoh { "ops-retired", 0xc1, 0x00, true },
918f1f580f5Smsaitoh { "branch-retired", 0xc2, 0x00, true },
919f1f580f5Smsaitoh { "branch-miss-retired", 0xc3, 0x00, true },
920f1f580f5Smsaitoh { "branch-taken-retired", 0xc4, 0x00, true },
921f1f580f5Smsaitoh { "branch-taken-miss-retired", 0xc5, 0x00, true },
922f1f580f5Smsaitoh { "branch-far-retired", 0xc6, 0x00, true },
923f1f580f5Smsaitoh { "branch-resync-retired", 0xc7, 0x00, true },
924f1f580f5Smsaitoh { "branch-near-retired", 0xc8, 0x00, true },
925f1f580f5Smsaitoh { "branch-near-miss-retired", 0xc9, 0x00, true },
926f1f580f5Smsaitoh { "branch-indirect-miss-retired", 0xca, 0x00, true },
927f1f580f5Smsaitoh { "int-hw", 0xcf, 0x00, true },
928f1f580f5Smsaitoh { "int-cycles-masked", 0xcd, 0x00, true },
929f1f580f5Smsaitoh { "int-cycles-masked-pending", 0xce, 0x00, true },
930f1f580f5Smsaitoh { "fpu-exceptions", 0xdb, 0x00, true },
931f1f580f5Smsaitoh { "break-match0", 0xdc, 0x00, true },
932f1f580f5Smsaitoh { "break-match1", 0xdd, 0x00, true },
933f1f580f5Smsaitoh { "break-match2", 0xde, 0x00, true },
934f1f580f5Smsaitoh { "break-match3", 0xdf, 0x00, true },
935a087cb3cSmaxv };
936a087cb3cSmaxv
937a087cb3cSmaxv static struct event_table amd_f10h = {
938a087cb3cSmaxv .tablename = "AMD Family 10h",
939a087cb3cSmaxv .names = amd_f10h_names,
940a087cb3cSmaxv .nevents = sizeof(amd_f10h_names) /
941a087cb3cSmaxv sizeof(struct name_to_event),
942a087cb3cSmaxv .next = NULL
943a087cb3cSmaxv };
944a087cb3cSmaxv
9450acc4e3eSmaxv /*
9461434425dSjmcneill * AMD Family 15h
9471434425dSjmcneill */
9481434425dSjmcneill static struct name_to_event amd_f15h_names[] = {
9491434425dSjmcneill { "FpPipeAssignment", 0x000, 0x77, true },
9501434425dSjmcneill { "FpSchedulerEmpty", 0x001, 0x00, true },
9511434425dSjmcneill { "FpRetSseAvxOps", 0x003, 0xff, true },
9521434425dSjmcneill { "FpNumMovElim", 0x004, 0x0f, true },
9531434425dSjmcneill { "FpRetiredSerOps", 0x005, 0x0f, true },
9541434425dSjmcneill { "LsSegRegLoads", 0x020, 0x7f, true },
9551434425dSjmcneill { "LsPipeRestartSelfMod", 0x021, 0x00, true },
9561434425dSjmcneill { "LsPipeRestartVarious", 0x022, 0x1f, true },
9571434425dSjmcneill { "LsLoadQueueStoreQFull", 0x023, 0x03, true },
9581434425dSjmcneill { "LsLockedOps", 0x024, 0x00, true },
9591434425dSjmcneill { "LsRetClflushInstr", 0x026, 0x00, true },
9601434425dSjmcneill { "LsRetCpuidInstr", 0x027, 0x00, true },
9611434425dSjmcneill { "LsDispatch", 0x029, 0x07, true },
9621434425dSjmcneill { "LsCanStoreToLoadFwOps", 0x02a, 0x03, true },
9631434425dSjmcneill { "LsSmisReceived", 0x02b, 0x00, true },
9641434425dSjmcneill { "LsExecClflushInstr", 0x030, 0x00, true },
9651434425dSjmcneill { "LsMisalignStore", 0x032, 0x00, true },
9661434425dSjmcneill { "LsFpLoadBufStall", 0x034, 0x00, true },
9671434425dSjmcneill { "LsStlf", 0x035, 0x00, true },
9681434425dSjmcneill { "DcCacheAccess", 0x040, 0x00, true },
9691434425dSjmcneill { "DcCacheMiss", 0x041, 0x00, true },
9701434425dSjmcneill { "DcCacheFillL2Sys", 0x042, 0x1f, true },
9711434425dSjmcneill { "DcCacheFillSys", 0x043, 0x00, true },
9721434425dSjmcneill { "DcUnifiedTlbHit", 0x045, 0x77, true },
9731434425dSjmcneill { "DcUnifiedTlbMiss", 0x046, 0x77, true },
9741434425dSjmcneill { "DcMisalignAccess", 0x047, 0x00, true },
9751434425dSjmcneill { "DcPrefetchInstrDisp", 0x04b, 0x07, true },
9761434425dSjmcneill { "DcIneffSwPrefetch", 0x052, 0x09, true },
9771434425dSjmcneill { "CuCmdVictimBuf", 0x060, 0x98, true },
9781434425dSjmcneill { "CuCmdMaskedOps", 0x061, 0x65, true },
9791434425dSjmcneill { "CuCmdReadBlkOps", 0x062, 0x77, true },
9801434425dSjmcneill { "CuCmdChgDirtyOps", 0x063, 0x08, true },
9811434425dSjmcneill { "CuDramSysReq", 0x064, 0x00, true },
9821434425dSjmcneill { "CuMemReqByType", 0x065, 0x83, true },
9831434425dSjmcneill { "CuDataCachePrefetch", 0x067, 0x03, true },
9841434425dSjmcneill { "CuMabReq", 0x068, 0xff, true },
9851434425dSjmcneill { "CuMabWaitCyc", 0x069, 0xff, true },
9861434425dSjmcneill { "CuSysRespCacheFill", 0x06c, 0x3f, true },
9871434425dSjmcneill { "CuOctwordsWritten", 0x06d, 0x01, true },
9881434425dSjmcneill { "CuCacheXInv", 0x075, 0x0f, true },
9891434425dSjmcneill { "CuCpuClkNotHalted", 0x076, 0x00, true },
9901434425dSjmcneill { "CuL2Req", 0x07d, 0x5f, true },
9911434425dSjmcneill { "CuL2Miss", 0x07e, 0x17, true },
9921434425dSjmcneill { "CuL2FillWb", 0x07f, 0x07, true },
9931434425dSjmcneill { "CuPageSplintering", 0x165, 0x07, true },
9941434425dSjmcneill { "CuL2PrefetchTrigEv", 0x16c, 0x03, true },
9951434425dSjmcneill { "CuXabAllocStall", 0x177, 0x03, true },
9961434425dSjmcneill { "CuFreeXabEntries", 0x17f, 0x01, true },
9971434425dSjmcneill { "IcCacheFetch", 0x080, 0x00, true },
9981434425dSjmcneill { "IcCacheMiss", 0x081, 0x00, true },
9991434425dSjmcneill { "IcCacheFillL2", 0x082, 0x00, true },
10001434425dSjmcneill { "IcCacheFillSys", 0x083, 0x00, true },
10011434425dSjmcneill { "IcL1TlbMissL2Hit", 0x084, 0x00, true },
10021434425dSjmcneill { "IcL1TlbMissL2Miss", 0x085, 0x07, true },
10031434425dSjmcneill { "IcPipeRestartInstrStrProbe", 0x086, 0x00, true },
10041434425dSjmcneill { "IcFetchStall", 0x087, 0x00, true },
10051434425dSjmcneill { "IcRetStackHits", 0x088, 0x00, true },
10061434425dSjmcneill { "IcRetStackOver", 0x089, 0x00, true },
10071434425dSjmcneill { "IcCacheVictims", 0x08b, 0x00, true },
10081434425dSjmcneill { "IcCacheLinesInv", 0x08c, 0x0f, true },
10091434425dSjmcneill { "IcTlbReload", 0x099, 0x00, true },
10101434425dSjmcneill { "IcTlbReloadAbort", 0x09a, 0x00, true },
10111434425dSjmcneill { "IcUopsDispatched", 0x186, 0x01, true },
10121434425dSjmcneill { "ExRetInstr", 0x0c0, 0x00, true },
10131434425dSjmcneill { "ExRetCops", 0x0c1, 0x00, true },
10141434425dSjmcneill { "ExRetBrn", 0x0c2, 0x00, true },
10151434425dSjmcneill { "ExRetBrnMisp", 0x0c3, 0x00, true },
10161434425dSjmcneill { "ExRetBrnTkn", 0x0c4, 0x00, true },
10171434425dSjmcneill { "ExRetBrnTknMisp", 0x0c5, 0x00, true },
10181434425dSjmcneill { "ExRetBrnFar", 0x0c6, 0x00, true },
10191434425dSjmcneill { "ExRetBrnResync", 0x0c7, 0x00, true },
10201434425dSjmcneill { "ExRetNearRet", 0x0c8, 0x00, true },
10211434425dSjmcneill { "ExRetNearRetMispred", 0x0c9, 0x00, true },
10221434425dSjmcneill { "ExRetBrnIndMisp", 0x0ca, 0x00, true },
10231434425dSjmcneill { "ExRetMmxFpInstr@X87", 0x0cb, 0x01, true },
10241434425dSjmcneill { "ExRetMmxFpInstr@Mmx", 0x0cb, 0x02, true },
10251434425dSjmcneill { "ExRetMmxFpInstr@Sse", 0x0cb, 0x04, true },
10261434425dSjmcneill { "ExIntMaskedCyc", 0x0cd, 0x00, true },
10271434425dSjmcneill { "ExIntMaskedCycIntPend", 0x0ce, 0x00, true },
10281434425dSjmcneill { "ExIntTaken", 0x0cf, 0x00, true },
10291434425dSjmcneill { "ExDecEmpty", 0x0d0, 0x00, true },
10301434425dSjmcneill { "ExDispStall", 0x0d1, 0x00, true },
10311434425dSjmcneill { "ExUseqStallSer", 0x0d2, 0x00, true },
10321434425dSjmcneill { "ExDispStallInstrRetQFull", 0x0d5, 0x00, true },
10331434425dSjmcneill { "ExDispStallIntSchedQFull", 0x0d6, 0x00, true },
10341434425dSjmcneill { "ExDispStallFpSchedQFull", 0x0d7, 0x00, true },
10351434425dSjmcneill { "ExDispStallLdqFull", 0x0d8, 0x00, true },
10361434425dSjmcneill { "ExUseqStallAllQuiet", 0x0d9, 0x00, true },
10371434425dSjmcneill { "ExFpuEx", 0x0db, 0x1f, true },
10381434425dSjmcneill { "ExBpDr0", 0x0dc, 0x8f, true },
10391434425dSjmcneill { "ExBpDr1", 0x0dd, 0x8f, true },
10401434425dSjmcneill { "ExBpDr2", 0x0de, 0x8f, true },
10411434425dSjmcneill { "ExBpDr3", 0x0df, 0x8f, true },
10421434425dSjmcneill { "ExRetx87FpOps", 0x1c0, 0x07, true },
10431434425dSjmcneill { "ExTaggedIbsOps", 0x1cf, 0x07, true },
10441434425dSjmcneill { "ExRetFusBrInstr", 0x1d0, 0x00, true },
10451434425dSjmcneill { "ExDispStallStqFull", 0x1d8, 0x00, true },
10461434425dSjmcneill { "ExCycNoDispIntPrfTok", 0x1dd, 0x00, true },
10471434425dSjmcneill { "ExCycNoDispfpPrfTok", 0x1de, 0x00, true },
10481434425dSjmcneill { "ExFpDispContention", 0x1df, 0x0f, true },
10491434425dSjmcneill };
10501434425dSjmcneill
10511434425dSjmcneill static struct event_table amd_f15h = {
10521434425dSjmcneill .tablename = "AMD Family 15h",
10531434425dSjmcneill .names = amd_f15h_names,
10541434425dSjmcneill .nevents = sizeof(amd_f15h_names) /
10551434425dSjmcneill sizeof(struct name_to_event),
10561434425dSjmcneill .next = NULL
10571434425dSjmcneill };
10581434425dSjmcneill
10591434425dSjmcneill /*
10600acc4e3eSmaxv * AMD Family 17h
10610acc4e3eSmaxv */
10620acc4e3eSmaxv static struct name_to_event amd_f17h_names[] = {
10630acc4e3eSmaxv { "FpRetx87FpOps", 0x02, __BITS(2,0), true },
10640acc4e3eSmaxv { "FpRetSseAvxOps", 0x03, __BITS(7,0), true },
10650acc4e3eSmaxv { "FpRetiredSerOps", 0x05, __BITS(3,0), true },
10660acc4e3eSmaxv { "LsL1DTlbMiss", 0x45, __BITS(7,0), true },
10670acc4e3eSmaxv { "LsTableWalker", 0x46, __BITS(3,0), true },
10680acc4e3eSmaxv { "LsMisalAccesses", 0x47, 0x00, true },
10690acc4e3eSmaxv { "LsInefSwPref", 0x52, __BITS(1,0), true },
10700acc4e3eSmaxv { "LsNotHaltedCyc", 0x76, 0x00, true },
10710acc4e3eSmaxv { "IcFw32", 0x80, 0x00, true },
10720acc4e3eSmaxv { "IcFw32Miss", 0x81, 0x00, true },
10730acc4e3eSmaxv { "IcCacheFillL2", 0x82, 0x00, true },
10740acc4e3eSmaxv { "IcCacheFillSys", 0x83, 0x00, true },
10750acc4e3eSmaxv { "IcFetchStall", 0x87, __BITS(2,0), true },
1076f1f580f5Smsaitoh { "IcCacheInval", 0x8c, __BITS(1,0), true },
10770acc4e3eSmaxv { "BpL1TlbMissL2Hit", 0x84, 0x00, true },
10780acc4e3eSmaxv { "BpL1TlbMissL2Miss", 0x85, 0x00, true },
10790acc4e3eSmaxv { "BpSnpReSync", 0x86, 0x00, true },
1080f1f580f5Smsaitoh { "BpL1BTBCorrect", 0x8a, 0x00, true },
1081f1f580f5Smsaitoh { "BpL2BTBCorrect", 0x8b, 0x00, true },
10820acc4e3eSmaxv { "BpTlbRel", 0x99, 0x00, true },
1083f1f580f5Smsaitoh { "ExRetInstr", 0xc0, 0x00, true },
1084f1f580f5Smsaitoh { "ExRetCops", 0xc1, 0x00, true },
1085f1f580f5Smsaitoh { "ExRetBrn", 0xc2, 0x00, true },
1086f1f580f5Smsaitoh { "ExRetBrnMisp", 0xc3, 0x00, true },
1087f1f580f5Smsaitoh { "ExRetBrnTkn", 0xc4, 0x00, true },
1088f1f580f5Smsaitoh { "ExRetBrnTknMisp", 0xc5, 0x00, true },
1089f1f580f5Smsaitoh { "ExRetBrnFar", 0xc6, 0x00, true },
1090f1f580f5Smsaitoh { "ExRetBrnResync", 0xc7, 0x00, true },
1091f1f580f5Smsaitoh { "ExRetBrnIndMisp", 0xca, 0x00, true },
1092f1f580f5Smsaitoh { "ExRetNearRet", 0xc8, 0x00, true },
1093f1f580f5Smsaitoh { "ExRetNearRetMispred", 0xc9, 0x00, true },
1094f1f580f5Smsaitoh { "ExRetMmxFpInstr@X87", 0xcb, __BIT(0), true },
1095f1f580f5Smsaitoh { "ExRetMmxFpInstr@Mmx", 0xcb, __BIT(1), true },
1096f1f580f5Smsaitoh { "ExRetMmxFpInstr@Sse", 0xcb, __BIT(2), true },
1097f1f580f5Smsaitoh { "ExRetCond", 0xd1, 0x00, true },
1098f1f580f5Smsaitoh { "ExRetCondMisp", 0xd2, 0x00, true },
1099f1f580f5Smsaitoh { "ExDivBusy", 0xd3, 0x00, true },
1100f1f580f5Smsaitoh { "ExDivCount", 0xd4, 0x00, true },
11010acc4e3eSmaxv };
11020acc4e3eSmaxv
11030acc4e3eSmaxv static struct event_table amd_f17h = {
11040acc4e3eSmaxv .tablename = "AMD Family 17h",
11050acc4e3eSmaxv .names = amd_f17h_names,
11060acc4e3eSmaxv .nevents = sizeof(amd_f17h_names) /
11070acc4e3eSmaxv sizeof(struct name_to_event),
11080acc4e3eSmaxv .next = NULL
11090acc4e3eSmaxv };
1110a087cb3cSmaxv
1111db24b2c2Smsaitoh /*
1112db24b2c2Smsaitoh * AMD Family 19h
1113db24b2c2Smsaitoh * From PPR:
1114db24b2c2Smsaitoh * - f19h model 01h B1 (zen3)
1115db24b2c2Smsaitoh * - f19h model 11h B1 (zen4)
1116db24b2c2Smsaitoh * - f19h model 21h B1 (zen3)
1117db24b2c2Smsaitoh * - f19h model 51h A1 (zen3)
1118db24b2c2Smsaitoh */
1119db24b2c2Smsaitoh static struct name_to_event amd_f19h_names[] = {
1120db24b2c2Smsaitoh /* Model 1x only */
1121db24b2c2Smsaitoh { "FpRetx87FpOps", 0x02, __BITS(2,0), true },
1122db24b2c2Smsaitoh
1123db24b2c2Smsaitoh /* Only model 1x has bit 4 */
1124db24b2c2Smsaitoh { "FpRetSseAvxOps", 0x03, __BITS(4,0), true },
1125db24b2c2Smsaitoh
1126db24b2c2Smsaitoh { "FpRetiredSerOps", 0x05, __BITS(3,0), true },
1127db24b2c2Smsaitoh
1128db24b2c2Smsaitoh /* Model 1x only */
1129db24b2c2Smsaitoh { "FpOpsRetiredByWidth", 0x08, __BITS(5,0), true },
1130db24b2c2Smsaitoh { "FpOpsRetiredByType", 0x0a, __BITS(7,0), true },
1131db24b2c2Smsaitoh { "SseAvxOpsRetired", 0x0b, __BITS(7,0), true },
1132db24b2c2Smsaitoh { "FpPackOpsRetired", 0x0c, __BITS(7,0), true },
1133db24b2c2Smsaitoh { "PackedIntOpType", 0x0d, __BITS(7,0), true },
1134db24b2c2Smsaitoh
1135db24b2c2Smsaitoh { "FpDispFaults", 0x0e, __BITS(3,0), true },
1136db24b2c2Smsaitoh { "LsBadStatus2", 0x24, __BIT(1), true },
1137db24b2c2Smsaitoh { "LsLocks", 0x25, __BIT(0), true },
1138db24b2c2Smsaitoh { "LsRetClClush", 0x26, 0x00, true },
1139db24b2c2Smsaitoh { "LsRetCpuid", 0x27, 0x00, true },
1140db24b2c2Smsaitoh { "LsDispatch", 0x29, __BITS(2,0), true },
1141db24b2c2Smsaitoh { "LsSmiRx", 0x2b, 0x00, true },
1142db24b2c2Smsaitoh { "LsIntTaken", 0x2c, 0x00, true },
1143db24b2c2Smsaitoh { "LsSTLF", 0x35, 0x00, true },
1144db24b2c2Smsaitoh { "LsStCommitCancel2", 0x37, __BIT(0), true },
1145db24b2c2Smsaitoh { "LsMabAlloc-ls", 0x41, 0x3f, true },
1146db24b2c2Smsaitoh { "LsMabAlloc-hp", 0x41, 0x40, true },
1147db24b2c2Smsaitoh { "LsMabAlloc-all", 0x41, 0x7f, true },
1148db24b2c2Smsaitoh { "LsDmndFillsFromSys", 0x43, 0x5f, true },
1149db24b2c2Smsaitoh
1150db24b2c2Smsaitoh /* Only model 1x has bit 7 */
1151db24b2c2Smsaitoh { "LsAnyFillsFromSys", 0x44, 0xdf, true },
1152db24b2c2Smsaitoh
1153db24b2c2Smsaitoh { "LsL1DTlbMiss", 0x45, __BITS(7,0), true },
1154db24b2c2Smsaitoh { "LsMisalLoads-MA64", 0x47, __BIT(0), true },
1155db24b2c2Smsaitoh { "LsMisalLoads-MA4K", 0x47, __BIT(1), true },
1156db24b2c2Smsaitoh { "LsMisalLoads-all", 0x47, __BITS(1,0), true },
1157db24b2c2Smsaitoh { "LsPrefInstrDisp", 0x4b, __BITS(2,0), true },
1158db24b2c2Smsaitoh { "LsInefSwPref", 0x52, __BITS(1,0), true },
1159db24b2c2Smsaitoh
1160db24b2c2Smsaitoh /* Only model 1x has bit 7 */
1161db24b2c2Smsaitoh { "LsSwPfDcFills", 0x59, 0xdf, true },
1162db24b2c2Smsaitoh { "LsHwPfDcFills", 0x5a, 0xdf, true },
1163db24b2c2Smsaitoh
1164db24b2c2Smsaitoh { "LsAllocMabCount", 0x5f, 0x00, true },
1165db24b2c2Smsaitoh { "LsNotHaltedCyc", 0x76, 0x00, true },
1166db24b2c2Smsaitoh
1167db24b2c2Smsaitoh /* Model 0x, 1x and 2x only */
1168db24b2c2Smsaitoh { "LsTlbFlush", 0x78, 0xff, true },
1169db24b2c2Smsaitoh
1170db24b2c2Smsaitoh /* Model 1x only */
1171db24b2c2Smsaitoh { "LsNotHaltedP0Cyc", 0x120, __BIT(0), true },
1172db24b2c2Smsaitoh
1173db24b2c2Smsaitoh { "IcCacheFillL2", 0x82, 0x00, true },
1174db24b2c2Smsaitoh { "IcCacheFillSys", 0x83, 0x00, true },
1175db24b2c2Smsaitoh { "BpL1TlbMissL2TlbHit", 0x84, 0x00, true },
1176db24b2c2Smsaitoh { "BpL1TlbMissL2TlbMiss-IF4K", 0x85, __BIT(0), true },
1177db24b2c2Smsaitoh { "BpL1TlbMissL2TlbMiss-IF2M", 0x85, __BIT(1), true },
1178db24b2c2Smsaitoh { "BpL1TlbMissL2TlbMiss-IF1G", 0x85, __BIT(2), true },
1179db24b2c2Smsaitoh { "BpL1TlbMissL2TlbMiss-Coalesced4K", 0x85, __BIT(3), true },
1180db24b2c2Smsaitoh { "BpL1TlbMissL2TlbMiss-all", 0x85, __BITS(3,0), true },
1181db24b2c2Smsaitoh
1182db24b2c2Smsaitoh { "BpL2BTBCorrect", 0x8b, 0x00, true },
1183db24b2c2Smsaitoh { "BpDynIndPred", 0x8e, 0x00, true },
1184db24b2c2Smsaitoh { "BpDeReDirect", 0x91, 0x00, true },
1185db24b2c2Smsaitoh { "BpL1TlbFetchHit-IF4K", 0x94, __BIT(0), true },
1186db24b2c2Smsaitoh { "BpL1TlbFetchHit-IF2M", 0x94, __BIT(1), true },
1187db24b2c2Smsaitoh { "BpL1TlbFetchHit-IF1G", 0x94, __BIT(2), true },
1188db24b2c2Smsaitoh { "BpL1TlbFetchHit-all", 0x94, __BITS(2,0), true },
1189db24b2c2Smsaitoh
1190db24b2c2Smsaitoh /* Model 1x only */
1191db24b2c2Smsaitoh { "ResyncsOrNcRedirects", 0x96, 0x00, true },
1192db24b2c2Smsaitoh
1193db24b2c2Smsaitoh { "IcTagHitMiss-hit", 0x18e, 0x07, true },
1194db24b2c2Smsaitoh { "IcTagHitMiss-miss", 0x18e, 0x18, true },
1195db24b2c2Smsaitoh { "IcTagHitMiss-all", 0x18e, 0x1f, true },
1196db24b2c2Smsaitoh { "OpCacheHitMiss-hit", 0x28f, 0x03, true },
1197db24b2c2Smsaitoh { "OpCacheHitMiss-miss", 0x28f, 0x04, true },
1198db24b2c2Smsaitoh { "OpCacheHitMiss-all", 0x28f, 0x07, true },
1199db24b2c2Smsaitoh { "DeOpQueueEmpty", 0xa9, 0x00, true },
1200db24b2c2Smsaitoh
1201db24b2c2Smsaitoh /*
1202db24b2c2Smsaitoh * Model 0x and 1x only.
1203db24b2c2Smsaitoh * Only model 1x has bit 2.
1204db24b2c2Smsaitoh */
1205db24b2c2Smsaitoh { "DeSrcOpDisp", 0xaa, __BITS(2,0), true },
1206db24b2c2Smsaitoh
1207db24b2c2Smsaitoh { "DeDisOpsFromDecoder-Fp-Ibs", 0xab, 0x04, true },
1208db24b2c2Smsaitoh { "DeDisOpsFromDecoder-Int-Ibs", 0xab, 0x08, true },
1209db24b2c2Smsaitoh
1210db24b2c2Smsaitoh /* Model 0x, 2x and newer */
1211db24b2c2Smsaitoh { "DeDisOpsFromDecoder-Fp-Ret", 0xab, 0x84, true },
1212db24b2c2Smsaitoh { "DeDisOpsFromDecoder-Int-Ret", 0xab, 0x88, true },
1213db24b2c2Smsaitoh
1214db24b2c2Smsaitoh { "DeDisDispatchTokenStalls1", 0xae, 0xf7, true },
1215db24b2c2Smsaitoh { "DeDisDispatchTokenStalls2", 0xaf, 0x2f, true },
1216db24b2c2Smsaitoh
1217db24b2c2Smsaitoh /* Model 1x only */
1218db24b2c2Smsaitoh { "DeNoDispatchPerSolt-empty", 0x1a0, 0x01, true },
1219db24b2c2Smsaitoh { "DeNoDispatchPerSolt-backend", 0x1a0, 0x1e, true },
1220db24b2c2Smsaitoh { "DeNoDispatchPerSolt-otherSMT", 0x1a0, 0x60, true },
1221db24b2c2Smsaitoh { "DeAdditionalResourceStalls", 0x1a2, 0x30, true },
1222db24b2c2Smsaitoh
1223db24b2c2Smsaitoh { "ExRetInstr", 0xc0, 0x00, true },
1224db24b2c2Smsaitoh { "ExRetCops", 0xc1, 0x00, true },
1225db24b2c2Smsaitoh { "ExRetBrn", 0xc2, 0x00, true },
1226db24b2c2Smsaitoh { "ExRetBrnMisp", 0xc3, 0x00, true },
1227db24b2c2Smsaitoh { "ExRetBrnTkn", 0xc4, 0x00, true },
1228db24b2c2Smsaitoh { "ExRetBrnTknMisp", 0xc5, 0x00, true },
1229db24b2c2Smsaitoh { "ExRetBrnFar", 0xc6, 0x00, true },
1230db24b2c2Smsaitoh { "ExRetBrnIndMisp", 0xca, 0x00, true },
1231db24b2c2Smsaitoh { "ExRetNearRet", 0xc8, 0x00, true },
1232db24b2c2Smsaitoh { "ExRetNearRetMispred", 0xc9, 0x00, true },
1233db24b2c2Smsaitoh { "ExRetMmxFpInstr@X87", 0xcb, __BIT(0), true },
1234db24b2c2Smsaitoh { "ExRetMmxFpInstr@Mmx", 0xcb, __BIT(1), true },
1235db24b2c2Smsaitoh { "ExRetMmxFpInstr@Sse", 0xcb, __BIT(2), true },
1236db24b2c2Smsaitoh { "ExRetIndBrchInstr", 0xcc, 0x00, true },
1237db24b2c2Smsaitoh { "ExRetCond", 0xd1, 0x00, true },
1238db24b2c2Smsaitoh { "ExDivBusy", 0xd3, 0x00, true },
1239db24b2c2Smsaitoh { "ExDivCount", 0xd4, 0x00, true },
1240db24b2c2Smsaitoh
1241db24b2c2Smsaitoh /* Model 1x only */
1242db24b2c2Smsaitoh { "ExDivCount-LoadAndALU", 0xd6, 0x1f, true },
1243db24b2c2Smsaitoh { "ExDivCount-Load", 0xd6, 0xbf, true },
1244db24b2c2Smsaitoh { "ExRetUcodeInstr", 0x1c1, 0x00, true },
1245db24b2c2Smsaitoh { "ExRetUcodeOps", 0x1c2, 0x00, true },
1246db24b2c2Smsaitoh
1247db24b2c2Smsaitoh { "ExRetMsprdBrnchInstrDirMsmtch", 0x1c7, 0x00, true },
1248db24b2c2Smsaitoh
1249db24b2c2Smsaitoh /* Model 1x only */
1250db24b2c2Smsaitoh { "ExRetUncondBrnchInstrMspred", 0x1c8, 0x00, true },
1251db24b2c2Smsaitoh { "ExRetUncondBrnchInstr", 0x1c8, 0x00, true },
1252db24b2c2Smsaitoh
1253db24b2c2Smsaitoh { "ExTaggedIbsOps", 0x1cf, __BITS(2,0), true },
1254db24b2c2Smsaitoh { "ExRetFusedInstr", 0x1d0, 0x00, true },
1255db24b2c2Smsaitoh
1256db24b2c2Smsaitoh /* Only model 1x has bit 0 */
1257db24b2c2Smsaitoh { "L2RequestG1", 0x60, __BITS(7,1), true },
1258db24b2c2Smsaitoh
1259db24b2c2Smsaitoh { "L2CacheReqStart", 0x64, __BITS(7,0), true },
1260db24b2c2Smsaitoh { "L2PfHitL2-L2", 0x70, __BITS(4,0), true },
1261db24b2c2Smsaitoh { "L2PfHitL2-L1", 0x70, __BITS(7,5), true },
1262db24b2c2Smsaitoh { "L2PfHitL2-all", 0x70, __BITS(7,0), true },
1263db24b2c2Smsaitoh { "L2PfMissL2HitL3-L2", 0x71, __BITS(4,0), true },
1264db24b2c2Smsaitoh { "L2PfMissL2HitL3-L1", 0x71, __BITS(7,5), true },
1265db24b2c2Smsaitoh { "L2PfMIssL2HitL3-all", 0x71, __BITS(7,0), true },
1266db24b2c2Smsaitoh { "L2PfMissL2L3-L2", 0x72, __BITS(4,0), true },
1267db24b2c2Smsaitoh { "L2PfMissL2L3-L1", 0x72, __BITS(7,5), true },
1268db24b2c2Smsaitoh { "L2PfMIssL2L3-all", 0x72, __BITS(7,0), true },
1269db24b2c2Smsaitoh
1270db24b2c2Smsaitoh { "L3LookupState-L3Miss", 0x04, __BIT(0), true },
1271db24b2c2Smsaitoh { "L3LookupState-L3Hit", 0x04, __BITS(7,1), true },
1272db24b2c2Smsaitoh { "L3LookupState-all", 0x04, __BITS(7,0), true },
1273db24b2c2Smsaitoh
1274db24b2c2Smsaitoh /* Model 0x, 2x and newer */
1275db24b2c2Smsaitoh { "XiSysFillLatency", 0x90, 0x00, true },
1276db24b2c2Smsaitoh { "XiCcxSdpReq1", 0x9a, 0x00, true },
1277db24b2c2Smsaitoh
1278db24b2c2Smsaitoh /* Model 1x only */
1279db24b2c2Smsaitoh { "XiSampledLatency", 0xac, 0x00, true },
1280db24b2c2Smsaitoh { "XiSampledLatencyRequests", 0xad, 0x00, true },
1281db24b2c2Smsaitoh };
1282db24b2c2Smsaitoh
1283db24b2c2Smsaitoh static struct event_table amd_f19h = {
1284db24b2c2Smsaitoh .tablename = "AMD Family 19h",
1285db24b2c2Smsaitoh .names = amd_f19h_names,
1286db24b2c2Smsaitoh .nevents = sizeof(amd_f19h_names) /
1287db24b2c2Smsaitoh sizeof(struct name_to_event),
1288db24b2c2Smsaitoh .next = NULL
1289db24b2c2Smsaitoh };
1290db24b2c2Smsaitoh
1291a087cb3cSmaxv static struct event_table *
init_amd_generic(void)1292a087cb3cSmaxv init_amd_generic(void)
1293a087cb3cSmaxv {
1294a087cb3cSmaxv unsigned int eax, ebx, ecx, edx;
1295a087cb3cSmaxv
1296a087cb3cSmaxv eax = 0x01;
1297a087cb3cSmaxv ebx = 0;
1298a087cb3cSmaxv ecx = 0;
1299a087cb3cSmaxv edx = 0;
1300a087cb3cSmaxv x86_cpuid(&eax, &ebx, &ecx, &edx);
1301a087cb3cSmaxv
1302a087cb3cSmaxv switch (CPUID_TO_FAMILY(eax)) {
1303a087cb3cSmaxv case 0x10:
13040acc4e3eSmaxv return &amd_f10h;
13051434425dSjmcneill case 0x15:
13061434425dSjmcneill return &amd_f15h;
13070acc4e3eSmaxv case 0x17:
13080acc4e3eSmaxv return &amd_f17h;
1309db24b2c2Smsaitoh case 0x19:
1310db24b2c2Smsaitoh return &amd_f19h;
1311a087cb3cSmaxv }
1312a087cb3cSmaxv
1313a087cb3cSmaxv return NULL;
1314a087cb3cSmaxv }
1315a087cb3cSmaxv
1316f5823b20Smsaitoh /* ------------------------------------------------------------------------- */
1317a087cb3cSmaxv
1318a087cb3cSmaxv int
tprof_event_init(uint32_t ident)1319a087cb3cSmaxv tprof_event_init(uint32_t ident)
1320a087cb3cSmaxv {
1321f5823b20Smsaitoh
1322a087cb3cSmaxv switch (ident) {
1323a087cb3cSmaxv case TPROF_IDENT_NONE:
1324a087cb3cSmaxv return -1;
1325a087cb3cSmaxv case TPROF_IDENT_INTEL_GENERIC:
1326a087cb3cSmaxv cpuevents = init_intel_generic();
1327a087cb3cSmaxv break;
1328a087cb3cSmaxv case TPROF_IDENT_AMD_GENERIC:
1329a087cb3cSmaxv cpuevents = init_amd_generic();
1330a087cb3cSmaxv break;
1331a087cb3cSmaxv }
1332a087cb3cSmaxv return (cpuevents == NULL) ? -1 : 0;
1333a087cb3cSmaxv }
1334a087cb3cSmaxv
1335a087cb3cSmaxv static void
recursive_event_list(struct event_table * table)1336a087cb3cSmaxv recursive_event_list(struct event_table *table)
1337a087cb3cSmaxv {
1338a087cb3cSmaxv size_t i;
1339a087cb3cSmaxv
1340a087cb3cSmaxv printf("%s:\n", table->tablename);
1341a087cb3cSmaxv for (i = 0; i < table->nevents; i++) {
1342a087cb3cSmaxv if (!table->names[i].enabled)
1343a087cb3cSmaxv continue;
1344a087cb3cSmaxv printf("\t%s\n", table->names[i].name);
1345a087cb3cSmaxv }
1346a087cb3cSmaxv
1347f5823b20Smsaitoh if (table->next != NULL)
1348a087cb3cSmaxv recursive_event_list(table->next);
1349a087cb3cSmaxv }
1350a087cb3cSmaxv
1351a087cb3cSmaxv void
tprof_event_list(void)1352a087cb3cSmaxv tprof_event_list(void)
1353a087cb3cSmaxv {
1354f5823b20Smsaitoh
1355a087cb3cSmaxv recursive_event_list(cpuevents);
1356a087cb3cSmaxv }
1357a087cb3cSmaxv
1358a087cb3cSmaxv static void
recursive_event_lookup(struct event_table * table,const char * name,struct tprof_param * param)1359a087cb3cSmaxv recursive_event_lookup(struct event_table *table, const char *name,
1360a087cb3cSmaxv struct tprof_param *param)
1361a087cb3cSmaxv {
1362a087cb3cSmaxv size_t i;
1363a087cb3cSmaxv
1364a087cb3cSmaxv for (i = 0; i < table->nevents; i++) {
1365a087cb3cSmaxv if (!table->names[i].enabled)
1366a087cb3cSmaxv continue;
1367a087cb3cSmaxv if (!strcmp(table->names[i].name, name)) {
1368a087cb3cSmaxv param->p_event = table->names[i].event;
1369a087cb3cSmaxv param->p_unit = table->names[i].unit;
1370a087cb3cSmaxv return;
1371a087cb3cSmaxv }
1372a087cb3cSmaxv }
1373a087cb3cSmaxv
1374f5823b20Smsaitoh if (table->next != NULL)
1375a087cb3cSmaxv recursive_event_lookup(table->next, name, param);
1376f5823b20Smsaitoh else
1377a087cb3cSmaxv errx(EXIT_FAILURE, "event '%s' unknown", name);
1378a087cb3cSmaxv }
1379a087cb3cSmaxv
1380a087cb3cSmaxv void
tprof_event_lookup(const char * name,struct tprof_param * param)1381a087cb3cSmaxv tprof_event_lookup(const char *name, struct tprof_param *param)
1382a087cb3cSmaxv {
1383f5823b20Smsaitoh
1384a087cb3cSmaxv recursive_event_lookup(cpuevents, name, param);
1385a087cb3cSmaxv }
1386