/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Intel(R) Processor Trace PMU driver for perf3* Copyright (c) 2013-2014, Intel Corporation.4*5* Intel PT is specified in the Intel Architecture Instruction Set Extensions6* Programming Reference:7* http://software.intel.com/en-us/intel-isa-extensions8*/910#ifndef __INTEL_PT_H__11#define __INTEL_PT_H__1213/*14* Single-entry ToPA: when this close to region boundary, switch15* buffers to avoid losing data.16*/17#define TOPA_PMI_MARGIN 5121819#define TOPA_SHIFT 122021static inline unsigned int sizes(unsigned int tsz)22{23return 1 << (tsz + TOPA_SHIFT);24};2526struct topa_entry {27u64 end : 1;28u64 rsvd0 : 1;29u64 intr : 1;30u64 rsvd1 : 1;31u64 stop : 1;32u64 rsvd2 : 1;33u64 size : 4;34u64 rsvd3 : 2;35u64 base : 40;36u64 rsvd4 : 12;37};3839struct pt_pmu {40struct pmu pmu;41u32 caps[PT_CPUID_REGS_NUM * PT_CPUID_LEAVES];42bool vmx;43bool branch_en_always_on;44unsigned long max_nonturbo_ratio;45unsigned int tsc_art_num;46unsigned int tsc_art_den;47};4849/**50* struct pt_buffer - buffer configuration; one buffer per task_struct or51* cpu, depending on perf event configuration52* @tables: list of ToPA tables in this buffer53* @first: shorthand for first topa table54* @last: shorthand for last topa table55* @cur: current topa table56* @nr_pages: buffer size in pages57* @cur_idx: current output region's index within @cur table58* @output_off: offset within the current output region59* @data_size: running total of the amount of data in this buffer60* @lost: if data was lost/truncated61* @head: logical write offset inside the buffer62* @snapshot: if this is for a snapshot/overwrite counter63* @single: use Single Range Output instead of ToPA64* @wrapped: buffer advance wrapped back to the first topa table65* @stop_pos: STOP topa entry index66* @intr_pos: INT topa entry index67* @stop_te: STOP topa entry pointer68* @intr_te: INT topa entry pointer69* @data_pages: array of pages from perf70* @topa_index: table of topa entries indexed by page offset71*/72struct pt_buffer {73struct list_head tables;74struct topa *first, *last, *cur;75unsigned int cur_idx;76size_t output_off;77unsigned long nr_pages;78local_t data_size;79local64_t head;80bool snapshot;81bool single;82bool wrapped;83long stop_pos, intr_pos;84struct topa_entry *stop_te, *intr_te;85void **data_pages;86};8788#define PT_FILTERS_NUM 48990/**91* struct pt_filter - IP range filter configuration92* @msr_a: range start, goes to RTIT_ADDRn_A93* @msr_b: range end, goes to RTIT_ADDRn_B94* @config: 4-bit field in RTIT_CTL95*/96struct pt_filter {97unsigned long msr_a;98unsigned long msr_b;99unsigned long config;100};101102/**103* struct pt_filters - IP range filtering context104* @filter: filters defined for this context105* @nr_filters: number of defined filters in the @filter array106*/107struct pt_filters {108struct pt_filter filter[PT_FILTERS_NUM];109unsigned int nr_filters;110};111112/**113* struct pt - per-cpu pt context114* @handle: perf output handle115* @filters: last configured filters116* @handle_nmi: do handle PT PMI on this cpu, there's an active event117* @vmx_on: 1 if VMX is ON on this cpu118* @pause_allowed: PERF_EF_PAUSE is allowed to stop tracing119* @resume_allowed: PERF_EF_RESUME is allowed to start tracing120* @output_base: cached RTIT_OUTPUT_BASE MSR value121* @output_mask: cached RTIT_OUTPUT_MASK MSR value122*/123struct pt {124struct perf_output_handle handle;125struct pt_filters filters;126int handle_nmi;127int vmx_on;128int pause_allowed;129int resume_allowed;130u64 output_base;131u64 output_mask;132};133134#endif /* __INTEL_PT_H__ */135136137