]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - tools/perf/arch/x86/util/auxtrace.c
Merge branches 'fixes', 'misc' and 'spectre' into for-linus
[mirror_ubuntu-jammy-kernel.git] / tools / perf / arch / x86 / util / auxtrace.c
1 /*
2 * auxtrace.c: AUX area tracing support
3 * Copyright (c) 2013-2014, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 */
15
16 #include <errno.h>
17 #include <stdbool.h>
18
19 #include "../../util/header.h"
20 #include "../../util/debug.h"
21 #include "../../util/pmu.h"
22 #include "../../util/auxtrace.h"
23 #include "../../util/intel-pt.h"
24 #include "../../util/intel-bts.h"
25 #include "../../util/evlist.h"
26
27 static
28 struct auxtrace_record *auxtrace_record__init_intel(struct perf_evlist *evlist,
29 int *err)
30 {
31 struct perf_pmu *intel_pt_pmu;
32 struct perf_pmu *intel_bts_pmu;
33 struct perf_evsel *evsel;
34 bool found_pt = false;
35 bool found_bts = false;
36
37 intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME);
38 intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME);
39
40 evlist__for_each_entry(evlist, evsel) {
41 if (intel_pt_pmu && evsel->attr.type == intel_pt_pmu->type)
42 found_pt = true;
43 if (intel_bts_pmu && evsel->attr.type == intel_bts_pmu->type)
44 found_bts = true;
45 }
46
47 if (found_pt && found_bts) {
48 pr_err("intel_pt and intel_bts may not be used together\n");
49 *err = -EINVAL;
50 return NULL;
51 }
52
53 if (found_pt)
54 return intel_pt_recording_init(err);
55
56 if (found_bts)
57 return intel_bts_recording_init(err);
58
59 return NULL;
60 }
61
62 struct auxtrace_record *auxtrace_record__init(struct perf_evlist *evlist,
63 int *err)
64 {
65 char buffer[64];
66 int ret;
67
68 *err = 0;
69
70 ret = get_cpuid(buffer, sizeof(buffer));
71 if (ret) {
72 *err = ret;
73 return NULL;
74 }
75
76 if (!strncmp(buffer, "GenuineIntel,", 13))
77 return auxtrace_record__init_intel(evlist, err);
78
79 return NULL;
80 }