github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/perf.txt (about)

     1  # Copyright 2015 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  include <linux/perf_event.h>
     5  include <linux/hw_breakpoint.h>
     6  
     7  resource fd_perf_base[fd]
     8  resource fd_perf[fd_perf_base]
     9  
    10  perf_event_open(attr ptr[in, perf_event_attr], pid pid[opt], cpu intptr[-1:16], group fd_perf[opt], flags flags[perf_flags]) fd_perf
    11  perf_event_open$cgroup(attr ptr[in, perf_event_attr], fd fd_cgroup, cpu intptr[-1:16], group fd_perf[opt], flags flags[perf_flags_cgroup]) fd_perf
    12  
    13  mmap$perf(addr vma, len len[addr], prot flags[mmap_prot], flags flags[mmap_flags], fd fd_perf, offset fileoff)
    14  
    15  ioctl$PERF_EVENT_IOC_ENABLE(fd fd_perf, cmd const[PERF_EVENT_IOC_ENABLE], flags intptr)
    16  ioctl$PERF_EVENT_IOC_DISABLE(fd fd_perf, cmd const[PERF_EVENT_IOC_DISABLE], flags intptr)
    17  ioctl$PERF_EVENT_IOC_RESET(fd fd_perf, cmd const[PERF_EVENT_IOC_RESET], flags intptr)
    18  ioctl$PERF_EVENT_IOC_REFRESH(fd fd_perf, cmd const[PERF_EVENT_IOC_REFRESH], refresh intptr)
    19  ioctl$PERF_EVENT_IOC_PERIOD(fd fd_perf, cmd const[PERF_EVENT_IOC_PERIOD], period ptr[in, int64])
    20  ioctl$PERF_EVENT_IOC_ID(fd fd_perf, cmd const[PERF_EVENT_IOC_ID], id ptr[out, int64])
    21  ioctl$PERF_EVENT_IOC_SET_OUTPUT(fd fd_perf, cmd const[PERF_EVENT_IOC_SET_OUTPUT], other fd_perf)
    22  ioctl$PERF_EVENT_IOC_SET_FILTER(fd fd_perf, cmd const[PERF_EVENT_IOC_SET_FILTER], filter ptr[in, string])
    23  ioctl$PERF_EVENT_IOC_SET_BPF(fd fd_perf, cmd const[PERF_EVENT_IOC_SET_BPF], prog fd_bpf_prog)
    24  ioctl$PERF_EVENT_IOC_PAUSE_OUTPUT(fd fd_perf, cmd const[PERF_EVENT_IOC_PAUSE_OUTPUT], arg boolptr)
    25  ioctl$PERF_EVENT_IOC_QUERY_BPF(fd fd_perf, cmd const[PERF_EVENT_IOC_QUERY_BPF], arg ptr[in, perf_event_query_bpf])
    26  ioctl$PERF_EVENT_IOC_MODIFY_ATTRIBUTES(fd fd_perf, cmd const[PERF_EVENT_IOC_MODIFY_ATTRIBUTES], arg ptr[in, perf_event_attr])
    27  
    28  perf_flags = PERF_FLAG_FD_NO_GROUP, PERF_FLAG_FD_OUTPUT, PERF_FLAG_FD_CLOEXEC
    29  perf_flags_cgroup = PERF_FLAG_PID_CGROUP, perf_flags
    30  perf_event_type = PERF_TYPE_HARDWARE, PERF_TYPE_SOFTWARE, PERF_TYPE_TRACEPOINT, PERF_TYPE_HW_CACHE, PERF_TYPE_RAW, PERF_TYPE_BREAKPOINT
    31  perf_bp_type = HW_BREAKPOINT_EMPTY, HW_BREAKPOINT_R, HW_BREAKPOINT_W, HW_BREAKPOINT_X
    32  perf_sample_type = PERF_SAMPLE_IP, PERF_SAMPLE_TID, PERF_SAMPLE_TIME, PERF_SAMPLE_ADDR, PERF_SAMPLE_READ, PERF_SAMPLE_CALLCHAIN, PERF_SAMPLE_ID, PERF_SAMPLE_CPU, PERF_SAMPLE_PERIOD, PERF_SAMPLE_STREAM_ID, PERF_SAMPLE_RAW, PERF_SAMPLE_BRANCH_STACK, PERF_SAMPLE_REGS_USER, PERF_SAMPLE_STACK_USER, PERF_SAMPLE_WEIGHT, PERF_SAMPLE_DATA_SRC, PERF_SAMPLE_IDENTIFIER, PERF_SAMPLE_TRANSACTION, PERF_SAMPLE_REGS_INTR, PERF_SAMPLE_PHYS_ADDR
    33  perf_read_format = PERF_FORMAT_TOTAL_TIME_ENABLED, PERF_FORMAT_TOTAL_TIME_RUNNING, PERF_FORMAT_ID, PERF_FORMAT_GROUP
    34  perf_branch_sample_type = PERF_SAMPLE_BRANCH_USER, PERF_SAMPLE_BRANCH_KERNEL, PERF_SAMPLE_BRANCH_HV, PERF_SAMPLE_BRANCH_ANY, PERF_SAMPLE_BRANCH_ANY_CALL, PERF_SAMPLE_BRANCH_ANY_RETURN, PERF_SAMPLE_BRANCH_IND_CALL, PERF_SAMPLE_BRANCH_ABORT_TX, PERF_SAMPLE_BRANCH_IN_TX, PERF_SAMPLE_BRANCH_NO_TX, PERF_SAMPLE_BRANCH_COND, PERF_SAMPLE_BRANCH_CALL_STACK, PERF_SAMPLE_BRANCH_IND_JUMP, PERF_SAMPLE_BRANCH_CALL, PERF_SAMPLE_BRANCH_NO_FLAGS, PERF_SAMPLE_BRANCH_NO_CYCLES, PERF_SAMPLE_BRANCH_TYPE_SAVE, PERF_SAMPLE_BRANCH_MAX
    35  perf_bp_lens = 1, 2, 4, 8
    36  _ = __NR_mmap2
    37  #perf_event_attr size
    38  _ = PERF_ATTR_SIZE_VER0, PERF_ATTR_SIZE_VER1, PERF_ATTR_SIZE_VER2, PERF_ATTR_SIZE_VER3, PERF_ATTR_SIZE_VER4, PERF_ATTR_SIZE_VER5
    39  #perf_event_attr config field
    40  _ = PERF_COUNT_HW_CPU_CYCLES, PERF_COUNT_HW_INSTRUCTIONS, PERF_COUNT_HW_CACHE_REFERENCES, PERF_COUNT_HW_CACHE_MISSES, PERF_COUNT_HW_BRANCH_INSTRUCTIONS, PERF_COUNT_HW_BRANCH_MISSES, PERF_COUNT_HW_BUS_CYCLES, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PERF_COUNT_HW_REF_CPU_CYCLES, PERF_COUNT_HW_MAX
    41  _ = PERF_COUNT_SW_CPU_CLOCK, PERF_COUNT_SW_TASK_CLOCK, PERF_COUNT_SW_PAGE_FAULTS, PERF_COUNT_SW_CONTEXT_SWITCHES, PERF_COUNT_SW_CPU_MIGRATIONS, PERF_COUNT_SW_PAGE_FAULTS_MIN, PERF_COUNT_SW_PAGE_FAULTS_MAJ, PERF_COUNT_SW_ALIGNMENT_FAULTS, PERF_COUNT_SW_EMULATION_FAULTS, PERF_COUNT_SW_DUMMY, PERF_COUNT_SW_BPF_OUTPUT
    42  
    43  perf_event_attr {
    44  	type				flags[perf_event_type, int32]
    45  	size				len[parent, int32]
    46  # TODO: config can contain lots of various flags depending on type.
    47  # this is a hacky way to generate something reasonable.
    48  	config0				int8
    49  	config1				int8
    50  	config2				int8
    51  	config3				int8
    52  	config4				const[0, int32]
    53  	sample_freq			int64
    54  	sample_type			flags[perf_sample_type, int64]
    55  	read_format			flags[perf_read_format, int64]
    56  
    57  	disabled			int64:1
    58  	inherit				int64:1
    59  	pinned				int64:1
    60  	exclusive			int64:1
    61  	exclude_user			int64:1
    62  	exclude_kernel			int64:1
    63  	exclude_hv			int64:1
    64  	exclude_idle			int64:1
    65  	mmap				int64:1
    66  	comm				int64:1
    67  	freq				int64:1
    68  	inherit_stat			int64:1
    69  	enable_on_exec			int64:1
    70  	task				int64:1
    71  	watermark			int64:1
    72  	precise_ip			int64:2
    73  	mmap_data			int64:1
    74  	sample_id_all			int64:1
    75  	exclude_host			int64:1
    76  	exclude_guest			int64:1
    77  	exclude_callchain_kernel	int64:1
    78  	exclude_callchain_user		int64:1
    79  	mmap2				int64:1
    80  	comm_exec			int64:1
    81  	use_clockid			int64:1
    82  	context_switch			int64:1
    83  	write_backward			int64:1
    84  	namespaces			int64:1
    85  	ksymbol				int64:1
    86  	bpf_event			int64:1
    87  	aux_output			int64:1
    88  	cgroup				int64:1
    89  	text_poke			int64:1
    90  	build_id			int64:1
    91  	inherit_thread			int64:1
    92  	remove_on_exec			int64:1
    93  	sigtrap				int64:1
    94  	__reserved_1			const[0, int64:26]
    95  
    96  	wakeup_events			int32
    97  	bp_type				flags[perf_bp_type, int32]
    98  	bp_config			perf_bp_config
    99  	branch_sample_type		flags[perf_branch_sample_type, int64]
   100  	sample_regs_user		int64
   101  	sample_stack_user		int32
   102  	clockid				flags[clock_type, int32]
   103  	sample_regs_intr		int64
   104  	aux_watermark			int32
   105  	sample_max_stack		int16
   106  	__reserved_2			const[0, int16]
   107  	aux_sample_size			int32
   108  	__reserved_3			const[0, int32]
   109  	sig_data			int64
   110  }
   111  
   112  perf_bp_config [
   113  	perf_bp		perf_bp
   114  	perf_config_ext	perf_config_ext
   115  ]
   116  
   117  perf_bp {
   118  	bp_addr	ptr64[out, int8]
   119  	bp_len	flags[perf_bp_lens, int64]
   120  }
   121  
   122  perf_config_ext {
   123  	config1	int64
   124  	config2	int64
   125  }
   126  
   127  perf_event_query_bpf {
   128  	ids_len		len[ids, int32]
   129  	prog_cnt	const[0, int32]
   130  	ids		array[const[0, int32]]
   131  }