2 * Intel(R) Processor Trace PMU driver for perf
3 * Copyright (c) 2013-2014, Intel Corporation.
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.
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
14 * Intel PT is specified in the Intel Architecture Instruction Set Extensions
15 * Programming Reference:
16 * http://software.intel.com/en-us/intel-isa-extensions
19 #ifndef __INTEL_PT_H__
20 #define __INTEL_PT_H__
23 * Single-entry ToPA: when this close to region boundary, switch
24 * buffers to avoid losing data.
26 #define TOPA_PMI_MARGIN 512
30 static inline unsigned int sizes(unsigned int tsz)
32 return 1 << (tsz + TOPA_SHIFT);
48 #define PT_CPUID_LEAVES 2
49 #define PT_CPUID_REGS_NUM 4 /* number of regsters (eax, ebx, ecx, edx) */
51 enum pt_capabilities {
52 PT_CAP_max_subleaf = 0,
57 PT_CAP_topa_multiple_entries,
58 PT_CAP_single_range_output,
61 PT_CAP_cycle_thresholds,
67 u32 caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];
72 * struct pt_buffer - buffer configuration; one buffer per task_struct or
73 * cpu, depending on perf event configuration
74 * @cpu: cpu for per-cpu allocation
75 * @tables: list of ToPA tables in this buffer
76 * @first: shorthand for first topa table
77 * @last: shorthand for last topa table
78 * @cur: current topa table
79 * @nr_pages: buffer size in pages
80 * @cur_idx: current output region's index within @cur table
81 * @output_off: offset within the current output region
82 * @data_size: running total of the amount of data in this buffer
83 * @lost: if data was lost/truncated
84 * @head: logical write offset inside the buffer
85 * @snapshot: if this is for a snapshot/overwrite counter
86 * @stop_pos: STOP topa entry in the buffer
87 * @intr_pos: INT topa entry in the buffer
88 * @data_pages: array of pages from perf
89 * @topa_index: table of topa entries indexed by page offset
93 struct list_head tables;
94 struct topa *first, *last, *cur;
97 unsigned long nr_pages;
102 unsigned long stop_pos, intr_pos;
104 struct topa_entry *topa_index[0];
108 * struct pt - per-cpu pt context
109 * @handle: perf output handle
110 * @handle_nmi: do handle PT PMI on this cpu, there's an active event
111 * @vmx_on: 1 if VMX is ON on this cpu
114 struct perf_output_handle handle;
119 #endif /* __INTEL_PT_H__ */