├── .gitignore ├── CHANGES ├── COPYING ├── Makefile ├── Makefile.globals.inc ├── Makefile.papi.inc ├── README ├── TODO ├── crashes ├── .gitignore ├── Makefile ├── README ├── arm_map_hw_event_oops.c ├── arm_validate_event_oops.c ├── css_cgroup_crash.c ├── nmi_soft_lockup.c ├── offcore_response_mask.c ├── oflo_sw_cpu_clock_crash.c ├── pe_inherit_memleak.c ├── pe_task_schedule_panic.c ├── perf_ftrace_event_crash.c ├── perf_mmap_close_bug.c ├── rapl_crash.c ├── sw_event_config_overflow.c └── tracepoint_irq_work_exit.c ├── doc ├── ftrace │ └── HOWTO └── low_level_implementation │ ├── ERRORS.txt │ ├── README │ ├── perf_event_open.txt │ ├── scheduler.txt │ └── task_sched_in.txt ├── exploits ├── Makefile ├── README └── arm_perf_exploit.c ├── fuzzer ├── .gitignore ├── Makefile ├── README ├── TODO ├── active_events.c ├── bugs-found │ ├── 3.10-rc5.kernel_events_2122_warning.html │ ├── 3.12.bad_page_map.html │ ├── 3.12.core2_nmi_flood.html │ ├── 3.13.task_output.html │ ├── 3.14-rc.kernel_event_core_5659_warning.html │ ├── 3.14-rc.null_constraint.html │ ├── 3.14-rc1.x32_filp_reboot.html │ ├── 3.14-rc3.cr2_corruption.html │ ├── 3.14-rc3.perf_event_1158_warning.html │ ├── 3.14-rc5.breakpoint_warning.html │ ├── 3.14-rc5.perf_event_overflow.html │ ├── 3.14-rc5.rbtree_hrtimer.html │ ├── 3.14-rc6.do_page_fault.html │ ├── 3.14-rc6.perf_sw_event.html │ ├── 3.14-rc6.x86_schedule_events.html │ ├── 3.14-rc8.perf_event_exit_task_lockdep.html │ ├── 3.14.ftrace_graph_exit_task.html │ ├── 3.14.perf_event_1076_warning.html │ ├── 3.15-memory-corruption.html │ ├── 3.15-next.perf_remove_from_context_gpf.html │ ├── 3.15-rc.flag_range_check.html │ ├── 3.15-rc1.irq_loop_warning.html │ ├── 3.15-rc1.perf_swevent_del_bug.html │ ├── 3.15-rc1.sample_period_overflow.html │ ├── 3.15-rc2.kernel_events_2384_warning.html │ ├── 3.15-rc3.kvm_mmap_corruption.html │ ├── 3.15-rc4.list_del_warning.html │ ├── 3.15-rc4.p4_pmu_schedule_events.html │ ├── 3.15-rc4.p4_x86_pmu_start_stop_warning.html │ ├── 3.15-rc4.perf_event_init_context_oops.html │ ├── 3.15-rc5.get_cpu_context_gpf.html │ ├── 3.15-rc5.mutex_lock_nested.html │ ├── 3.15-rc7.find_get_context_hang.html │ ├── 3.17+.0day-bug.html │ ├── 3.17-rc4.core2_reboot.html │ ├── 3.17-rc6.arm64_stall.html │ ├── 3.17-rc6.do_IRQ_overflown.html │ ├── 3.17-rc7.bug_uncore_assign_events.html │ ├── 3.17-rc7.put_ctx_lockup.html │ ├── 3.19-next.add_event_to_context_warning.html │ ├── 3.19-next.perf_mmap_gpf.html │ ├── 3.19-rc5.haswell_x86_pmu_del_warning.html │ ├── 3.19-rc5.rapl_scale_crash.html │ ├── 3.19-rc6.perf_remove_from_context_hang.html │ ├── 3.19.0+.breakpoint_warning.html │ ├── 3.19.0+.perf_callchain_hang.html │ ├── 3.19.0+.snb_uncore_imc_event_start_crash.html │ ├── 3.19.0+.x86_pmu_event_init_crash.html │ ├── 3.2-sparc.bad_page.html │ ├── 3.3.perf_event_1076_warning.html │ ├── 4.0-rc1.perf_mem_leak.html │ ├── 4.0-rc2.arm_group.html │ ├── 4.1-rc2.kill_fasync.html │ ├── 4.1-rc2.x86_pmu_start_warning.html │ ├── 4.1-rc7.aux_spinlock_recursion.html │ ├── 4.1-rc7.warning_perf_aux_output_begin.html │ ├── 4.1-rc7.warning_replace_preds.html │ ├── 4.1-rc8.warning_replace_preds.html │ ├── 4.1.0-rc1-next.perf_event_ctx_lock.html │ ├── 4.2-rc0.intel_pmu_drain_pebs_nhm_warning.html │ ├── 4.2-rc0.intel_pmu_lbr_disable_warning.html │ ├── 4.2-rc0.x86_pmu_stop_warning.html │ ├── 4.2-rc1.kprobe_warnings.html │ ├── 4.20-rc1.bts.html │ ├── 4.20-rc5.prepare_sample.html │ ├── 4.4-rc4.amd_ibs_crash.html │ ├── 4.8-rc0.haswell_perf_cgroup_attach.html │ ├── 4.8-rc1.haswell_disable_gpf.html │ ├── 4.8-rc1.haswell_event_function_local.html │ ├── 4.8-rc1.haswell_perf_mmap_close.html │ ├── 4.8-rc1.haswell_rb_free_aux.html │ ├── 4.8-rc1.haswell_slab_bitflip.html │ ├── 4.8-rc1.haswell_spinlock_hang.html │ ├── 4.8-rc2.amd_nb_bug.html │ ├── 4.8-rc3.perf_read_warn.html │ ├── 4.9-rc0.p4_nmi.html │ ├── 4.9-rc1.overlap_scheduling.html │ ├── 4.9-rc1.uncore_get_constraint.html │ ├── 4.9-rc1.vmalloc_fault.html │ ├── 4.9-rc5.kasan_imc_uncore.html │ ├── 4.9-rc5.kasan_token.html │ ├── 4.9-rc5.kasan_unwind.html │ ├── 5.11-rc5.pebs.html │ ├── Makefile │ ├── NEW_BUGS │ ├── bugs_found.html │ └── kernel_panics.html ├── fast_repro.sh ├── fast_repro2.sh ├── fast_repro3.sh ├── fast_repro98.sh ├── fast_repro99.sh ├── filter_address.c ├── filter_address.h ├── filter_log.c ├── filter_tracepoint.c ├── filter_tracepoint.h ├── fuzz_access.c ├── fuzz_access.h ├── fuzz_close.c ├── fuzz_close.h ├── fuzz_compat.h ├── fuzz_fork.c ├── fuzz_fork.h ├── fuzz_ioctl.c ├── fuzz_ioctl.h ├── fuzz_million.c ├── fuzz_million.h ├── fuzz_mmap.c ├── fuzz_mmap.h ├── fuzz_open.c ├── fuzz_open.h ├── fuzz_overflow.c ├── fuzz_overflow.h ├── fuzz_poll.c ├── fuzz_poll.h ├── fuzz_prctl.c ├── fuzz_prctl.h ├── fuzz_read.c ├── fuzz_read.h ├── fuzz_vsyscall.c ├── fuzz_vsyscall.h ├── fuzz_write.c ├── fuzz_write.h ├── fuzzer_determinism.h ├── fuzzer_logging.h ├── fuzzer_random.c ├── fuzzer_random.h ├── fuzzer_stats.c ├── fuzzer_stats.h ├── get_cpuinfo.c ├── get_cpuinfo.h ├── log_to_code.c ├── parse_log.c ├── parse_log.h ├── perf_attr_print.c ├── perf_attr_print.h ├── perf_fuzzer.c ├── perf_fuzzer.h ├── pmus.h ├── replay_log.c ├── trace_filters.h ├── trinity_files │ ├── Makefile │ ├── README │ ├── diff_trinity.sh │ ├── fds.c │ ├── generic-sanitise.c │ ├── include │ │ ├── arch-aarch64.h │ │ ├── arch-alpha.h │ │ ├── arch-arm.h │ │ ├── arch-i386.h │ │ ├── arch-ia64.h │ │ ├── arch-mips.h │ │ ├── arch-parisc.h │ │ ├── arch-ppc.h │ │ ├── arch-s390.h │ │ ├── arch-sh.h │ │ ├── arch-sparc.h │ │ ├── arch-syscalls.h │ │ ├── arch-x86-64.h │ │ ├── arch.h │ │ ├── child.h │ │ ├── compat.h │ │ ├── constants.h │ │ ├── exit.h │ │ ├── log.h │ │ ├── maps.h │ │ ├── perf.h │ │ ├── pids.h │ │ ├── random.h │ │ ├── sanitise.h │ │ ├── shm.h │ │ ├── syscall.h │ │ ├── tables.h │ │ ├── trinity.h │ │ ├── types.h │ │ └── utils.h │ ├── interesting-numbers.c │ ├── log.c │ ├── perf_event_open.c │ ├── pids.c │ ├── random-address.c │ ├── random-length.c │ ├── random.c │ ├── shm.c │ ├── unicode.c │ └── utils.c └── version.h ├── include ├── Makefile ├── bpf.h ├── bpf_common.h ├── bpf_helpers.h ├── branches_testcode.h ├── detect_cache.h ├── hw_breakpoint.h ├── instructions_testcode.h ├── libbpf.h ├── matrix_multiply.h ├── nops_testcode.h ├── papi_helpers.h ├── parse_record.h ├── perf_barrier.h ├── perf_event.h ├── perf_helpers.h ├── test_utils.h └── tracefs_helpers.h ├── lib ├── Makefile ├── bpf_helpers.c ├── branches_testcode.c ├── detect_cache.c ├── instructions_testcode.c ├── matrix_multiply.c ├── nops_testcode.c ├── papi_helpers.c ├── parse_record.c ├── perf_helpers.c ├── test_utils.c └── tracefs_helpers.c ├── papi ├── Makefile ├── TODO ├── check_papi_latency.c ├── core2_constraints.c ├── cpufreq_scaling.c ├── event_create_race.c ├── mpx_oflo.c ├── offcore_response.c ├── overhead │ ├── 100b_none.c │ ├── 100b_papi.c │ ├── 100b_perf.c │ ├── 100b_perf_rdpmc.c │ ├── Makefile │ ├── README │ ├── parse_output.c │ └── plain.results ├── papi_cache_info.h ├── papi_hybrid_100m_one_eventset.c ├── papi_hybrid_100m_one_eventset_multiplex.c ├── papi_hybrid_100m_two_events.c ├── papi_hybrid_sleep.c ├── perfevent_generalized_events.c ├── perfevent_sw_events.c ├── standalone │ ├── matrix_multiply.c │ └── matrix_multiply_short.c ├── tools │ ├── input │ └── make_tests.c ├── unregister.c └── validation │ ├── Makefile │ ├── check_mhz_value.c │ ├── papi_bgl_oed.c │ ├── papi_bgl_tr_dpkt.c │ ├── papi_bgl_tr_full.c │ ├── papi_bgl_ts_32b.c │ ├── papi_bgl_ts_full.c │ ├── papi_br_cn.c │ ├── papi_br_ins.c │ ├── papi_br_msp.c │ ├── papi_br_ntk.c │ ├── papi_br_prc.c │ ├── papi_br_tkn.c │ ├── papi_br_ucn.c │ ├── papi_bru_idl.c │ ├── papi_btac_m.c │ ├── papi_ca_cln.c │ ├── papi_ca_inv.c │ ├── papi_ca_itv.c │ ├── papi_ca_shr.c │ ├── papi_ca_snp.c │ ├── papi_cache_info.c │ ├── papi_csr_fal.c │ ├── papi_csr_suc.c │ ├── papi_csr_tot.c │ ├── papi_dp_ops.c │ ├── papi_fad_ins.c │ ├── papi_fdv_ins.c │ ├── papi_fma_ins.c │ ├── papi_fml_ins.c │ ├── papi_fnv_ins.c │ ├── papi_fp_ins.c │ ├── papi_fp_ops.c │ ├── papi_fp_stal.c │ ├── papi_fpu_idl.c │ ├── papi_fsq_ins.c │ ├── papi_ful_ccy.c │ ├── papi_ful_icy.c │ ├── papi_fxu_idl.c │ ├── papi_hw_int.c │ ├── papi_int_ins.c │ ├── papi_l1_dca.c │ ├── papi_l1_dch.c │ ├── papi_l1_dcm.c │ ├── papi_l1_dcr.c │ ├── papi_l1_dcw.c │ ├── papi_l1_ica.c │ ├── papi_l1_ich.c │ ├── papi_l1_icm.c │ ├── papi_l1_icr.c │ ├── papi_l1_icw.c │ ├── papi_l1_ldm.c │ ├── papi_l1_stm.c │ ├── papi_l1_tca.c │ ├── papi_l1_tch.c │ ├── papi_l1_tcm.c │ ├── papi_l1_tcr.c │ ├── papi_l1_tcw.c │ ├── papi_l2_dca.c │ ├── papi_l2_dch.c │ ├── papi_l2_dcm.c │ ├── papi_l2_dcr.c │ ├── papi_l2_dcw.c │ ├── papi_l2_ica.c │ ├── papi_l2_ich.c │ ├── papi_l2_icm.c │ ├── papi_l2_icr.c │ ├── papi_l2_icw.c │ ├── papi_l2_ldm.c │ ├── papi_l2_stm.c │ ├── papi_l2_tca.c │ ├── papi_l2_tch.c │ ├── papi_l2_tcm.c │ ├── papi_l2_tcr.c │ ├── papi_l2_tcw.c │ ├── papi_l3_dca.c │ ├── papi_l3_dch.c │ ├── papi_l3_dcm.c │ ├── papi_l3_dcr.c │ ├── papi_l3_dcw.c │ ├── papi_l3_ica.c │ ├── papi_l3_ich.c │ ├── papi_l3_icm.c │ ├── papi_l3_icr.c │ ├── papi_l3_icw.c │ ├── papi_l3_ldm.c │ ├── papi_l3_stm.c │ ├── papi_l3_tca.c │ ├── papi_l3_tch.c │ ├── papi_l3_tcm.c │ ├── papi_l3_tcr.c │ ├── papi_l3_tcw.c │ ├── papi_ld_ins.c │ ├── papi_lst_ins.c │ ├── papi_lsu_idl.c │ ├── papi_mem_rcy.c │ ├── papi_mem_scy.c │ ├── papi_mem_wcy.c │ ├── papi_prf_dm.c │ ├── papi_profile.c │ ├── papi_res_stl.c │ ├── papi_sp_ops.c │ ├── papi_sr_ins.c │ ├── papi_stl_ccy.c │ ├── papi_stl_icy.c │ ├── papi_syc_ins.c │ ├── papi_tlb_dm.c │ ├── papi_tlb_im.c │ ├── papi_tlb_sd.c │ ├── papi_tlb_tl.c │ ├── papi_tot_cyc.c │ ├── papi_tot_iis.c │ ├── papi_tot_ins.c │ ├── papi_vec_dp.c │ ├── papi_vec_ins.c │ └── papi_vec_sp.c ├── perf_data_fuzzer ├── BUGS_FOUND ├── Makefile ├── create_perf_data.c ├── create_perf_data.h ├── data_read.c ├── data_read.h ├── parse_record.c ├── parse_record.h ├── perf_attr_print.c ├── perf_attr_print.h ├── perf_data.h ├── perf_data_dump.c ├── perf_data_fuzzer.c ├── test.c └── trinity_files │ ├── Makefile │ ├── README │ ├── fds.c │ ├── generic-sanitise.c │ ├── include │ ├── arch-aarch64.h │ ├── arch-alpha.h │ ├── arch-arm.h │ ├── arch-i386.h │ ├── arch-ia64.h │ ├── arch-mips.h │ ├── arch-parisc.h │ ├── arch-ppc.h │ ├── arch-s390.h │ ├── arch-sh.h │ ├── arch-sparc.h │ ├── arch-syscalls.h │ ├── arch-x86-64.h │ ├── arch.h │ ├── child.h │ ├── compat.h │ ├── constants.h │ ├── exit.h │ ├── log.h │ ├── maps.h │ ├── perf.h │ ├── pids.h │ ├── random.h │ ├── sanitise.h │ ├── shm.h │ ├── syscall.h │ ├── tables.h │ ├── trinity.h │ ├── types.h │ └── utils.h │ ├── interesting-numbers.c │ ├── log.c │ ├── perf_event_open.c │ ├── pids.c │ ├── random-address.c │ ├── random-length.c │ ├── random.c │ ├── shm.c │ ├── unicode.c │ └── utils.c ├── perf_event_h ├── perf_counter.h-2.6.31 ├── perf_event.h-2.6.32 ├── perf_event.h-2.6.33 ├── perf_event.h-2.6.34 ├── perf_event.h-2.6.35 ├── perf_event.h-2.6.36 ├── perf_event.h-2.6.37 ├── perf_event.h-2.6.38 ├── perf_event.h-2.6.39 ├── perf_event.h-3.0 ├── perf_event.h-3.1 ├── perf_event.h-3.10 ├── perf_event.h-3.11 ├── perf_event.h-3.12 ├── perf_event.h-3.13 ├── perf_event.h-3.14 ├── perf_event.h-3.15 ├── perf_event.h-3.16 ├── perf_event.h-3.17 ├── perf_event.h-3.18 ├── perf_event.h-3.19 ├── perf_event.h-3.2 ├── perf_event.h-3.3 ├── perf_event.h-3.4 ├── perf_event.h-3.5 ├── perf_event.h-3.6 ├── perf_event.h-3.7 ├── perf_event.h-3.8 ├── perf_event.h-3.9 ├── perf_event.h-4.0 ├── perf_event.h-4.1 ├── perf_event.h-4.10 ├── perf_event.h-4.11 ├── perf_event.h-4.12 ├── perf_event.h-4.13 ├── perf_event.h-4.14 ├── perf_event.h-4.15 ├── perf_event.h-4.16 ├── perf_event.h-4.17 ├── perf_event.h-4.18 ├── perf_event.h-4.19 ├── perf_event.h-4.2 ├── perf_event.h-4.20 ├── perf_event.h-4.3 ├── perf_event.h-4.4 ├── perf_event.h-4.5 ├── perf_event.h-4.6 ├── perf_event.h-4.7 ├── perf_event.h-4.8 ├── perf_event.h-4.9 ├── perf_event.h-5.0 ├── perf_event.h-5.1 ├── perf_event.h-5.10 ├── perf_event.h-5.11 ├── perf_event.h-5.12 ├── perf_event.h-5.13 ├── perf_event.h-5.14 ├── perf_event.h-5.15 ├── perf_event.h-5.16 ├── perf_event.h-5.17 ├── perf_event.h-5.18 ├── perf_event.h-5.19 ├── perf_event.h-5.2 ├── perf_event.h-5.3 ├── perf_event.h-5.4 ├── perf_event.h-5.5 ├── perf_event.h-5.6 ├── perf_event.h-5.7 ├── perf_event.h-5.8 ├── perf_event.h-5.9 ├── perf_event.h-6.0 ├── perf_event.h-6.1 ├── perf_event.h-6.10 ├── perf_event.h-6.11 ├── perf_event.h-6.12 ├── perf_event.h-6.13 ├── perf_event.h-6.14 ├── perf_event.h-6.15 ├── perf_event.h-6.15-rc1 ├── perf_event.h-6.2 ├── perf_event.h-6.3 ├── perf_event.h-6.4 ├── perf_event.h-6.5 ├── perf_event.h-6.6 ├── perf_event.h-6.7 ├── perf_event.h-6.8 └── perf_event.h-6.9 ├── results ├── a10 │ └── a10-3.16 ├── bobcat │ ├── bobcat-3.11 │ └── bobcat-3.8 ├── core2 │ ├── core2-2.6.32 │ ├── core2-2.6.33 │ ├── core2-2.6.34 │ ├── core2-2.6.35 │ ├── core2-2.6.36 │ ├── core2-2.6.37 │ ├── core2-2.6.38 │ ├── core2-2.6.39 │ ├── core2-3.0 │ ├── core2-3.1 │ ├── core2-3.10 │ ├── core2-3.11 │ ├── core2-3.12 │ ├── core2-3.12-rc1 │ ├── core2-3.12-rc4 │ ├── core2-3.13 │ ├── core2-3.13-rc3 │ ├── core2-3.13-rc4 │ ├── core2-3.14 │ ├── core2-3.14-rc1 │ ├── core2-3.15 │ ├── core2-3.15-rc6 │ ├── core2-3.15-rc7 │ ├── core2-3.16-rc5 │ ├── core2-3.16-rc5+ │ ├── core2-3.17-rc4 │ ├── core2-3.17-rc7 │ ├── core2-3.19-rc4 │ ├── core2-3.2 │ ├── core2-3.3 │ ├── core2-3.4 │ ├── core2-3.5 │ ├── core2-3.6 │ ├── core2-3.7 │ ├── core2-3.8 │ ├── core2-3.9 │ └── core2-4.0 ├── cortexA9 │ └── cortexA9-3.11-rc4 ├── haswell │ ├── haswell-3.13 │ ├── haswell-3.15-rc1 │ ├── haswell-3.15-rc5 │ ├── haswell-3.16-rc3 │ ├── haswell-3.17-rc1 │ ├── haswell-3.17-rc2 │ ├── haswell-3.19 │ ├── haswell-3.19-rc1 │ ├── haswell-3.19-rc4 │ ├── haswell-3.19-rc5 │ ├── haswell-4.1-rc4 │ ├── haswell-4.1-rc7 │ ├── haswell-4.10 │ ├── haswell-4.11 │ ├── haswell-4.11-deb │ ├── haswell-4.13-rc0 │ ├── haswell-4.13-rc1 │ ├── haswell-4.13-rc2 │ ├── haswell-4.13-rc3 │ ├── haswell-4.14-rc0 │ ├── haswell-4.14-rc4 │ ├── haswell-4.17-rc1 │ ├── haswell-4.17-rc3 │ ├── haswell-4.2-rc0 │ ├── haswell-4.2-rc7 │ ├── haswell-4.5-rc0 │ ├── haswell-4.5.0 │ ├── haswell-4.8-rc0 │ └── haswell-4.9-deb ├── ivb │ ├── ivb-3.12 │ ├── ivb-3.14 │ ├── ivb-4.0 │ ├── ivb-4.1 │ ├── ivb-4.15-deb │ └── ivb-4.8-deb └── sparc │ └── sparc-3.2 ├── run_crash_tests.sh ├── run_papi_tests.sh ├── run_tests.sh ├── tests ├── .gitignore ├── Makefile ├── README ├── attr_fields │ ├── Makefile │ ├── disabled.c │ ├── enable_on_exec.c │ ├── exclude_guest.c │ ├── exclude_host.c │ ├── exclude_hv.c │ ├── exclude_idle.c │ ├── exclude_kernel.c │ ├── exclude_user.c │ ├── exclusive.c │ ├── format_id_support.c │ ├── inherit.c │ ├── inherit_stat.c │ ├── pinned.c │ ├── read_format_range_check.c │ └── sample_type_range_check.c ├── bpf │ ├── Makefile │ ├── README │ ├── linux │ │ └── bpf.h │ ├── load_bpf.c │ ├── test_bpf.c │ └── test_bpf_output.c ├── breakpoints │ ├── Makefile │ └── breakpoint_support.c ├── bugs │ ├── Makefile │ ├── check_schedulability.c │ ├── nmi_watchdog_group_leader.c │ ├── overflow_close_bug.c │ ├── peo_zero_return.c │ ├── read_group_attached.c │ ├── sync_read_required.c │ └── test_child.c ├── constraints │ ├── Makefile │ └── check_constraints.c ├── corner_cases │ ├── Makefile │ ├── check_reset_mpx.c │ ├── context_switch_user_kernel.c │ ├── huge_events_start.c │ ├── huge_group_start.c │ ├── hw_sw_mix.c │ ├── ioctl_refresh_0.c │ ├── max_multiplex.c │ ├── max_num_events.c │ ├── multiple_active.c │ ├── overflow_requires_mmap.c │ ├── reset_leader.c │ ├── sampled_notleader_refresh.c │ ├── signal_after_close.c │ ├── signal_after_exec.c │ ├── sw_start_leader.c │ ├── wrap.c │ └── wrong_size_enospc.c ├── error_returns │ ├── Makefile │ ├── README │ ├── e2big.c │ ├── eacces.c │ ├── ebadf.c │ ├── efault.c │ ├── einval.c │ ├── emfile.c │ ├── enoent.c │ ├── enospc.c │ ├── eopnotsupp.c │ ├── eoverflow.c │ ├── eperm.c │ ├── esrch.c │ └── non-existent.c ├── flags │ ├── Makefile │ ├── flags_cgroup.c │ ├── flags_fd_no_group.c │ ├── flags_fd_output.c │ └── flags_range_check.c ├── generalized_events │ ├── Makefile │ ├── branch-misses.c │ ├── branches.c │ ├── cycles.c │ ├── instructions.c │ ├── l1-dcache-loads.c │ └── l1-dcache-stores.c ├── ioctl │ ├── Makefile │ ├── ioctl_0_enable.c │ ├── ioctl_10_query_bpf.c │ ├── ioctl_11_modify_attributes.c │ ├── ioctl_1_disable.c │ ├── ioctl_2_refresh.c │ ├── ioctl_3_reset.c │ ├── ioctl_4_period.c │ ├── ioctl_5_set_output.c │ ├── ioctl_6_set_filter.c │ ├── ioctl_7_id.c │ ├── ioctl_8_set_bpf.c │ ├── ioctl_9_pause_output.c │ └── ioctl_flag_group.c ├── multiplexing │ ├── Makefile │ ├── check_multiplexing.c │ ├── check_papi_multiplexing.c │ └── old_multiplexing.c ├── multithread │ ├── Makefile │ ├── TODO │ ├── fork_then_read.c │ ├── lots_of_forks.c │ └── open_fork_close_kill.c ├── openmp │ ├── Makefile │ ├── openmp_overflow.c │ ├── openmp_sample.c │ └── openmp_test.c ├── overflow │ ├── Makefile │ ├── breakpoint_overflow.c │ ├── overflow_large.c │ ├── overflow_poll.c │ ├── overflow_requires_wakeup.c │ ├── overflow_signal.c │ ├── overflow_skid.c │ ├── simple_overflow_leader.c │ ├── simple_overflow_leader_poll.c │ ├── simple_overflow_sibling.c │ ├── simul_oneshot_group_overflow.c │ ├── simultaneous_group_overflow.c │ ├── simultaneous_overflow.c │ ├── single_shot_overflow.c │ ├── single_shot_w_enable.c │ └── wakeup_events_overflow.c ├── periodic_stats │ ├── Makefile │ └── print_record_sample.c ├── prctl │ ├── Makefile │ ├── prctl.c │ ├── prctl_attach.c │ ├── prctl_child.c │ ├── prctl_inherit.c │ └── prctl_parent.c ├── rdpmc │ ├── Makefile │ ├── rdpmc_attach.c │ ├── rdpmc_attach_cpu.c │ ├── rdpmc_attach_global_cpu.c │ ├── rdpmc_attach_multi_enable.c │ ├── rdpmc_attach_other_cpu.c │ ├── rdpmc_comparision_mmap.c │ ├── rdpmc_comparision_readsyscall.c │ ├── rdpmc_exec.c │ ├── rdpmc_exec_papi.c │ ├── rdpmc_group.c │ ├── rdpmc_group_syswide.c │ ├── rdpmc_inlines.h │ ├── rdpmc_invalid.c │ ├── rdpmc_lib.c │ ├── rdpmc_lib.h │ ├── rdpmc_multiattach.c │ ├── rdpmc_multiattach_papi.c │ ├── rdpmc_multiplexing.c │ ├── rdpmc_pthreads.c │ ├── rdpmc_pthreads_group.c │ ├── rdpmc_reset.c │ ├── rdpmc_support.c │ ├── rdpmc_sw_events.c │ └── rdpmc_validation.c ├── record_sample │ ├── Makefile │ ├── lost_record_sample.c │ ├── mmap_multiple.c │ ├── multiple_mmap_sizes.c │ ├── overwrite_mmap.c │ ├── print_record_sample.c │ ├── record_comm.c │ ├── record_comm_exec.c │ ├── record_fork.c │ ├── record_mmap.c │ ├── record_mmap2.c │ ├── record_mmap_data.c │ ├── sample_branch_stack.c │ ├── sample_data_src.c │ ├── sample_regs_intr.c │ ├── sample_regs_user.c │ ├── sample_stack_user.c │ ├── sample_weight.c │ └── validate_record_sample.c ├── size │ ├── Makefile │ ├── header_mismatch.c │ ├── just_right.c │ ├── too_big.c │ └── too_little.c ├── socket │ ├── Makefile │ └── socket_pass.c ├── sysfs │ ├── Makefile │ └── events.c ├── tracepoints │ ├── Makefile │ └── tracepoint_alias.c ├── unfinished │ ├── multiplex_test.c │ └── rdpmc_overhead.c ├── utils │ ├── Makefile │ ├── check_paranoid.c │ └── get_cache_info.c ├── vsyscall │ ├── Makefile │ ├── vdso.c │ └── vsyscall.c ├── x86_amd │ ├── Makefile │ ├── ibs_fetch.c │ └── ibs_op.c └── x86_intel │ ├── Makefile │ ├── TODO │ ├── bts_aux.c │ ├── bts_kernel.c │ ├── fixed_ctr0.c │ ├── fixed_ctr1.c │ ├── fixed_ctr2.c │ ├── intel_features.txt │ ├── offcore_response.c │ ├── offcore_response_mask.c │ ├── pebs.c │ ├── pebs_addr.c │ ├── pebs_latency.c │ ├── pebs_registers.c │ ├── uncore_cpu_cbox.c │ ├── uncore_events.c │ ├── uncore_group_cbox.c │ └── uncore_max_cbox.c ├── tools ├── .gitignore ├── Makefile ├── event_parser.c ├── fakesys │ ├── ivb │ │ └── sys │ │ │ └── bus │ │ │ └── event_source │ │ │ └── devices │ │ │ ├── breakpoint │ │ │ ├── type │ │ │ └── uevent │ │ │ ├── cpu │ │ │ ├── events │ │ │ │ ├── branch-instructions │ │ │ │ ├── branch-misses │ │ │ │ ├── bus-cycles │ │ │ │ ├── cache-misses │ │ │ │ ├── cache-references │ │ │ │ ├── cpu-cycles │ │ │ │ ├── instructions │ │ │ │ ├── mem-loads │ │ │ │ └── stalled-cycles-frontend │ │ │ ├── format │ │ │ │ ├── any │ │ │ │ ├── cmask │ │ │ │ ├── edge │ │ │ │ ├── event │ │ │ │ ├── inv │ │ │ │ ├── ldlat │ │ │ │ ├── offcore_rsp │ │ │ │ ├── pc │ │ │ │ └── umask │ │ │ ├── rdpmc │ │ │ ├── type │ │ │ └── uevent │ │ │ ├── software │ │ │ ├── type │ │ │ └── uevent │ │ │ ├── tracepoint │ │ │ ├── type │ │ │ └── uevent │ │ │ ├── uncore_cbox_0 │ │ │ ├── cpumask │ │ │ ├── events │ │ │ │ └── clockticks │ │ │ ├── format │ │ │ │ ├── cmask │ │ │ │ ├── edge │ │ │ │ ├── event │ │ │ │ ├── inv │ │ │ │ └── umask │ │ │ ├── type │ │ │ └── uevent │ │ │ └── uncore_cbox_1 │ │ │ ├── cpumask │ │ │ ├── events │ │ │ └── clockticks │ │ │ ├── format │ │ │ ├── cmask │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ └── umask │ │ │ ├── type │ │ │ └── uevent │ └── snb_ep │ │ └── sys │ │ └── bus │ │ └── event_source │ │ └── devices │ │ ├── breakpoint │ │ ├── type │ │ └── uevent │ │ ├── cpu │ │ ├── events │ │ │ ├── branch-instructions │ │ │ ├── branch-misses │ │ │ ├── bus-cycles │ │ │ ├── cache-misses │ │ │ ├── cache-references │ │ │ ├── cpu-cycles │ │ │ ├── instructions │ │ │ ├── ref-cycles │ │ │ ├── stalled-cycles-backend │ │ │ └── stalled-cycles-frontend │ │ └── format │ │ │ ├── any │ │ │ ├── cmask │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── offcore_rsp │ │ │ ├── pc │ │ │ └── umask │ │ ├── software │ │ ├── type │ │ └── uevent │ │ ├── tracepoint │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_0 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_1 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_2 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_3 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_4 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_5 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_6 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_cbox_7 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_nid │ │ │ ├── filter_opc │ │ │ ├── filter_state │ │ │ ├── filter_tid │ │ │ ├── inv │ │ │ ├── thresh │ │ │ ├── tid_en │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_ha │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_imc_0 │ │ ├── cpumask │ │ ├── events │ │ │ ├── cas_count_read │ │ │ ├── cas_count_write │ │ │ └── clockticks │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_imc_1 │ │ ├── cpumask │ │ ├── events │ │ │ ├── cas_count_read │ │ │ ├── cas_count_write │ │ │ └── clockticks │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_imc_2 │ │ ├── cpumask │ │ ├── events │ │ │ ├── cas_count_read │ │ │ ├── cas_count_write │ │ │ └── clockticks │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_imc_3 │ │ ├── cpumask │ │ ├── events │ │ │ ├── cas_count_read │ │ │ ├── cas_count_write │ │ │ └── clockticks │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_pcu │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── filter_band0 │ │ │ ├── filter_band1 │ │ │ ├── filter_band2 │ │ │ ├── filter_band3 │ │ │ ├── inv │ │ │ ├── occ_edge │ │ │ ├── occ_invert │ │ │ ├── occ_sel │ │ │ └── thresh │ │ ├── type │ │ └── uevent │ │ ├── uncore_qpi_0 │ │ ├── cpumask │ │ ├── events │ │ │ ├── clockticks │ │ │ ├── drs_data │ │ │ ├── ncb_data │ │ │ └── txl_flits_active │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_qpi_1 │ │ ├── cpumask │ │ ├── events │ │ │ ├── clockticks │ │ │ ├── drs_data │ │ │ ├── ncb_data │ │ │ └── txl_flits_active │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_r2pcie │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_r3qpi_0 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ ├── uncore_r3qpi_1 │ │ ├── cpumask │ │ ├── format │ │ │ ├── edge │ │ │ ├── event │ │ │ ├── inv │ │ │ ├── thresh │ │ │ └── umask │ │ ├── type │ │ └── uevent │ │ └── uncore_ubox │ │ ├── cpumask │ │ ├── format │ │ ├── edge │ │ ├── event │ │ ├── inv │ │ ├── thresh │ │ └── umask │ │ ├── type │ │ └── uevent ├── trace_event_parser.c ├── trace_filter_generator.c └── trace_filters.h └── warnings ├── Makefile ├── README ├── core2_nmi_flood.c ├── kec_2122_warn.c └── pec_1076_warn.c /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.globals.inc 2 | 3 | SCRIPT_LIST = \ 4 | run_crash_tests.sh \ 5 | run_tests.sh 6 | 7 | all: 8 | $(MAKE) -C lib 9 | $(MAKE) -C tests 10 | $(MAKE) -C crashes 11 | $(MAKE) -C fuzzer 12 | $(MAKE) -C tools 13 | $(MAKE) -C warnings 14 | 15 | install: all 16 | $(MAKE) -C tests install 17 | $(MAKE) -C crashes install 18 | $(MAKE) -C fuzzer install 19 | $(MAKE) -C tools install 20 | $(MAKE) -C warnings install 21 | $(INSTALL) -m755 $(SCRIPT_LIST) $(prefix) 22 | 23 | papi: 24 | $(MAKE) -C papi 25 | 26 | clean: clean-local 27 | $(MAKE) -C lib clean 28 | $(MAKE) -C tests clean 29 | $(MAKE) -C papi clean 30 | $(MAKE) -C crashes clean 31 | $(MAKE) -C fuzzer clean 32 | $(MAKE) -C tools clean 33 | $(MAKE) -C warnings clean 34 | 35 | clean-local: 36 | @- $(RM) *~ 37 | -------------------------------------------------------------------------------- /Makefile.globals.inc: -------------------------------------------------------------------------------- 1 | # Make variables (CC, etc...) 2 | AS = $(CROSS_COMPILE)as 3 | LD = $(CROSS_COMPILE)ld 4 | CC = $(CROSS_COMPILE)gcc 5 | CPP = $(CC) -E 6 | AR = $(CROSS_COMPILE)ar 7 | NM = $(CROSS_COMPILE)nm 8 | STRIP = $(CROSS_COMPILE)strip 9 | OBJCOPY = $(CROSS_COMPILE)objcopy 10 | OBJDUMP = $(CROSS_COMPILE)objdump 11 | RANLIB = $(CROSS_COMPILE)ranlib 12 | 13 | INSTALL = /usr/bin/install 14 | 15 | prefix = /opt/perf_event_tests 16 | -------------------------------------------------------------------------------- /Makefile.papi.inc: -------------------------------------------------------------------------------- 1 | #PAPI_INCLUDE = -I/home/vweaver1/research/papi/papi.cvs.perfctr/src 2 | #PAPI_LIB = /home/vweaver1/research/papi/papi.cvs.perfctr/src/libpapi.a 3 | 4 | #PAPI_INCLUDE = -I/home/vweaver1/research/papi/papi.git/src 5 | #PAPI_LIB = /home/vweaver1/research/papi/papi.git/src/libpapi.a 6 | 7 | #PAPI_INCLUDE = -I/home/vweaver1/research/papi/releases/papi-4.1.3/src 8 | #PAPI_LIB = /home/vweaver1/research/papi/releases/papi-4.1.3/src/libpapi.a 9 | 10 | #PAPI_INCLUDE = -I/usr/local/lib 11 | #PAPI_LIB = /usr/local/lib/libpapi.a 12 | 13 | PAPI_INCLUDE = -I/usr/local/lib 14 | PAPI_LIB = -lpapi 15 | -------------------------------------------------------------------------------- /crashes/.gitignore: -------------------------------------------------------------------------------- 1 | arm_map_hw_event_oops 2 | arm_validate_event_oops 3 | css_cgroup_crash 4 | nmi_soft_lockup 5 | offcore_response_mask 6 | oflo_sw_cpu_clock_crash 7 | pe_inherit_memleak 8 | pe_task_schedule_panic 9 | perf_ftrace_event_crash 10 | perf_mmap_close_bug 11 | rapl_crash 12 | sw_event_config_overflow 13 | tracepoint_irq_work_exit 14 | -------------------------------------------------------------------------------- /crashes/rapl_crash.c: -------------------------------------------------------------------------------- 1 | /* rapl_crash.c -- bug found with perf_fuzzer */ 2 | /* by Vince Weaver 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "perf_helpers.h" 21 | 22 | int main(int argc, char **argv) { 23 | 24 | int fd; 25 | static struct perf_event_attr pe; 26 | 27 | /* Random Seed was 1421689769 */ 28 | /* /proc/sys/kernel/perf_event_max_sample_rate was 100000 */ 29 | 30 | memset(&pe,0,sizeof(struct perf_event_attr)); 31 | pe.type=6; 32 | pe.config=0x2ULL; 33 | pe.read_format=PERF_FORMAT_TOTAL_TIME_ENABLED|PERF_FORMAT_ID; /* 5 */ 34 | pe.pinned=1; 35 | pe.config1=0x39ULL; 36 | 37 | fd=perf_event_open(&pe, 38 | -1, /* all processes */ 39 | 5, /* Only cpu 5 */ 40 | -1, /* no group leader */ 41 | PERF_FLAG_FD_NO_GROUP /*1*/ ); 42 | 43 | close(fd); 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /doc/ftrace/HOWTO: -------------------------------------------------------------------------------- 1 | Instrumenting kernel: 2 | 3 | use trace_printk() 4 | trace_dump_stack(2); 5 | 6 | enable tracing inside of perf_event 7 | 8 | in kernel/events/Makefile 9 | remove 10 | -ifdef CONFIG_FUNCTION_TRACER 11 | -CFLAGS_REMOVE_core.o = -pg 12 | -endif 13 | 14 | Running: 15 | 16 | run fuzzer. Current known issues 17 | 18 | ./perf_fuzzer -t OCIRMQWPpAi -r 1392938876 19 | ./perf_fuzzer -t OCMQ -r 1393527691 20 | 21 | suspend with control-Z 22 | get pid 23 | 24 | 25 | trace-cmd record -p function -e all -P 11492 26 | trace-cmd report | less 27 | trace-cmd report -R | less (withough address remapping 28 | which can hide issues, i.e. 29 | segfault address in userspace) 30 | 31 | 32 | 33 | Trying to trace process plus idle thread (RCU release) 34 | 35 | trace-cmd record -p function -e all -P 0 -P 31679 36 | 37 | 38 | trace-cmd record -p function -e all -c -F su vince -c "./perf_fuzzer -t OCIRMQWPFpAi -s 50000 -r 139870047" 39 | 40 | trace-cmd record -e kmem -e raw_syscalls -l 'perf*' -l 'x86*' 41 | 42 | trace-cmd record -e kmem -e raw_syscalls -p function -l '*perf*' -n 'perf_event_task_tick' 43 | 44 | trace-cmd record -e raw_syscalls -p function -l '*perf*' -n 'perf_event_task_tick' -l 'x86*' -l 'intel*' 45 | 46 | -------------------------------------------------------------------------------- /doc/low_level_implementation/README: -------------------------------------------------------------------------------- 1 | Notes to myself on various perf_event paths through the kernel. 2 | 3 | -------------------------------------------------------------------------------- /doc/low_level_implementation/perf_event_open.txt: -------------------------------------------------------------------------------- 1 | ####################################################### 2 | SYSCALL_DEFINE5(perf_event_open -- kernel/events/core.c 3 | ####################################################### 4 | 5 | 6 | event = perf_event_alloc() 7 | 8 | ########################################### 9 | perf_event_alloc(() -- kernel/events/core.c 10 | ########################################### 11 | # perf_event__state_init 12 | # 13 | # pmu = perf_init_event() 14 | 15 | ########################################### 16 | # perf_init_event() -- kernel/events/core.c 17 | ########################################### 18 | # pmu = idr_find(&pmu_idr, event->attr.type); 19 | # lookup in idr? 20 | # if not in idr, try initializing event in each pmu? 21 | 22 | ctx = find_get_context(pmu, task, event->cpu); 23 | 24 | ############################################ 25 | # find_get_context() -- kernel/events/core.c 26 | ############################################ 27 | # if (!task) { then CPU 28 | # cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); 29 | # ctx = &cpuctx->ctx; 30 | # get_ctx(ctx); 31 | # return; 32 | # } 33 | # ctx = perf_lock_task_context() 34 | # if (ctx) good 35 | # else ctx = alloc_perf_context() 36 | 37 | -------------------------------------------------------------------------------- /doc/low_level_implementation/scheduler.txt: -------------------------------------------------------------------------------- 1 | 2 | PeterZ: Re: [PATCH 4/7] perf: be less pessimistic when scheduling events 3 | Tue, 25 Feb 2014 12:29:36 4 | 5 | Yeah, software events are a problem; I realized this the moment I send 6 | that email. However, software events do not have the O(n!) programming 7 | fail hw events have. 8 | 9 | AMD Fam15h has a O(n^4) termination of the O(n*n!) algorithm, the rest 10 | of x86 has a normal O(n^2) bound. 11 | 12 | -------------------------------------------------------------------------------- /exploits/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../include 4 | CFLAGS += -Wall -O2 5 | 6 | PROGRAM_LIST = arm_perf_exploit 7 | 8 | all: $(PROGRAM_LIST) 9 | 10 | arm_perf_exploit: arm_perf_exploit.o 11 | 12 | clean: clean-local 13 | @- $(RM) $(PROGRAM_LIST) 14 | @- $(RM) *.o 15 | 16 | clean-local: 17 | @- $(RM) *~ 18 | -------------------------------------------------------------------------------- /exploits/README: -------------------------------------------------------------------------------- 1 | This directory holds local-kernel exploits I've found in the perf_event interface. 2 | 3 | In case the vulnerability isn't announced yet, I'll include the md5sum here but 4 | won't push the exploit code. 5 | 6 | a8bc5d6c4a517a9403f73cafdb279a8a arm_perf_exploit.c 7 | -------------------------------------------------------------------------------- /fuzzer/.gitignore: -------------------------------------------------------------------------------- 1 | active_events 2 | filter_log 3 | log_to_code 4 | perf_fuzzer 5 | replay_log 6 | last.seed 7 | -------------------------------------------------------------------------------- /fuzzer/TODO: -------------------------------------------------------------------------------- 1 | hookup vsyscall replay 2 | 3 | vsyscalls 4 | see October 6th 2023 e-mail 5 | 6 | io_uring 7 | 8 | md5sum the executable and store a copy, so can reproduce later even 9 | in the face of changing versions 10 | 11 | Try having the PERF_FLAG_FD_NO_GROUP and 12 | PERF_FLAG_FD_OUTPUT flags work together. 13 | 14 | Try passing a fd over a socket 15 | 16 | Set breakpoint events on the mmap buffers? 17 | Randomly mmap() existing events? 18 | - be sure to unmap once the event is destroyed 19 | 20 | Try unmapping random page in middle of mmap buffer? 21 | 22 | Forking -- make sure we clean up child threads? 23 | 24 | Attaching to more pids (?) 25 | 26 | For sysfs events, try also flipping a few random bits to try 27 | to catch corner cases. 28 | 29 | + ->mmap2 support 30 | + double check why cpu is never set to -1? 31 | 32 | Set relevant sample_stack_user flags. If SAMPLE_STACK_USER set 33 | try setting varios believable sample_stack_user values. 34 | 35 | -------------------------------------------------------------------------------- /fuzzer/bugs-found/3.14-rc3.cr2_corruption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | pagefault ftrace cr2 corruption 4 | 5 | 6 | 7 | 8 | 9 |
10 |

pagefault ftrace cr2 corruption 11 |

12 |
13 | 14 |

Summary

15 | 16 | Problem: perf_fuzzer segfaulting at impossible address. It turns out 17 | the ftrace code when tracing the page fault handler would corrupt 18 | the x86 cr2 register (pagefault source address register) causing 19 | a secondary fault (to write out event data) to improperly segfault. 20 | 21 |

Found by

22 | perf_fuzzer

23 | Independently found later by Jiri Olsa 24 | 25 |

Fixed-by

26 | x86, trace: Fix CR2 corruption when tracing page faults

27 | 0ac09f9f8cd1fb028a48330edba6023d347d3cea

28 | 3.14-rc6 29 |

30 | Also: he has proposed a patch to avoid constructing user stack 31 | traces that might be related. 32 | 33 | 34 |

Linux-kernel

35 | 21 February 2014 -- perf_fuzzer causes reboot 36 | 37 | 38 |
39 | 40 | Back to perf_fuzzer bugs found 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /fuzzer/bugs-found/3.15-rc.flag_range_check.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | no error on invalid flag value 5 | 6 | 7 | 8 | 9 | 10 |
11 |

12 | no error on invalid flag value 13 |

14 |
15 | 16 |

Severity

17 | Just a correctness issue. 18 | 19 | 20 |

Found by

21 | perf_fuzzer (noticed when tracking another problem) 22 | 23 |

First Seen

24 | 3.15-rc1 25 | 26 |

Reproducible

27 | yes 28 | 29 |

Found On

30 | Haswell 31 | 32 |

Fixed by

33 | Linux 3.16 643fd0b9f5dc40fedbfbb908ebe6f1169284f7d8 34 | perf: Fix perf_event_open(.flags) test 35 | 36 |

Linux-kernel Mailing List Report

37 | 22 April 2014 -- [perf] yet another 32/64-bit range check failure 38 | 39 |

Analysis

40 | 41 | We check if flags is valid like this: 42 |
43 |         /* for future expandability... */
44 |         if (flags & ~PERF_FLAG_ALL)
45 |                 return -EINVAL;
46 | 
47 | but flags is a 64-bit value but ~PERF_FLAG_ALL is 32-bit.

48 | 49 | This means values like 0x800000000000ULL are treated as valid even though 50 | they aren't. 51 | 52 | 53 |
54 | Back to perf_fuzzer bugs found 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /fuzzer/bugs-found/4.0-rc1.perf_mem_leak.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | [BUG] mem leak (not: info leak) in perf (kernel 4.0.0-rc2) 4 | 5 | 6 | 7 | 8 | 9 |
10 |

11 | [BUG] mem leak (not: info leak) in perf (kernel 4.0.0-rc2) 12 |

13 |
14 | 15 |

Found by

16 | honggfuzz -- https://code.google.com/p/honggfuzz/source/checkout 17 | 18 |

Severity

19 | Memory leak 20 | 21 |

First Seen

22 | 4.0-rc1, introduced by a83fe28e2e45392464858a96745db26ac73670c8 23 | 24 |

Most recently Seen

25 | ? 26 | 27 |

Reproducible

28 | ? 29 | 30 |

Found On

31 | ? 32 | 33 |

Linux-kernel

34 | 26 February 2015 -- [PATCH] perf: fix put_event() ctx leak
35 | 12 March 2015 -- [BUG] mem leak (not: info leak) in perf (kernel 4.0.0-rc2)
36 | 37 |

Fixed in

38 | 4.0 a83fe28e2e45392464858a96745db26ac73670c8 39 | 40 |

Kernel Splat

41 | 42 |
    43 |
  1. 44 |
45 | 46 | 47 |
48 | Back to perf_fuzzer bugs found 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /fuzzer/bugs-found/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | install: 4 | scp ../README *.html `cat ~/webserver`:public_html/projects/perf_events/fuzzer/ 5 | 6 | clean: 7 | rm -f *~ *.bak 8 | 9 | -------------------------------------------------------------------------------- /fuzzer/bugs-found/NEW_BUGS: -------------------------------------------------------------------------------- 1 | New bugs since last paper: 2 | 3 | 6.7.0-rc5 4 | 5 | xingwei lee found 6 | possible deadlock in down_trylock/perf_event_open 7 | WARNING: CPU: 1 PID: 8266 at kernel/events/core.c:1950 __do_sys_perf_event_open0 8 | 9 | with syzcaller (perf_fuzzer found it too a few days later) 10 | actually trinity possibly found it even earlier 11 | 12 | Subject: [tip:perf/urgent] [perf] 382c27f4ed: 13 | WARNING:at_kernel/events/core.c:#__do_sys_perf_event_open 14 | 15 | 6.7.0-rc5 16 | 17 | added vsyscall support and perf_fuzzer found possible deadlock 18 | reported to Linux kernel on 13 December 2023 19 | 20 | [perf] vsyscall, possible circular locking dependency detected 21 | 22 | -------------------------------------------------------------------------------- /fuzzer/fast_repro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do ./perf_fuzzer -t OC -s 20000 ; done 4 | -------------------------------------------------------------------------------- /fuzzer/fast_repro2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do ./perf_fuzzer -t OCIRMQWPpAi -s 50000 ; done 4 | -------------------------------------------------------------------------------- /fuzzer/fast_repro3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do ./perf_fuzzer -t OCMQ -s 20000 ; done 4 | -------------------------------------------------------------------------------- /fuzzer/fast_repro98.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do ./perf_fuzzer -t OCIRMQWPFVpAi -s 50000 ; done 4 | -------------------------------------------------------------------------------- /fuzzer/fast_repro99.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while true; do ./perf_fuzzer -s 30000 ; done 4 | -------------------------------------------------------------------------------- /fuzzer/filter_address.h: -------------------------------------------------------------------------------- 1 | int make_address_filter( 2 | int which, 3 | char *filter_out, 4 | int filter_size, 5 | int max_whitespace, 6 | int try_valid); 7 | -------------------------------------------------------------------------------- /fuzzer/filter_log.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | 5 | char string[BUFSIZ]; 6 | char *result; 7 | FILE *fff; 8 | 9 | if (argc<3) { 10 | fprintf(stderr,"\nUsage: %s logfile char\n\n",argv[0]); 11 | return -1; 12 | } 13 | 14 | fff=fopen(argv[1],"r"); 15 | if (fff==NULL) { 16 | fprintf(stderr,"Error opening file %s\n",argv[1]); 17 | return -1; 18 | } 19 | 20 | while(1) { 21 | result=fgets(string,BUFSIZ,fff); 22 | if (result==NULL) break; 23 | if (string[0]!=argv[2][0]) printf("%s",string); 24 | } 25 | 26 | fclose(fff); 27 | 28 | return 0; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /fuzzer/filter_tracepoint.h: -------------------------------------------------------------------------------- 1 | int make_tracepoint_filter(int which, 2 | char *filter, int size, 3 | int max_levels, int max_whitespace, 4 | int try_valid); 5 | char *tracepoint_name(int which); 6 | -------------------------------------------------------------------------------- /fuzzer/fuzz_access.h: -------------------------------------------------------------------------------- 1 | void access_random_file(void); 2 | -------------------------------------------------------------------------------- /fuzzer/fuzz_close.h: -------------------------------------------------------------------------------- 1 | void close_event(int i, int from_sigio); 2 | void close_random_event(void); 3 | -------------------------------------------------------------------------------- /fuzzer/fuzz_compat.h: -------------------------------------------------------------------------------- 1 | #ifndef PR_TASK_PERF_EVENTS_ENABLE 2 | #define PR_TASK_PERF_EVENTS_DISABLE 31 3 | #define PR_TASK_PERF_EVENTS_ENABLE 32 4 | #endif 5 | -------------------------------------------------------------------------------- /fuzzer/fuzz_fork.h: -------------------------------------------------------------------------------- 1 | extern int already_forked; 2 | extern pid_t forked_pid; 3 | 4 | void fork_random_event(void); 5 | -------------------------------------------------------------------------------- /fuzzer/fuzz_ioctl.h: -------------------------------------------------------------------------------- 1 | extern int kprobe_id; 2 | 3 | void ioctl_random_event(void); 4 | -------------------------------------------------------------------------------- /fuzzer/fuzz_million.c: -------------------------------------------------------------------------------- 1 | #include "fuzzer_determinism.h" 2 | 3 | #include "instructions_testcode.h" 4 | 5 | void run_a_million_instructions(void) { 6 | 7 | if (ignore_but_dont_skip.million) return; 8 | 9 | instructions_million(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /fuzzer/fuzz_million.h: -------------------------------------------------------------------------------- 1 | void run_a_million_instructions(void); 2 | -------------------------------------------------------------------------------- /fuzzer/fuzz_mmap.h: -------------------------------------------------------------------------------- 1 | long long perf_mmap_read(int which); 2 | void trash_random_mmap(void); 3 | int setup_mmap(int which); 4 | void mmap_random_event(int type); 5 | void unmap_mmap(int i,int from_sigio); 6 | int setup_mmap_aux(int which_fd, int which_mmap); 7 | -------------------------------------------------------------------------------- /fuzzer/fuzz_open.h: -------------------------------------------------------------------------------- 1 | extern struct syscallentry syscall_perf_event_open; 2 | void open_random_event(int mmap_enabled, int overflow_enabled); 3 | -------------------------------------------------------------------------------- /fuzzer/fuzz_overflow.h: -------------------------------------------------------------------------------- 1 | #define MAX_THROTTLES 10 2 | 3 | void our_handler(int signum, siginfo_t *info, void *uc); 4 | void sigio_handler(int signum, siginfo_t *info, void *uc); 5 | void orderly_shutdown(void); 6 | -------------------------------------------------------------------------------- /fuzzer/fuzz_poll.h: -------------------------------------------------------------------------------- 1 | void poll_random_event(void); 2 | 3 | -------------------------------------------------------------------------------- /fuzzer/fuzz_prctl.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "perf_event.h" 11 | 12 | #include "perf_fuzzer.h" 13 | #include "fuzzer_determinism.h" 14 | #include "fuzzer_logging.h" 15 | #include "fuzzer_stats.h" 16 | 17 | #include "fuzz_prctl.h" 18 | 19 | void prctl_random_event(void) { 20 | 21 | int ret; 22 | int type; 23 | 24 | stats.prctl_attempts++; 25 | stats.total_syscalls++; 26 | 27 | type=rand()%2; 28 | 29 | if (ignore_but_dont_skip.prctl) return; 30 | 31 | if (type) { 32 | ret=prctl(PR_TASK_PERF_EVENTS_ENABLE); 33 | if ((ret==0)&&(logging&TYPE_PRCTL)) { 34 | sprintf(log_buffer,"P 1\n"); 35 | write(log_fd,log_buffer,strlen(log_buffer)); 36 | } 37 | } 38 | else { 39 | ret=prctl(PR_TASK_PERF_EVENTS_DISABLE); 40 | if ((ret==0)&&(logging&TYPE_PRCTL)) { 41 | sprintf(log_buffer,"P 0\n"); 42 | write(log_fd,log_buffer,strlen(log_buffer)); 43 | } 44 | 45 | } 46 | 47 | /* FIXME: are there others we should be trying? */ 48 | 49 | if (ret==0) stats.prctl_successful++; 50 | } 51 | -------------------------------------------------------------------------------- /fuzzer/fuzz_prctl.h: -------------------------------------------------------------------------------- 1 | void prctl_random_event(void); 2 | 3 | -------------------------------------------------------------------------------- /fuzzer/fuzz_read.h: -------------------------------------------------------------------------------- 1 | void read_random_event(void); 2 | 3 | -------------------------------------------------------------------------------- /fuzzer/fuzz_vsyscall.h: -------------------------------------------------------------------------------- 1 | int detect_vsyscall(void); 2 | void vsyscall_random_event(void); 3 | 4 | -------------------------------------------------------------------------------- /fuzzer/fuzz_write.h: -------------------------------------------------------------------------------- 1 | void write_random_event(void); 2 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_determinism.h: -------------------------------------------------------------------------------- 1 | extern int attempt_determinism; 2 | 3 | /* Try to allow minimal determinism while at the same */ 4 | /* time skipping unnecessary system calls. */ 5 | #if 0 6 | /* Minimal syscalls needed for bug I am tracking */ 7 | static int ignore_but_dont_skip_mmap=1; 8 | static int ignore_but_dont_skip_overflow=1; 9 | static int ignore_but_dont_skip_open=0; 10 | static int ignore_but_dont_skip_close=0; 11 | static int ignore_but_dont_skip_read=1; 12 | static int ignore_but_dont_skip_write=1; 13 | static int ignore_but_dont_skip_ioctl=1; 14 | static int ignore_but_dont_skip_fork=0; 15 | static int ignore_but_dont_skip_prctl=1; 16 | static int ignore_but_dont_skip_poll=1; 17 | static int ignore_but_dont_skip_million=1; 18 | static int ignore_but_dont_skip_access=1; 19 | static int ignore_but_dont_skip_trash_mmap=1; 20 | static int ignore_but_dont_skip_vsyscall=1; 21 | #endif 22 | 23 | struct skip_t { 24 | int mmap; 25 | int overflow; 26 | int open; 27 | int close; 28 | int read; 29 | int write; 30 | int ioctl; 31 | int fork; 32 | int prctl; 33 | int poll; 34 | int million; 35 | int access; 36 | int trash_mmap; 37 | int vsyscall; 38 | }; 39 | 40 | extern struct skip_t ignore_but_dont_skip; 41 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_logging.h: -------------------------------------------------------------------------------- 1 | #define LOG_FAILURES 0 2 | #define FSYNC_EVERY 0 3 | 4 | #define TYPE_ALL 0xffffffff 5 | #define TYPE_MMAP 0x0001 6 | #define TYPE_OVERFLOW 0x0002 7 | #define TYPE_OPEN 0x0004 8 | #define TYPE_CLOSE 0x0008 9 | #define TYPE_READ 0x0010 10 | #define TYPE_WRITE 0x0020 11 | #define TYPE_IOCTL 0x0040 12 | #define TYPE_FORK 0x0080 13 | /* missing */ 14 | #define TYPE_PRCTL 0x0200 15 | #define TYPE_POLL 0x0400 16 | #define TYPE_MILLION 0x0800 17 | #define TYPE_ACCESS 0x1000 18 | #define TYPE_TRASH_MMAP 0x2000 19 | #define TYPE_VSYSCALL 0x4000 20 | 21 | extern int trigger_failure_logging; 22 | extern int logging; 23 | extern int stop_after; 24 | 25 | extern int log_fd; 26 | extern char log_buffer[BUFSIZ]; 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /fuzzer/fuzzer_random.h: -------------------------------------------------------------------------------- 1 | int rand_refresh(void); 2 | int rand_period(void); 3 | int rand_ioctl_arg(void); 4 | uint64_t rand_open_flags(void); 5 | -------------------------------------------------------------------------------- /fuzzer/get_cpuinfo.h: -------------------------------------------------------------------------------- 1 | void get_cpuinfo(char *cpuinfo); 2 | -------------------------------------------------------------------------------- /fuzzer/parse_log.h: -------------------------------------------------------------------------------- 1 | int parse_open_event(char *line, 2 | int *orig_fd, pid_t *pid, int *cpu, int *group_fd, long int *flags, 3 | struct perf_event_attr *pe); 4 | 5 | -------------------------------------------------------------------------------- /fuzzer/perf_attr_print.h: -------------------------------------------------------------------------------- 1 | void perf_pretty_print_mmap_prot(int prot); 2 | void perf_pretty_print_flags(FILE *fff,long int flags); 3 | void perf_pretty_print_mmap_flags(int flags); 4 | //static void perf_pretty_print_type(int type); 5 | //static void perf_pretty_print_cache(long long config); 6 | //static void perf_pretty_print_config(long long type, long long config); 7 | //static void perf_pretty_print_sample_type(unsigned long long sample_type); 8 | //static void perf_pretty_print_read_format(unsigned long long read_format); 9 | //static void perf_pretty_print_breakpoint_type(int bp_type); 10 | void perf_pretty_print_attr(FILE *fff,struct perf_event_attr *pe, int fd); 11 | void perf_pretty_print_event(FILE *fff,int fd, int original_pid, 12 | struct perf_event_attr *pe, 13 | pid_t pid, int cpu, 14 | int group_fd, unsigned long flags); 15 | void perf_pretty_print_event_short(FILE *fff,int fd, int original_pid, 16 | struct perf_event_attr *pe, 17 | pid_t pid, int cpu, 18 | int group_fd, unsigned long flags); 19 | -------------------------------------------------------------------------------- /fuzzer/perf_fuzzer.h: -------------------------------------------------------------------------------- 1 | #define NUM_EVENTS 100000 2 | 3 | struct event_data_t { 4 | int active; 5 | int fd; 6 | struct perf_event_attr attr; 7 | pid_t pid; 8 | int cpu; 9 | int group_fd; 10 | unsigned long flags; 11 | int read_size; 12 | int number_in_group; 13 | struct sigaction sa; 14 | int mmap; 15 | // char *mmap; 16 | // int mmap_size; 17 | int last_refresh; 18 | int overflows; 19 | int throttles; 20 | }; 21 | 22 | extern struct event_data_t event_data[NUM_EVENTS]; 23 | extern int active_events; 24 | 25 | int find_random_active_event(void); 26 | int find_random_active_sampling_event(void); 27 | int find_random_active_breakpoint_event(void); 28 | int find_empty_event(void); 29 | int lookup_event(int fd); 30 | 31 | 32 | extern int kernel_features; 33 | 34 | #define KERNEL_VSYSCALL (1<<0) 35 | -------------------------------------------------------------------------------- /fuzzer/pmus.h: -------------------------------------------------------------------------------- 1 | 2 | struct generic_event_type { 3 | char *name; 4 | char *value; 5 | long long config; 6 | long long config1; 7 | long long config2; 8 | }; 9 | 10 | struct format_type { 11 | char *name; 12 | char *value; 13 | int field; 14 | unsigned long long mask; 15 | }; 16 | 17 | struct pmu_type { 18 | char *name; 19 | int type; 20 | int num_formats; 21 | int num_generic_events; 22 | struct format_type *formats; 23 | struct generic_event_type *generic_events; 24 | }; 25 | 26 | extern int num_pmus; 27 | extern struct pmu_type *pmus; 28 | 29 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | LIBNAME = trinity_lib.a 4 | 5 | LIBNAME_X32 = trinity_lib.xa 6 | 7 | CPPFLAGS += -I./include -I../../include -I. 8 | CFLAGS += -O2 -Wall -g 9 | CFLAGS_X32 += -mx32 10 | LDFLAGS += 11 | 12 | FILE_LIST_C := $(filter-out $(PAPI_FILE_LIST_C),$(wildcard *.c)) 13 | FILE_LIST_C_OBJS := $(FILE_LIST_C:.c=.o) 14 | FILE_LIST_X32_OBJS := $(FILE_LIST_C:.c=.xo) 15 | 16 | .SUFFIXES: .xo .x32 17 | 18 | .c.xo: 19 | $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(CFLAGS_X32) 20 | 21 | 22 | all: $(LIBNAME) 23 | 24 | x32: $(LIBNAME_X32) 25 | 26 | $(LIBNAME): $(FILE_LIST_C_OBJS) 27 | $(AR) ru $@ $^ 28 | $(RANLIB) $@ 29 | 30 | $(LIBNAME_X32): $(FILE_LIST_X32_OBJS) 31 | $(AR) ru $@ $^ 32 | $(RANLIB) $@ 33 | 34 | clean: clean-local 35 | @- $(RM) $(LIBNAME) $(LIBNAME_X32) 36 | @- $(RM) $(FILE_LIST_C_OBJS) 37 | @- $(RM) *.o *.xo 38 | 39 | clean-local: 40 | @- $(RM) *~ 41 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/README: -------------------------------------------------------------------------------- 1 | These files come from Dave Jones' trinity project 2 | 3 | http://codemonkey.org.uk/projects/trinity/ 4 | 5 | They are GPL v2 6 | 7 | The perf_event_open.c file was contributed by me (Vince Weaver) 8 | 9 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-aarch64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PAGE_OFFSET 0xffffffc000000000UL 4 | #define TASK_SIZE (1UL << 39) 5 | #define MODULE_ADDR (PAGE_OFFSET - 0x04000000) 6 | #define KERNEL_ADDR (PAGE_OFFSET + 0x80000) 7 | 8 | /* PAGE_SHIFT is 16 ifdef CONFIG_ARM64_64K_PAGES */ 9 | #define PAGE_SHIFT 12 10 | #define PTE_FILE_MAX_BITS 60 11 | 12 | #define PTRACE_GETREGS 0 13 | #define PTRACE_GETFPREGS 0 14 | #define PTRACE_SETREGS 0 15 | #define PTRACE_SETFPREGS 0 16 | 17 | #define SYSCALLS syscalls_aarch64 18 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-alpha.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xfffffc0000310000 4 | /* KERNEL_ADDR is 0xfffffc0001010000 ifndef CONFIG_ALPHA_LEGACY_START_ADDRESS */ 5 | 6 | #define PAGE_SHIFT 13 7 | #define PGDIR_SHIFT (PAGE_SHIFT + 2*(PAGE_SHIFT-3)) 8 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 9 | #define MODULE_ADDR (-2*PGDIR_SIZE) 10 | /* MODULE_ADDR is 0xfffffe0000000000 ifdef CONFIG_ALPHA_LARGE_VMALLOC */ 11 | 12 | #define PAGE_OFFSET 0xfffffc0000000000UL 13 | /* PAGE_OFFSET is 0xffff800000000000UL ifdef USE_48_BIT_KSEG */ 14 | 15 | #define TASK_SIZE 0x40000000000UL 16 | 17 | #define PTE_FILE_MAX_BITS 32 18 | 19 | #define PTRACE_GETREGS 0 20 | #define PTRACE_GETFPREGS 0 21 | #define PTRACE_SETREGS 0 22 | #define PTRACE_SETFPREGS 0 23 | 24 | #define SYSCALLS syscalls_alpha 25 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-arm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PAGE_OFFSET 0xC0000000 4 | /* 5 | * Alternative possibilities for PAGE_OFFSET: 6 | * default 0x40000000 if VMSPLIT_1G 7 | * default 0x80000000 if VMSPLIT_2G 8 | */ 9 | #define TASK_SIZE (PAGE_OFFSET - 0x01000000) 10 | #define MODULE_ADDR (PAGE_OFFSET - 0x00800000) 11 | #define KERNEL_ADDR (PAGE_OFFSET + 0x00008000) 12 | 13 | #define PAGE_SHIFT 12 14 | 15 | #define PTE_FILE_MAX_BITS 29 16 | 17 | #define SYSCALLS syscalls_arm 18 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-i386.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define X86 1 4 | 5 | #define KERNEL_ADDR 0xc0100220 6 | #define MODULE_ADDR 0xa0000000 // FIXME: Placeholder 7 | 8 | #define PAGE_OFFSET 0xC0000000 9 | #define TASK_SIZE (PAGE_OFFSET) 10 | /* 11 | * Alternative possibilities for PAGE_OFFSET: 12 | * default 0xB0000000 if VMSPLIT_3G_OPT 13 | * default 0x78000000 if VMSPLIT_2G 14 | * default 0x40000000 if VMSPLIT_1G 15 | */ 16 | 17 | #define PAGE_SHIFT 12 18 | 19 | #define PTE_FILE_MAX_BITS 31 20 | 21 | #define SYSCALLS syscalls_i386 22 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-ia64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xa000000100000000 4 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 5 | #define PAGE_OFFSET 0xe000000000000000 6 | #define TASK_SIZE 0xa000000000000000 7 | 8 | #define PAGE_SHIFT 12 9 | #define PTE_FILE_MAX_BITS 61 10 | 11 | #define SYSCALL_OFFSET 1024 12 | 13 | // for __IA64_UL_CONST we need to include: 14 | #include 15 | 16 | #define PTRACE_GETFPREGS 0 17 | #define PTRACE_SETFPREGS 0 18 | 19 | #define SYSCALLS syscalls_ia64 20 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-mips.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xc0100220 4 | #define MODULE_ADDR 0xa0000000 // FIXME: Placeholder 5 | #define PAGE_OFFSET 0x80000000 6 | #define TASK_SIZE (PAGE_OFFSET) 7 | #define PAGE_SHIFT 12 8 | #define PTE_FILE_MAX_BITS 31 9 | #define SYSCALL_OFFSET 4000 10 | 11 | #define SYSCALLS syscalls_mips 12 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-parisc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // FIXME: depends on kernel bit size, userspace is always 32 bit 4 | 5 | #define PAGE_OFFSET 0x10000000 6 | 7 | #if 0 8 | // for 64 bit 9 | #define PAGE_OFFSET 0x40000000 10 | #endif 11 | 12 | #define KERNEL_ADDR 0xa0000000 // FIXME: Placeholder 13 | #define MODULE_ADDR 0xa0000000L // FIXME: Placeholder 14 | #define TASK_SIZE 0xa0000000 // FIXME: Placeholder 15 | 16 | #define PAGE_SHIFT 12 17 | #define PTE_FILE_MAX_BITS (32 - 11) 18 | 19 | #define PTRACE_GETREGS 0 20 | #define PTRACE_GETFPREGS 0 21 | #define PTRACE_SETREGS 0 22 | #define PTRACE_SETFPREGS 0 23 | 24 | #define SYSCALLS syscalls_parisc 25 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-ppc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __powerpc64__ 4 | #define KERNEL_ADDR 0xc000000000000000UL 5 | #define MODULE_ADDR 0xd000000000000000UL 6 | #define PAGE_OFFSET 0xc000000000000000UL 7 | #define TASK_SIZE (PAGE_OFFSET) 8 | 9 | #define PAGE_SHIFT 12 10 | #define BITS_PER_LONG 64 11 | #define PTE_RPN_SHIFT (PAGE_SHIFT) 12 | #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT) 13 | 14 | #else /* __powerpc64__ */ 15 | 16 | #define KERNEL_ADDR 0xc0000000 17 | #define MODULE_ADDR 0xd0000000 18 | #define PAGE_OFFSET 0xc0000000 19 | #define TASK_SIZE (PAGE_OFFSET) 20 | 21 | #define PAGE_SHIFT 12 22 | #define BITS_PER_LONG 32 23 | #define PTE_RPN_SHIFT (PAGE_SHIFT) 24 | #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT) 25 | 26 | #endif /* __powerpc64__ */ 27 | 28 | #define SYSCALLS syscalls_ppc 29 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-s390.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __s390x__ 4 | 5 | #define KERNEL_ADDR 0UL 6 | #define MODULE_ADDR 0x1fffff80000000UL 7 | #define TASK_SIZE ~0UL 8 | #define PAGE_SHIFT 12 9 | #define PTE_FILE_MAX_BITS 59 10 | 11 | #define SYSCALLS syscalls_s390x 12 | 13 | #else /* __s390x__ */ 14 | 15 | #define KERNEL_ADDR 0UL 16 | #define TASK_SIZE 0x80000000UL 17 | #define PAGE_SHIFT 12 18 | #define PTE_FILE_MAX_BITS 26 19 | 20 | #define SYSCALLS syscalls_s390 21 | 22 | #endif /* __s390x__ */ 23 | 24 | #define PAGE_OFFSET 0x0UL 25 | #define PTRACE_GETREGS 0 26 | #define PTRACE_GETFPREGS 0 27 | #define PTRACE_SETREGS 0 28 | #define PTRACE_SETFPREGS 0 29 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-sh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #if __WORDSIZE == 64 6 | #define KERNEL_ADDR 0xfffff80000000000 7 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 8 | #define TASK_SIZE ~0UL 9 | #define PAGE_SHIFT 12 10 | #define PTE_FILE_MAX_BITS 29 11 | #else 12 | #define KERNEL_ADDR 0xf0000000 13 | #define TASK_SIZE 0xF0000000UL 14 | #define PAGE_SHIFT 12 15 | #define PTE_FILE_MAX_BITS 31 16 | #endif 17 | 18 | #define SYSCALLS syscalls_sh 19 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-sparc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __arch64__ 4 | #define PAGE_OFFSET (8 * 1024) 5 | #define KERNEL_ADDR 0xfffff80000000000 6 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 7 | #define TASK_SIZE ~0UL 8 | #define PAGE_SHIFT 13 9 | #define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL) 10 | #else 11 | #define KERNEL_ADDR 0xf0000000 12 | #define TASK_SIZE 0xF0000000UL 13 | #define PAGE_SHIFT 12 14 | #define PTE_FILE_MAX_BITS 24 15 | #endif 16 | 17 | #define SYSCALLS syscalls_sparc 18 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-syscalls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __x86_64__ 4 | #include "syscalls-x86_64.h" 5 | #include "syscalls-i386.h" 6 | #endif 7 | #ifdef __i386__ 8 | #include "syscalls-i386.h" 9 | #endif 10 | #ifdef __powerpc__ 11 | #include "syscalls-ppc.h" 12 | #endif 13 | #ifdef __ia64__ 14 | #include "syscalls-ia64.h" 15 | #endif 16 | #ifdef __sparc__ 17 | #include "syscalls-sparc.h" 18 | #endif 19 | #ifdef __s390x__ 20 | #include "syscalls-s390x.h" 21 | #endif 22 | #ifdef __s390__ 23 | #include "syscalls-s390.h" 24 | #endif 25 | #ifdef __arm__ 26 | #include "syscalls-arm.h" 27 | #endif 28 | #ifdef __mips__ 29 | #include "syscalls-mips.h" 30 | #endif 31 | #ifdef __sh__ 32 | #include "syscalls-sh.h" 33 | #endif 34 | #ifdef __alpha__ 35 | #include "syscalls-alpha.h" 36 | #endif 37 | #ifdef __aarch64__ 38 | #include "syscalls-aarch64.h" 39 | #endif 40 | #ifdef __hppa__ 41 | #include "syscalls-parisc.h" 42 | #endif 43 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch-x86-64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define X86 1 4 | 5 | #define PAGE_OFFSET 0xffff880000000000UL 6 | #define KERNEL_ADDR 0xffffffff81000000UL 7 | #define MODULE_ADDR 0xffffffffa0000000UL 8 | #define VDSO_ADDR 0xffffffffff600000UL 9 | 10 | #define TASK_SIZE (0x800000000000UL - 4096) 11 | 12 | #define PAGE_SHIFT 12 13 | 14 | #define PTE_FILE_MAX_BITS 32 15 | 16 | #define ARCH_IS_BIARCH 1 17 | #define SYSCALLS32 syscalls_i386 18 | #define SYSCALLS64 syscalls_x86_64 19 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/arch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | #ifdef __x86_64__ 6 | #include "arch-x86-64.h" 7 | #endif 8 | 9 | #ifdef __i386__ 10 | #include "arch-i386.h" 11 | #endif 12 | 13 | #ifdef __powerpc__ 14 | #include "arch-ppc.h" 15 | #endif 16 | 17 | #ifdef __ia64__ 18 | #include "arch-ia64.h" 19 | #endif 20 | 21 | #ifdef __sparc__ 22 | #include "arch-sparc.h" 23 | #endif 24 | 25 | #ifdef __s390__ 26 | #include "arch-s390.h" 27 | #endif 28 | 29 | #ifdef __arm__ 30 | #include "arch-arm.h" 31 | #endif 32 | 33 | #ifdef __mips__ 34 | #include "arch-mips.h" 35 | #endif 36 | 37 | #ifdef __sh__ 38 | #include "arch-sh.h" 39 | #endif 40 | 41 | #ifdef __alpha__ 42 | #include "arch-alpha.h" 43 | #endif 44 | 45 | #ifdef __aarch64__ 46 | #include "arch-aarch64.h" 47 | #endif 48 | 49 | #ifdef __hppa__ 50 | #include "arch-parisc.h" 51 | #endif 52 | 53 | #ifndef SYSCALL_OFFSET 54 | #define SYSCALL_OFFSET 0 55 | #endif 56 | 57 | #define PAGE_MASK (~(page_size - 1)) 58 | extern unsigned int page_size; 59 | 60 | extern bool biarch; 61 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/child.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "syscall.h" 7 | 8 | struct childdata { 9 | /* The actual syscall records each child uses. */ 10 | struct syscallrecord syscall; 11 | struct syscallrecord previous; 12 | 13 | /* log file related stuff */ 14 | FILE *logfile; 15 | bool logdirty; 16 | 17 | /* per-child mmaps */ 18 | struct map *mappings; 19 | unsigned int num_mappings; 20 | 21 | unsigned int seed; 22 | 23 | pid_t pid; 24 | 25 | unsigned int num; 26 | 27 | unsigned char kill_count; 28 | 29 | bool dontkillme; /* provide temporary protection from the watchdog. */ 30 | }; 31 | 32 | extern struct childdata *this_child; 33 | extern unsigned int max_children; 34 | 35 | void init_child(struct childdata *child, int childno); 36 | void init_child_mappings(struct childdata *child); 37 | 38 | void child_process(void); 39 | 40 | void set_dontkillme(pid_t pid, bool state); 41 | 42 | void reap_child(pid_t childpid); 43 | 44 | bool child_random_syscalls(void); 45 | int child_read_all_files(void); 46 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONSTANTS_H 2 | #define _CONSTANTS_H 1 3 | 4 | #define MAX_NR_CHILDREN 64 5 | 6 | #define MAX_PIPE_FDS 4 7 | #define NR_SOCKET_FDS 375 8 | #define NR_FILE_FDS 250 9 | 10 | #define REGENERATION_POINT 100000 11 | 12 | #endif /* _CONSTANTS_H */ 13 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/exit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern unsigned char exit_reason; 4 | 5 | enum exit_reasons { 6 | STILL_RUNNING = 0, 7 | EXIT_NO_SYSCALLS_ENABLED = 1, 8 | EXIT_REACHED_COUNT = 2, 9 | EXIT_NO_FDS = 3, 10 | EXIT_LOST_PID_SLOT = 4, 11 | EXIT_PID_OUT_OF_RANGE = 5, 12 | EXIT_SIGINT = 6, 13 | EXIT_KERNEL_TAINTED = 7, 14 | EXIT_SHM_CORRUPTION = 8, 15 | EXIT_REPARENT_PROBLEM = 9, 16 | EXIT_NO_FILES = 10, 17 | EXIT_MAIN_DISAPPEARED = 11, 18 | EXIT_UID_CHANGED = 12, 19 | EXIT_FD_INIT_FAILURE = 13, 20 | EXIT_FORK_FAILURE = 14, 21 | 22 | NUM_EXIT_REASONS = 15 23 | }; 24 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/maps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#include "list.h" 4 | 5 | extern char *page_zeros; 6 | extern char *page_0xff; 7 | extern char *page_rand; 8 | extern unsigned long *page_allocs; 9 | extern unsigned long *page_maps; 10 | 11 | void init_shared_pages(void); 12 | 13 | #define MAP_GLOBAL 1 14 | #define MAP_LOCAL 2 15 | 16 | struct map { 17 | // struct list_head list; 18 | void *ptr; 19 | char *name; 20 | unsigned long size; 21 | int prot; 22 | unsigned char type; 23 | }; 24 | 25 | extern unsigned int num_shared_mappings; 26 | extern struct map *shared_mappings; 27 | 28 | void setup_shared_mappings(void); 29 | void destroy_shared_mappings(void); 30 | 31 | void delete_mapping(int childno, struct map *map); 32 | 33 | struct map * get_map(void); 34 | 35 | struct map * common_set_mmap_ptr_len(int childno); 36 | 37 | void dirty_mapping(struct map *map); 38 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/perf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deater/perf_event_tests/d9f1f545adfc569cff124a00a3661a083c3f2367/fuzzer/trinity_files/include/perf.h -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/pids.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #if VMW 5 | #include "child.h" 6 | #endif 7 | #include "types.h" 8 | 9 | extern pid_t mainpid; 10 | extern pid_t initpid; 11 | extern pid_t watchdog_pid; 12 | 13 | #define for_each_pidslot(i) for (i = 0; i < max_children; i++) 14 | 15 | #define PIDSLOT_NOT_FOUND -1 16 | #define EMPTY_PIDSLOT -1 17 | int find_pid_slot(pid_t mypid); 18 | bool pidmap_empty(void); 19 | void dump_pid_slots(void); 20 | int pid_is_valid(pid_t); 21 | void pids_init(void); 22 | 23 | #define pid_alive(_pid) kill(_pid, 0) 24 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "child.h" 5 | #include "types.h" 6 | 7 | #define ONE_IN(x) ((rand() % x) == 0) // limit of RAND_MAX-1 8 | 9 | #if RAND_MAX == 0x7FFFFFFF 10 | #define RAND_32() ((rand() << 1) | (rand() & 1)) 11 | #define RAND_64() (((0ULL | rand()) << 33) | ((0ULL | rand()) << 2) | (rand() & 0x3)) 12 | #else 13 | #error "Unexpected RAND_MAX value. Please add support." 14 | #endif 15 | 16 | #define RAND_BOOL() (rand() & 1) 17 | #define RAND_BYTE() (rand() & 0xff) 18 | #define RAND_RANGE(min, max) (min + rand() / (RAND_MAX / (max - min + 1) + 1)) 19 | 20 | extern unsigned int seed; 21 | unsigned int init_seed(unsigned int seed); 22 | void set_seed(struct childdata *child); 23 | void reseed(void); 24 | unsigned int new_seed(void); 25 | 26 | void generate_rand_bytes(unsigned char *ptr, unsigned int len); 27 | unsigned int rand32(void); 28 | u64 rand64(void); 29 | unsigned long rand_single_bit(unsigned char size); 30 | unsigned long set_rand_bitmask(unsigned int num, const unsigned long *values); 31 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/sanitise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "syscall.h" 4 | 5 | void generic_sanitise(struct syscallrecord *rec); 6 | void generic_free_arg(struct syscallrecord *rec); 7 | 8 | unsigned long get_interesting_value(void); 9 | 10 | void *get_address(void); 11 | void *get_non_null_address(void); 12 | void *get_writable_address(unsigned long size); 13 | unsigned long find_previous_arg_address(struct syscallrecord *rec, unsigned int argnum); 14 | struct iovec * alloc_iovec(unsigned int num); 15 | unsigned long get_len(void); 16 | unsigned int get_pid(void); 17 | const char * get_filename(void); 18 | int get_random_fd(void); 19 | const char * generate_pathname(void); 20 | 21 | void gen_unicode_page(char *page); 22 | 23 | void generate_syscall_args(struct syscallrecord *rec); 24 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/trinity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern unsigned int num_online_cpus; 4 | 5 | extern char *progname; 6 | 7 | void main_loop(void); 8 | 9 | void init_watchdog(void); 10 | unsigned int check_if_fd(unsigned int child); 11 | 12 | #define __unused__ __attribute((unused)) 13 | 14 | #define FAIL 0 15 | #define SUCCESS 1 16 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/include/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef enum { FALSE = 0, TRUE = 1 } bool; 6 | 7 | typedef __uint32_t u32; 8 | typedef __uint64_t u64; 9 | -------------------------------------------------------------------------------- /fuzzer/trinity_files/random-length.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "arch.h" // page_size 4 | #include "sanitise.h" 5 | #include "random.h" 6 | 7 | unsigned long get_len(void) 8 | { 9 | int i = 0; 10 | 11 | i = rand32(); 12 | 13 | /* short circuit if 0 */ 14 | if (i == 0) 15 | return 0; 16 | 17 | switch (rand() % 6) { 18 | 19 | case 0: i &= 0xff; 20 | break; 21 | case 1: i &= page_size - 1; 22 | break; 23 | case 2: i &= 0xffff; 24 | break; 25 | case 3: i &= 0xffffff; 26 | break; 27 | case 4: i &= 0xffffffff; 28 | break; 29 | case 5: 30 | // Pass through 31 | break; 32 | } 33 | 34 | /* again, short circuit if 0 */ 35 | if (i == 0) 36 | return 0; 37 | 38 | /* we might get lucky if something is counting ints/longs etc. */ 39 | if (ONE_IN(4)) { 40 | int _div = 1 << RAND_RANGE(1, 4); /* 2,4,8 or 16 */ 41 | i /= _div; 42 | } 43 | 44 | return i; 45 | } 46 | -------------------------------------------------------------------------------- /fuzzer/version.h: -------------------------------------------------------------------------------- 1 | #define VERSION "0.32-rc0" 2 | -------------------------------------------------------------------------------- /include/Makefile: -------------------------------------------------------------------------------- 1 | clean: clean-local 2 | 3 | clean-local: 4 | @- $(RM) *~ 5 | -------------------------------------------------------------------------------- /include/bpf_helpers.h: -------------------------------------------------------------------------------- 1 | long sys_bpf(int cmd, union bpf_attr *attr, unsigned long size); 2 | -------------------------------------------------------------------------------- /include/branches_testcode.h: -------------------------------------------------------------------------------- 1 | int branches_testcode(void); 2 | int random_branches_testcode(int number, int quiet); 3 | 4 | -------------------------------------------------------------------------------- /include/detect_cache.h: -------------------------------------------------------------------------------- 1 | #define CACHE_L1 0 2 | #define CACHE_L2 1 3 | #define CACHE_L3 2 4 | #define CACHE_L4 3 5 | #define CACHE_L5 4 6 | #define MAX_CACHE_LEVEL 5 7 | 8 | #define CACHE_I 0 9 | #define CACHE_D 1 10 | #define CACHE_U 2 11 | #define CACHE_T 3 12 | #define MAX_CACHE_TYPE 4 13 | 14 | #define CACHE_UNKNOWN 0 15 | 16 | struct cache_info_t { 17 | int exists; 18 | int level; 19 | int type; 20 | int wpolicy; 21 | int replace; 22 | int size; 23 | int lines; 24 | int ways; 25 | int linesize; 26 | }; 27 | 28 | extern struct cache_info_t cache_info[MAX_CACHE_LEVEL][MAX_CACHE_TYPE]; 29 | 30 | int gather_cache_info(int quiet, char *test_string); 31 | int cache_get_max_levels(int quiet, char *test_string); 32 | void print_cache_info(int quiet, struct cache_info_t *cache_entry); 33 | -------------------------------------------------------------------------------- /include/instructions_testcode.h: -------------------------------------------------------------------------------- 1 | int instructions_million(void); 2 | int instructions_fldcw(void); 3 | int instructions_rep(void); 4 | 5 | -------------------------------------------------------------------------------- /include/matrix_multiply.h: -------------------------------------------------------------------------------- 1 | long long naive_matrix_multiply_estimated_flops(int quiet); 2 | void naive_matrix_multiply(int quiet); 3 | 4 | 5 | -------------------------------------------------------------------------------- /include/nops_testcode.h: -------------------------------------------------------------------------------- 1 | int nops_testcode(void); 2 | -------------------------------------------------------------------------------- /include/parse_record.h: -------------------------------------------------------------------------------- 1 | #define RAW_NONE 0 2 | #define RAW_IBS_FETCH 1 3 | #define RAW_IBS_OP 2 4 | 5 | struct validate_values { 6 | int pid; 7 | int tid; 8 | int events; 9 | unsigned long branch_low; 10 | unsigned long branch_high; 11 | }; 12 | 13 | long long perf_mmap_read( 14 | void *our_mmap, int mmap_size, long long prev_head, 15 | int sample_type, int read_format, long long reg_mask, 16 | struct validate_values *validate, 17 | int quiet, int *events_read, 18 | int raw_type ); 19 | 20 | 21 | -------------------------------------------------------------------------------- /include/tracefs_helpers.h: -------------------------------------------------------------------------------- 1 | char *find_tracefs_location(char *buffer, int quiet); 2 | -------------------------------------------------------------------------------- /lib/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../include 4 | CFLAGS += -Wall -O2 -g 5 | CFLAGS_X32 = -mx32 6 | 7 | LIBNAME = libhelper.a 8 | LIBNAME_X32 = libhelper.xa 9 | 10 | PAPI_FILE_LIST_C := $(wildcard papi*.c) 11 | 12 | .SUFFIXES: .xo 13 | 14 | .c.xo: 15 | $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(CFLAGS_X32) 16 | 17 | 18 | FILE_LIST_C := $(filter-out $(PAPI_FILE_LIST_C),$(wildcard *.c)) 19 | FILE_LIST_C_OBJS := $(FILE_LIST_C:.c=.o) 20 | FILE_LIST_X32_OBJS := $(FILE_LIST_C:.c=.xo) 21 | 22 | all: $(LIBNAME) 23 | 24 | x32: $(LIBNAME_X32) 25 | 26 | $(LIBNAME): $(FILE_LIST_C_OBJS) 27 | $(AR) r $@ $^ 28 | $(RANLIB) $@ 29 | 30 | $(LIBNAME_X32): $(FILE_LIST_X32_OBJS) 31 | $(AR) r $@ $^ 32 | $(RANLIB) $@ 33 | 34 | clean: clean-local 35 | @- $(RM) $(LIBNAME) $(LIBNAME_X32) 36 | @- $(RM) $(FILE_LIST_C_OBJS) 37 | @- $(RM) *.o *.xo 38 | 39 | clean-local: 40 | @- $(RM) *~ 41 | -------------------------------------------------------------------------------- /lib/bpf_helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | #include "bpf.h" 11 | 12 | #ifndef __NR_bpf 13 | 14 | #if defined(__i386__) 15 | #define __NR_bpf 357 16 | #elif defined(__x86_64__) 17 | #define __NR_bpf 321 18 | #elif defined(__powerpc__) 19 | #define __NR_bpf 361 20 | #elif defined(__arm__) || defined(__aarch64__) 21 | #define __NR_bpf 386 22 | #elif defined(__sparc__) 23 | #define __NR_bpf 349 24 | #endif 25 | 26 | #endif 27 | 28 | 29 | long sys_bpf(int cmd, union bpf_attr *attr, unsigned long size) { 30 | 31 | return syscall(__NR_bpf, cmd, attr, size); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /lib/tracefs_helpers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | #include "tracefs_helpers.h" 11 | 12 | 13 | 14 | char *find_tracefs_location(char *buffer, int quiet) { 15 | 16 | int result; 17 | 18 | /* First try /sys/kernel/tracing */ 19 | result=access("/sys/kernel/tracing", R_OK|W_OK); 20 | if (result==0) { 21 | strcpy(buffer,"/sys/kernel/tracing"); 22 | return buffer; 23 | } 24 | else { 25 | if (errno==EPERM) { 26 | fprintf(stderr,"Insufficient permissions!\n"); 27 | return NULL; 28 | } 29 | } 30 | 31 | /* Next try /sys/kernel/debug/tracing */ 32 | result=access("/sys/kernel/debug/tracing", R_OK|W_OK); 33 | if (result==0) { 34 | strcpy(buffer,"/sys/kernel/debug/tracing"); 35 | return buffer; 36 | } 37 | else { 38 | if (errno==EPERM) { 39 | fprintf(stderr,"Insufficient permissions!\n"); 40 | return NULL; 41 | } 42 | } 43 | 44 | return NULL; 45 | } 46 | -------------------------------------------------------------------------------- /papi/TODO: -------------------------------------------------------------------------------- 1 | multiple domains (user, kernel at once) 2 | :c, etc 3 | how does setting :u or :k affect things 4 | adding more sw events than available counters 5 | -------------------------------------------------------------------------------- /papi/overhead/100b_none.c: -------------------------------------------------------------------------------- 1 | /* This program measures the relative overhead of PAPI */ 2 | /* vs raw perf_event */ 3 | 4 | /* by Vince Weaver, vincent.weaver _at_ maine.edu */ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "instructions_testcode.h" 12 | 13 | #define NUM_RUNS 100000 14 | 15 | 16 | 17 | int main(int argc, char **argv) { 18 | 19 | int i; 20 | int result; 21 | 22 | for(i=0;i 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_INT_INS predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_INT_INS); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_INT_INS not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_INT_INS; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_dch.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_DCH */ 2 | /* (Level 1 data cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_DCH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_DCH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_DCH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_DCH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_dcr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_DCR */ 2 | /* (Level 1 data cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_DCR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_DCR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_DCR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_DCR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_dcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_DCW */ 2 | /* (Level 1 data cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_DCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_DCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_DCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_DCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_ich.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_ICH */ 2 | /* (Level 1 instruction cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_ICH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_ICH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_ICH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_ICH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_icr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_ICR */ 2 | /* (Level 1 instruction cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_ICR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_ICR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_ICR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_ICR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_icw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_ICW */ 2 | /* (Level 1 instruction cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_ICW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_ICW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_ICW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_ICW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_tca.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_TCA */ 2 | /* (Level 1 total cache accesses) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_TCA predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_TCA); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_TCA not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_TCA; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_tch.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_TCH */ 2 | /* (Level 1 total cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_TCH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_TCH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_TCH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_TCH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_tcr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_TCR */ 2 | /* (Level 1 total cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_TCR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_TCR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_TCR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_TCR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l1_tcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L1_TCW */ 2 | /* (Level 1 total cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L1_TCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L1_TCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L1_TCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L1_TCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_dch.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_DCH */ 2 | /* (Level 2 data cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_DCH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_DCH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_DCH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_DCH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_dcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_DCW */ 2 | /* (Level 2 data cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_DCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_DCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_DCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_DCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_ich.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_ICH */ 2 | /* (Level 2 instruction cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_ICH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_ICH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_ICH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_ICH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_icr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_ICR */ 2 | /* (Level 2 instruction cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_ICR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_ICR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_ICR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_ICR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_icw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_ICW */ 2 | /* (Level 2 instruction cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_ICW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_ICW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_ICW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_ICW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_tca.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_TCA */ 2 | /* (Level 2 total cache accesses) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_TCA predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_TCA); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_TCA not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_TCA; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_tch.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_TCH */ 2 | /* (Level 2 total cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_TCH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_TCH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_TCH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_TCH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l2_tcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L2_TCW */ 2 | /* (Level 2 total cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L2_TCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L2_TCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L2_TCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L2_TCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_dca.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_DCA */ 2 | /* (Level 3 data cache accesses) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_DCA predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_DCA); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_DCA not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_DCA; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_dcr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_DCR */ 2 | /* (Level 3 data cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_DCR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_DCR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_DCR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_DCR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_dcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_DCW */ 2 | /* (Level 3 data cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_DCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_DCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_DCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_DCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_ich.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_ICH */ 2 | /* (Level 3 instruction cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_ICH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_ICH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_ICH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_ICH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_icr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_ICR */ 2 | /* (Level 3 instruction cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_ICR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_ICR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_ICR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_ICR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_icw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_ICW */ 2 | /* (Level 3 instruction cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_ICW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_ICW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_ICW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_ICW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_tca.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_TCA */ 2 | /* (Level 3 total cache accesses) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_TCA predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_TCA); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_TCA not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_TCA; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_tch.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_TCH */ 2 | /* (Level 3 total cache hits) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_TCH predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_TCH); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_TCH not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_TCH; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_tcr.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_TCR */ 2 | /* (Level 3 total cache reads) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_TCR predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_TCR); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_TCR not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_TCR; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_l3_tcw.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_L3_TCW */ 2 | /* (Level 3 total cache writes) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_L3_TCW predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_L3_TCW); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_L3_TCW not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_L3_TCW; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_ld_ins.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_LD_INS */ 2 | /* (Load instructions) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_LD_INS predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_LD_INS); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_LD_INS not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_LD_INS; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_sr_ins.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_SR_INS */ 2 | /* (Store instructions) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_SR_INS predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_SR_INS); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_SR_INS not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_SR_INS; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_tot_iis.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_TOT_IIS */ 2 | /* (Instructions issued) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_TOT_IIS predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_TOT_IIS); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_TOT_IIS not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_TOT_IIS; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /papi/validation/papi_vec_ins.c: -------------------------------------------------------------------------------- 1 | /* This code runs some sanity checks on the PAPI_VEC_INS */ 2 | /* (Vector/SIMD instructions) events. */ 3 | 4 | /* by Vince Weaver, vweaver1 _at_ eecs.utk.edu */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "papi.h" 11 | 12 | #include "test_utils.h" 13 | 14 | int main(int argc, char **argv) { 15 | 16 | int events[1]; 17 | long long counts[1]; 18 | 19 | int retval,quiet; 20 | 21 | char test_string[]="Testing PAPI_VEC_INS predefined event..."; 22 | 23 | quiet=test_quiet(); 24 | 25 | retval = PAPI_library_init(PAPI_VER_CURRENT); 26 | if (retval != PAPI_VER_CURRENT) { 27 | if (!quiet) printf("Error! PAPI_library_init %d\n",retval); 28 | test_fail(test_string); 29 | } 30 | 31 | retval = PAPI_query_event(PAPI_VEC_INS); 32 | if (retval != PAPI_OK) { 33 | if (!quiet) printf("PAPI_VEC_INS not available\n"); 34 | test_skip(test_string); 35 | } 36 | 37 | events[0]=PAPI_VEC_INS; 38 | 39 | PAPI_start_counters(events,1); 40 | 41 | PAPI_stop_counters(counts,1); 42 | 43 | if (counts[0]<1) { 44 | if (!quiet) printf("Error! Count too low\n"); 45 | test_fail(test_string); 46 | } 47 | 48 | PAPI_shutdown(); 49 | 50 | test_unimplemented(test_string); 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /perf_data_fuzzer/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I./trinity_files/include 4 | CFLAGS += -Wall -g -O2 5 | LDFLAGS += 6 | CFLAGS_X32 += -mx32 7 | LDFLAGS_X32 += -mx32 -static 8 | 9 | .SUFFIXES: .xo .xa 10 | 11 | .c.xo: 12 | $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(CFLAGS_X32) 13 | 14 | 15 | PROGRAM_LIST = perf_data_fuzzer perf_data_dump 16 | 17 | all: $(PROGRAM_LIST) 18 | 19 | perf_data_dump: perf_data_dump.o parse_record.o data_read.o perf_attr_print.o 20 | 21 | perf_data_fuzzer: perf_data_fuzzer.o create_perf_data.o \ 22 | trinity_files/trinity_lib.a 23 | 24 | 25 | trinity_files/trinity_lib.a: 26 | $(MAKE) -C trinity_files 27 | 28 | 29 | install: all 30 | $(INSTALL) -d $(prefix)/fuzzer 31 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/fuzzer 32 | 33 | clean: clean-local 34 | @- $(RM) $(PROGRAM_LIST) $(PROGRAM_LIST_X32) 35 | $(MAKE) -C trinity_files clean 36 | @- $(RM) *.o *.xo 37 | 38 | clean-local: 39 | @- $(RM) *~ 40 | -------------------------------------------------------------------------------- /perf_data_fuzzer/create_perf_data.h: -------------------------------------------------------------------------------- 1 | int create_perf_data_file(void); 2 | -------------------------------------------------------------------------------- /perf_data_fuzzer/data_read.h: -------------------------------------------------------------------------------- 1 | uint16_t get_uint16(unsigned char *data, int offset); 2 | uint32_t get_uint32(unsigned char *data, int offset); 3 | uint64_t get_uint64(unsigned char *data, int offset); 4 | uint32_t get_string(unsigned char *data, int offset, char *string); 5 | 6 | -------------------------------------------------------------------------------- /perf_data_fuzzer/parse_record.h: -------------------------------------------------------------------------------- 1 | #define RAW_NONE 0 2 | #define RAW_IBS_FETCH 1 3 | #define RAW_IBS_OP 2 4 | 5 | int parse_perf_record(unsigned char *data, int sample_type, int read_format); 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /perf_data_fuzzer/perf_attr_print.h: -------------------------------------------------------------------------------- 1 | void perf_pretty_print_mmap_prot(int prot); 2 | void perf_pretty_print_flags(FILE *fff,long int flags); 3 | void perf_pretty_print_mmap_flags(int flags); 4 | //static void perf_pretty_print_type(int type); 5 | //static void perf_pretty_print_cache(long long config); 6 | //static void perf_pretty_print_config(long long type, long long config); 7 | //static void perf_pretty_print_sample_type(unsigned long long sample_type); 8 | //static void perf_pretty_print_read_format(unsigned long long read_format); 9 | //static void perf_pretty_print_breakpoint_type(int bp_type); 10 | void perf_pretty_print_attr(FILE *fff,struct perf_event_attr *pe, int fd); 11 | void perf_pretty_print_event(FILE *fff,int fd, int original_pid, 12 | struct perf_event_attr *pe, 13 | pid_t pid, int cpu, 14 | int group_fd, unsigned long flags); 15 | void perf_pretty_print_event_short(FILE *fff,int fd, int original_pid, 16 | struct perf_event_attr *pe, 17 | pid_t pid, int cpu, 18 | int group_fd, unsigned long flags); 19 | -------------------------------------------------------------------------------- /perf_data_fuzzer/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) { 4 | 5 | char *c=NULL; 6 | char a; 7 | 8 | a=*c; 9 | 10 | printf("%c",a); 11 | 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | LIBNAME = trinity_lib.a 4 | 5 | CPPFLAGS += -I./include -I../../include -I. 6 | CFLAGS += -O2 -Wall -g 7 | LDFLAGS += 8 | 9 | FILE_LIST_C := $(filter-out $(PAPI_FILE_LIST_C),$(wildcard *.c)) 10 | FILE_LIST_C_OBJS := $(FILE_LIST_C:.c=.o) 11 | 12 | .SUFFIXES: .xo .x32 13 | 14 | .c.xo: 15 | $(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) $(CFLAGS_X32) 16 | 17 | 18 | all: $(LIBNAME) 19 | 20 | $(LIBNAME): $(FILE_LIST_C_OBJS) 21 | $(AR) ru $@ $^ 22 | $(RANLIB) $@ 23 | 24 | clean: clean-local 25 | @- $(RM) $(LIBNAME) $(LIBNAME_X32) 26 | @- $(RM) $(FILE_LIST_C_OBJS) 27 | @- $(RM) *.o *.xo 28 | 29 | clean-local: 30 | @- $(RM) *~ 31 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/README: -------------------------------------------------------------------------------- 1 | These files come from Dave Jones' trinity project 2 | 3 | http://codemonkey.org.uk/projects/trinity/ 4 | 5 | They are GPL v2 6 | 7 | The perf_event_open.c file was contributed by me (Vince Weaver) 8 | 9 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-aarch64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PAGE_OFFSET 0xffffffc000000000UL 4 | #define TASK_SIZE (1UL << 39) 5 | #define MODULE_ADDR (PAGE_OFFSET - 0x04000000) 6 | #define KERNEL_ADDR (PAGE_OFFSET + 0x80000) 7 | 8 | /* PAGE_SHIFT is 16 ifdef CONFIG_ARM64_64K_PAGES */ 9 | #define PAGE_SHIFT 12 10 | #define PTE_FILE_MAX_BITS 60 11 | 12 | #define PTRACE_GETREGS 0 13 | #define PTRACE_GETFPREGS 0 14 | #define PTRACE_SETREGS 0 15 | #define PTRACE_SETFPREGS 0 16 | 17 | #define SYSCALLS syscalls_aarch64 18 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-alpha.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xfffffc0000310000 4 | /* KERNEL_ADDR is 0xfffffc0001010000 ifndef CONFIG_ALPHA_LEGACY_START_ADDRESS */ 5 | 6 | #define PAGE_SHIFT 13 7 | #define PGDIR_SHIFT (PAGE_SHIFT + 2*(PAGE_SHIFT-3)) 8 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 9 | #define MODULE_ADDR (-2*PGDIR_SIZE) 10 | /* MODULE_ADDR is 0xfffffe0000000000 ifdef CONFIG_ALPHA_LARGE_VMALLOC */ 11 | 12 | #define PAGE_OFFSET 0xfffffc0000000000UL 13 | /* PAGE_OFFSET is 0xffff800000000000UL ifdef USE_48_BIT_KSEG */ 14 | 15 | #define TASK_SIZE 0x40000000000UL 16 | 17 | #define PTE_FILE_MAX_BITS 32 18 | 19 | #define PTRACE_GETREGS 0 20 | #define PTRACE_GETFPREGS 0 21 | #define PTRACE_SETREGS 0 22 | #define PTRACE_SETFPREGS 0 23 | 24 | #define SYSCALLS syscalls_alpha 25 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-arm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PAGE_OFFSET 0xC0000000 4 | /* 5 | * Alternative possibilities for PAGE_OFFSET: 6 | * default 0x40000000 if VMSPLIT_1G 7 | * default 0x80000000 if VMSPLIT_2G 8 | */ 9 | #define TASK_SIZE (PAGE_OFFSET - 0x01000000) 10 | #define MODULE_ADDR (PAGE_OFFSET - 0x00800000) 11 | #define KERNEL_ADDR (PAGE_OFFSET + 0x00008000) 12 | 13 | #define PAGE_SHIFT 12 14 | 15 | #define PTE_FILE_MAX_BITS 29 16 | 17 | #define SYSCALLS syscalls_arm 18 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-i386.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define X86 1 4 | 5 | #define KERNEL_ADDR 0xc0100220 6 | #define MODULE_ADDR 0xa0000000 // FIXME: Placeholder 7 | 8 | #define PAGE_OFFSET 0xC0000000 9 | #define TASK_SIZE (PAGE_OFFSET) 10 | /* 11 | * Alternative possibilities for PAGE_OFFSET: 12 | * default 0xB0000000 if VMSPLIT_3G_OPT 13 | * default 0x78000000 if VMSPLIT_2G 14 | * default 0x40000000 if VMSPLIT_1G 15 | */ 16 | 17 | #define PAGE_SHIFT 12 18 | 19 | #define PTE_FILE_MAX_BITS 31 20 | 21 | #define SYSCALLS syscalls_i386 22 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-ia64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xa000000100000000 4 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 5 | #define PAGE_OFFSET 0xe000000000000000 6 | #define TASK_SIZE 0xa000000000000000 7 | 8 | #define PAGE_SHIFT 12 9 | #define PTE_FILE_MAX_BITS 61 10 | 11 | #define SYSCALL_OFFSET 1024 12 | 13 | // for __IA64_UL_CONST we need to include: 14 | #include 15 | 16 | #define PTRACE_GETFPREGS 0 17 | #define PTRACE_SETFPREGS 0 18 | 19 | #define SYSCALLS syscalls_ia64 20 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-mips.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_ADDR 0xc0100220 4 | #define MODULE_ADDR 0xa0000000 // FIXME: Placeholder 5 | #define PAGE_OFFSET 0x80000000 6 | #define TASK_SIZE (PAGE_OFFSET) 7 | #define PAGE_SHIFT 12 8 | #define PTE_FILE_MAX_BITS 31 9 | #define SYSCALL_OFFSET 4000 10 | 11 | #define SYSCALLS syscalls_mips 12 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-parisc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // FIXME: depends on kernel bit size, userspace is always 32 bit 4 | 5 | #define PAGE_OFFSET 0x10000000 6 | 7 | #if 0 8 | // for 64 bit 9 | #define PAGE_OFFSET 0x40000000 10 | #endif 11 | 12 | #define KERNEL_ADDR 0xa0000000 // FIXME: Placeholder 13 | #define MODULE_ADDR 0xa0000000L // FIXME: Placeholder 14 | #define TASK_SIZE 0xa0000000 // FIXME: Placeholder 15 | 16 | #define PAGE_SHIFT 12 17 | #define PTE_FILE_MAX_BITS (32 - 11) 18 | 19 | #define PTRACE_GETREGS 0 20 | #define PTRACE_GETFPREGS 0 21 | #define PTRACE_SETREGS 0 22 | #define PTRACE_SETFPREGS 0 23 | 24 | #define SYSCALLS syscalls_parisc 25 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-ppc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __powerpc64__ 4 | #define KERNEL_ADDR 0xc000000000000000UL 5 | #define MODULE_ADDR 0xd000000000000000UL 6 | #define PAGE_OFFSET 0xc000000000000000UL 7 | #define TASK_SIZE (PAGE_OFFSET) 8 | 9 | #define PAGE_SHIFT 12 10 | #define BITS_PER_LONG 64 11 | #define PTE_RPN_SHIFT (PAGE_SHIFT) 12 | #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT) 13 | 14 | #else /* __powerpc64__ */ 15 | 16 | #define KERNEL_ADDR 0xc0000000 17 | #define MODULE_ADDR 0xd0000000 18 | #define PAGE_OFFSET 0xc0000000 19 | #define TASK_SIZE (PAGE_OFFSET) 20 | 21 | #define PAGE_SHIFT 12 22 | #define BITS_PER_LONG 32 23 | #define PTE_RPN_SHIFT (PAGE_SHIFT) 24 | #define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT) 25 | 26 | #endif /* __powerpc64__ */ 27 | 28 | #define SYSCALLS syscalls_ppc 29 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-s390.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __s390x__ 4 | 5 | #define KERNEL_ADDR 0UL 6 | #define MODULE_ADDR 0x1fffff80000000UL 7 | #define TASK_SIZE ~0UL 8 | #define PAGE_SHIFT 12 9 | #define PTE_FILE_MAX_BITS 59 10 | 11 | #define SYSCALLS syscalls_s390x 12 | 13 | #else /* __s390x__ */ 14 | 15 | #define KERNEL_ADDR 0UL 16 | #define TASK_SIZE 0x80000000UL 17 | #define PAGE_SHIFT 12 18 | #define PTE_FILE_MAX_BITS 26 19 | 20 | #define SYSCALLS syscalls_s390 21 | 22 | #endif /* __s390x__ */ 23 | 24 | #define PAGE_OFFSET 0x0UL 25 | #define PTRACE_GETREGS 0 26 | #define PTRACE_GETFPREGS 0 27 | #define PTRACE_SETREGS 0 28 | #define PTRACE_SETFPREGS 0 29 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-sh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #if __WORDSIZE == 64 6 | #define KERNEL_ADDR 0xfffff80000000000 7 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 8 | #define TASK_SIZE ~0UL 9 | #define PAGE_SHIFT 12 10 | #define PTE_FILE_MAX_BITS 29 11 | #else 12 | #define KERNEL_ADDR 0xf0000000 13 | #define TASK_SIZE 0xF0000000UL 14 | #define PAGE_SHIFT 12 15 | #define PTE_FILE_MAX_BITS 31 16 | #endif 17 | 18 | #define SYSCALLS syscalls_sh 19 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-sparc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __arch64__ 4 | #define PAGE_OFFSET (8 * 1024) 5 | #define KERNEL_ADDR 0xfffff80000000000 6 | #define MODULE_ADDR 0xffffffffa0000000L // FIXME: Placeholder 7 | #define TASK_SIZE ~0UL 8 | #define PAGE_SHIFT 13 9 | #define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL) 10 | #else 11 | #define KERNEL_ADDR 0xf0000000 12 | #define TASK_SIZE 0xF0000000UL 13 | #define PAGE_SHIFT 12 14 | #define PTE_FILE_MAX_BITS 24 15 | #endif 16 | 17 | #define SYSCALLS syscalls_sparc 18 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-syscalls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __x86_64__ 4 | #include "syscalls-x86_64.h" 5 | #include "syscalls-i386.h" 6 | #endif 7 | #ifdef __i386__ 8 | #include "syscalls-i386.h" 9 | #endif 10 | #ifdef __powerpc__ 11 | #include "syscalls-ppc.h" 12 | #endif 13 | #ifdef __ia64__ 14 | #include "syscalls-ia64.h" 15 | #endif 16 | #ifdef __sparc__ 17 | #include "syscalls-sparc.h" 18 | #endif 19 | #ifdef __s390x__ 20 | #include "syscalls-s390x.h" 21 | #endif 22 | #ifdef __s390__ 23 | #include "syscalls-s390.h" 24 | #endif 25 | #ifdef __arm__ 26 | #include "syscalls-arm.h" 27 | #endif 28 | #ifdef __mips__ 29 | #include "syscalls-mips.h" 30 | #endif 31 | #ifdef __sh__ 32 | #include "syscalls-sh.h" 33 | #endif 34 | #ifdef __alpha__ 35 | #include "syscalls-alpha.h" 36 | #endif 37 | #ifdef __aarch64__ 38 | #include "syscalls-aarch64.h" 39 | #endif 40 | #ifdef __hppa__ 41 | #include "syscalls-parisc.h" 42 | #endif 43 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch-x86-64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define X86 1 4 | 5 | #define PAGE_OFFSET 0xffff880000000000UL 6 | #define KERNEL_ADDR 0xffffffff81000000UL 7 | #define MODULE_ADDR 0xffffffffa0000000UL 8 | #define VDSO_ADDR 0xffffffffff600000UL 9 | 10 | #define TASK_SIZE (0x800000000000UL - 4096) 11 | 12 | #define PAGE_SHIFT 12 13 | 14 | #define PTE_FILE_MAX_BITS 32 15 | 16 | #define ARCH_IS_BIARCH 1 17 | #define SYSCALLS32 syscalls_i386 18 | #define SYSCALLS64 syscalls_x86_64 19 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/arch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | #ifdef __x86_64__ 6 | #include "arch-x86-64.h" 7 | #endif 8 | 9 | #ifdef __i386__ 10 | #include "arch-i386.h" 11 | #endif 12 | 13 | #ifdef __powerpc__ 14 | #include "arch-ppc.h" 15 | #endif 16 | 17 | #ifdef __ia64__ 18 | #include "arch-ia64.h" 19 | #endif 20 | 21 | #ifdef __sparc__ 22 | #include "arch-sparc.h" 23 | #endif 24 | 25 | #ifdef __s390__ 26 | #include "arch-s390.h" 27 | #endif 28 | 29 | #ifdef __arm__ 30 | #include "arch-arm.h" 31 | #endif 32 | 33 | #ifdef __mips__ 34 | #include "arch-mips.h" 35 | #endif 36 | 37 | #ifdef __sh__ 38 | #include "arch-sh.h" 39 | #endif 40 | 41 | #ifdef __alpha__ 42 | #include "arch-alpha.h" 43 | #endif 44 | 45 | #ifdef __aarch64__ 46 | #include "arch-aarch64.h" 47 | #endif 48 | 49 | #ifdef __hppa__ 50 | #include "arch-parisc.h" 51 | #endif 52 | 53 | #ifndef SYSCALL_OFFSET 54 | #define SYSCALL_OFFSET 0 55 | #endif 56 | 57 | #define PAGE_MASK (~(page_size - 1)) 58 | extern unsigned int page_size; 59 | 60 | extern bool biarch; 61 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/child.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "syscall.h" 7 | 8 | struct childdata { 9 | /* The actual syscall records each child uses. */ 10 | struct syscallrecord syscall; 11 | struct syscallrecord previous; 12 | 13 | /* log file related stuff */ 14 | FILE *logfile; 15 | bool logdirty; 16 | 17 | /* per-child mmaps */ 18 | struct map *mappings; 19 | unsigned int num_mappings; 20 | 21 | unsigned int seed; 22 | 23 | pid_t pid; 24 | 25 | unsigned int num; 26 | 27 | unsigned char kill_count; 28 | 29 | bool dontkillme; /* provide temporary protection from the watchdog. */ 30 | }; 31 | 32 | extern struct childdata *this_child; 33 | extern unsigned int max_children; 34 | 35 | void init_child(struct childdata *child, int childno); 36 | void init_child_mappings(struct childdata *child); 37 | 38 | void child_process(void); 39 | 40 | void set_dontkillme(pid_t pid, bool state); 41 | 42 | void reap_child(pid_t childpid); 43 | 44 | bool child_random_syscalls(void); 45 | int child_read_all_files(void); 46 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONSTANTS_H 2 | #define _CONSTANTS_H 1 3 | 4 | #define MAX_NR_CHILDREN 64 5 | 6 | #define MAX_PIPE_FDS 4 7 | #define NR_SOCKET_FDS 375 8 | #define NR_FILE_FDS 250 9 | 10 | #define REGENERATION_POINT 100000 11 | 12 | #endif /* _CONSTANTS_H */ 13 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/exit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern unsigned char exit_reason; 4 | 5 | enum exit_reasons { 6 | STILL_RUNNING = 0, 7 | EXIT_NO_SYSCALLS_ENABLED = 1, 8 | EXIT_REACHED_COUNT = 2, 9 | EXIT_NO_FDS = 3, 10 | EXIT_LOST_PID_SLOT = 4, 11 | EXIT_PID_OUT_OF_RANGE = 5, 12 | EXIT_SIGINT = 6, 13 | EXIT_KERNEL_TAINTED = 7, 14 | EXIT_SHM_CORRUPTION = 8, 15 | EXIT_REPARENT_PROBLEM = 9, 16 | EXIT_NO_FILES = 10, 17 | EXIT_MAIN_DISAPPEARED = 11, 18 | EXIT_UID_CHANGED = 12, 19 | EXIT_FD_INIT_FAILURE = 13, 20 | EXIT_FORK_FAILURE = 14, 21 | 22 | NUM_EXIT_REASONS = 15 23 | }; 24 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/maps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#include "list.h" 4 | 5 | extern char *page_zeros; 6 | extern char *page_0xff; 7 | extern char *page_rand; 8 | extern unsigned long *page_allocs; 9 | extern unsigned long *page_maps; 10 | 11 | void init_shared_pages(void); 12 | 13 | #define MAP_GLOBAL 1 14 | #define MAP_LOCAL 2 15 | 16 | struct map { 17 | // struct list_head list; 18 | void *ptr; 19 | char *name; 20 | unsigned long size; 21 | int prot; 22 | unsigned char type; 23 | }; 24 | 25 | extern unsigned int num_shared_mappings; 26 | extern struct map *shared_mappings; 27 | 28 | void setup_shared_mappings(void); 29 | void destroy_shared_mappings(void); 30 | 31 | void delete_mapping(int childno, struct map *map); 32 | 33 | struct map * get_map(void); 34 | 35 | struct map * common_set_mmap_ptr_len(int childno); 36 | 37 | void dirty_mapping(struct map *map); 38 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/perf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deater/perf_event_tests/d9f1f545adfc569cff124a00a3661a083c3f2367/perf_data_fuzzer/trinity_files/include/perf.h -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/pids.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #if VMW 5 | #include "child.h" 6 | #endif 7 | #include "types.h" 8 | 9 | extern pid_t mainpid; 10 | extern pid_t initpid; 11 | extern pid_t watchdog_pid; 12 | 13 | #define for_each_pidslot(i) for (i = 0; i < max_children; i++) 14 | 15 | #define PIDSLOT_NOT_FOUND -1 16 | #define EMPTY_PIDSLOT -1 17 | int find_pid_slot(pid_t mypid); 18 | bool pidmap_empty(void); 19 | void dump_pid_slots(void); 20 | int pid_is_valid(pid_t); 21 | void pids_init(void); 22 | 23 | #define pid_alive(_pid) kill(_pid, 0) 24 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "child.h" 5 | #include "types.h" 6 | 7 | #define ONE_IN(x) ((rand() % x) == 0) // limit of RAND_MAX-1 8 | 9 | #if RAND_MAX == 0x7FFFFFFF 10 | #define RAND_32() ((rand() << 1) | (rand() & 1)) 11 | #define RAND_64() (((0ULL | rand()) << 33) | ((0ULL | rand()) << 2) | (rand() & 0x3)) 12 | #else 13 | #error "Unexpected RAND_MAX value. Please add support." 14 | #endif 15 | 16 | #define RAND_BOOL() (rand() & 1) 17 | #define RAND_BYTE() (rand() & 0xff) 18 | #define RAND_RANGE(min, max) (min + rand() / (RAND_MAX / (max - min + 1) + 1)) 19 | 20 | extern unsigned int seed; 21 | unsigned int init_seed(unsigned int seed); 22 | void set_seed(struct childdata *child); 23 | void reseed(void); 24 | unsigned int new_seed(void); 25 | 26 | void generate_rand_bytes(unsigned char *ptr, unsigned int len); 27 | unsigned int rand32(void); 28 | u64 rand64(void); 29 | unsigned long rand_single_bit(unsigned char size); 30 | unsigned long set_rand_bitmask(unsigned int num, const unsigned long *values); 31 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/sanitise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "syscall.h" 4 | 5 | void generic_sanitise(struct syscallrecord *rec); 6 | void generic_free_arg(struct syscallrecord *rec); 7 | 8 | unsigned long get_interesting_value(void); 9 | 10 | void *get_address(void); 11 | void *get_non_null_address(void); 12 | void *get_writable_address(unsigned long size); 13 | unsigned long find_previous_arg_address(struct syscallrecord *rec, unsigned int argnum); 14 | struct iovec * alloc_iovec(unsigned int num); 15 | unsigned long get_len(void); 16 | unsigned int get_pid(void); 17 | const char * get_filename(void); 18 | int get_random_fd(void); 19 | const char * generate_pathname(void); 20 | 21 | void gen_unicode_page(char *page, int pagesize); 22 | 23 | void generate_syscall_args(struct syscallrecord *rec); 24 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/trinity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern unsigned int num_online_cpus; 4 | 5 | extern char *progname; 6 | 7 | void main_loop(void); 8 | 9 | void init_watchdog(void); 10 | unsigned int check_if_fd(unsigned int child); 11 | 12 | #define __unused__ __attribute((unused)) 13 | 14 | #define FAIL 0 15 | #define SUCCESS 1 16 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/include/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | typedef enum { FALSE = 0, TRUE = 1 } bool; 6 | 7 | typedef __uint32_t u32; 8 | typedef __uint64_t u64; 9 | -------------------------------------------------------------------------------- /perf_data_fuzzer/trinity_files/random-length.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "arch.h" // page_size 4 | #include "sanitise.h" 5 | #include "random.h" 6 | 7 | unsigned long get_len(void) 8 | { 9 | int i = 0; 10 | 11 | i = rand32(); 12 | 13 | /* short circuit if 0 */ 14 | if (i == 0) 15 | return 0; 16 | 17 | switch (rand() % 6) { 18 | 19 | case 0: i &= 0xff; 20 | break; 21 | case 1: i &= page_size - 1; 22 | break; 23 | case 2: i &= 0xffff; 24 | break; 25 | case 3: i &= 0xffffff; 26 | break; 27 | case 4: i &= 0xffffffff; 28 | break; 29 | case 5: 30 | // Pass through 31 | break; 32 | } 33 | 34 | /* again, short circuit if 0 */ 35 | if (i == 0) 36 | return 0; 37 | 38 | /* we might get lucky if something is counting ints/longs etc. */ 39 | if (ONE_IN(4)) { 40 | int _div = 1 << RAND_RANGE(1, 4); /* 2,4,8 or 16 */ 41 | i /= _div; 42 | } 43 | 44 | return i; 45 | } 46 | -------------------------------------------------------------------------------- /tests/bpf/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | BPF_CC = clang 4 | #CC = clang-3.7 5 | #CFLAGS = -O2 -emit-llvm 6 | BPF_CFLAGS = -Wno-unused-value -Wno-pointer-sign -O2 -target bpf -I../../include 7 | 8 | CPPFLAGS +=-I../../include 9 | CFLAGS += -Wall -O2 10 | LDFLAGS += 11 | LIB = ../../lib 12 | 13 | PROGRAM_LIST = \ 14 | load_bpf 15 | 16 | all: $(PROGRAM_LIST) test_bpf.o test_bpf_output.o 17 | 18 | load_bpf: load_bpf.o $(LIB)/libhelper.a 19 | 20 | test_bpf.o: test_bpf.c 21 | $(BPF_CC) $(BPF_CFLAGS) -c test_bpf.c -o test_bpf.o 22 | 23 | test_bpf_output.o: test_bpf_output.c 24 | $(BPF_CC) $(BPF_CFLAGS) -c test_bpf_output.c -o test_bpf_output.o 25 | 26 | 27 | clean: clean-local 28 | @- $(RM) $(PROGRAM_LIST) 29 | @- $(RM) *.o 30 | 31 | clean-local: 32 | @- $(RM) *~ 33 | 34 | -------------------------------------------------------------------------------- /tests/bpf/README: -------------------------------------------------------------------------------- 1 | Needed 4.9-rc kernel, plus debugfs mounted 2 | sudo /home/vince/research/linux-kernel/linux-git/tools/perf/perf record -v -v -v -a -e bpf-output/no-inherit,name=evt/ -e ./test_bpf_output.c/map:channel.event=evt/ ls / 3 | 4 | 5 | Need libelf-dev and libdwarf-dev installed before perf will compile 6 | with BPF support. Otherwise you get obnoxious 7 | BPF support is not compiled 8 | message 9 | 10 | /home/vince/research/linux-kernel/linux-2.6/tools/perf/perf 11 | record -a -e bpf-output/no-inherit/ 12 | -e ./test_bpf_output.c/maps:channel:event=evt/ ls / 13 | 14 | run as root 15 | 16 | still get 17 | Failed to load program for unknown reason 18 | 19 | 20 | 21 | Generating BPF files is a pain. 22 | 23 | They are architecture specific and have to be re-built each time 24 | you re-build the kernel. 25 | 26 | Also you need a version of the clang compiler to build them. 27 | 28 | The sample code in this directory is from a lkml posting 29 | Date: Fri, 15 May 2015 17:20:42 +0800 30 | From: "Wangnan (F)" 31 | Subject: Re: [BUG] kernel panic after bpf program removed. 32 | 33 | You will need CLANG 3.7 or newer. You can get nightly snapshots for 34 | Debian from http://llvm.org/apt/ 35 | -------------------------------------------------------------------------------- /tests/breakpoints/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = breakpoint_support 9 | 10 | all: $(PROGRAM_LIST) 11 | 12 | breakpoint_support: breakpoint_support.o $(LIB)/libhelper.a 13 | 14 | clean: clean-local 15 | @- $(RM) $(PROGRAM_LIST) 16 | @- $(RM) *.o 17 | 18 | install: all 19 | $(INSTALL) -d $(prefix)/tests/breakpoints 20 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/breakpoints 21 | 22 | clean-local: 23 | @- $(RM) *~ 24 | -------------------------------------------------------------------------------- /tests/bugs/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS = -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | check_schedulability \ 10 | nmi_watchdog_group_leader \ 11 | peo_zero_return \ 12 | read_group_attached \ 13 | sync_read_required 14 | 15 | all: $(PROGRAM_LIST) 16 | 17 | read_group_attached: read_group_attached.o \ 18 | $(LIB)/libhelper.a 19 | 20 | check_schedulability: check_schedulability.o \ 21 | $(LIB)/libhelper.a 22 | 23 | sync_read_required: sync_read_required.o \ 24 | $(LIB)/libhelper.a 25 | 26 | nmi_watchdog_group_leader: nmi_watchdog_group_leader.o \ 27 | $(LIB)/libhelper.a 28 | 29 | peo_zero_return: peo_zero_return.o \ 30 | $(LIB)/libhelper.a 31 | 32 | install: all 33 | $(INSTALL) -d $(prefix)/tests/bugs 34 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/bugs 35 | 36 | clean: clean-local 37 | @- $(RM) $(PROGRAM_LIST) 38 | @- $(RM) *.o 39 | 40 | clean-local: 41 | @- $(RM) *~ 42 | -------------------------------------------------------------------------------- /tests/bugs/test_child.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double busywork(int count) { 4 | 5 | int i; 6 | double sum=0.0012; 7 | 8 | for(i=0;i 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "perf_event.h" 15 | #include "perf_helpers.h" 16 | #include "test_utils.h" 17 | 18 | int main(int argc, char **argv) { 19 | 20 | int fd; 21 | int quiet; 22 | 23 | char test_string[]="Testing EFAULT generation..."; 24 | 25 | quiet=test_quiet(); 26 | 27 | if (!quiet) { 28 | printf("This tries to get perf_event_open() to generate\n"); 29 | printf("an EFAULT return.\n\n"); 30 | } 31 | 32 | fd=perf_event_open(NULL, 33 | 0, /* current thread */ 34 | -1, /* any cpu */ 35 | -1, /* New Group Leader */ 36 | 0 /*0*/ ); 37 | 38 | if (fd<0) { 39 | if (errno==EFAULT) { 40 | if (!quiet) { 41 | printf("Properly triggered EFAULT\n"); 42 | } 43 | test_pass(test_string); 44 | exit(0); 45 | } 46 | 47 | } 48 | 49 | if (!quiet) { 50 | printf("Unexpectedly got: %s\n",strerror(errno)); 51 | } 52 | 53 | test_fail(test_string); 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /tests/flags/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | flags_cgroup \ 10 | flags_fd_no_group \ 11 | flags_fd_output \ 12 | flags_range_check 13 | 14 | all: $(PROGRAM_LIST) 15 | 16 | 17 | flags_cgroup:flags_cgroup.o $(LIB)/libhelper.a 18 | 19 | flags_fd_no_group:flags_fd_no_group.o $(LIB)/libhelper.a 20 | 21 | flags_fd_output:flags_fd_output.o $(LIB)/libhelper.a 22 | 23 | flags_range_check: flags_range_check.o $(LIB)/libhelper.a 24 | 25 | install: all 26 | $(INSTALL) -d $(prefix)/tests/flags 27 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/flags 28 | 29 | clean: clean-local 30 | @- $(RM) $(PROGRAM_LIST) 31 | @- $(RM) *.o 32 | 33 | clean-local: 34 | @- $(RM) *~ 35 | -------------------------------------------------------------------------------- /tests/generalized_events/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | branches \ 10 | branch-misses \ 11 | cycles \ 12 | instructions \ 13 | l1-dcache-loads \ 14 | l1-dcache-stores 15 | 16 | all: $(PROGRAM_LIST) 17 | 18 | 19 | branches:branches.o $(LIB)/libhelper.a 20 | 21 | branch-misses: branch-misses.o $(LIB)/libhelper.a 22 | 23 | cycles: cycles.o $(LIB)/libhelper.a 24 | $(CC) $(LDFLAGS) -o $@ $^ -lrt 25 | 26 | l1-dcache-loads: l1-dcache-loads.o $(LIB)/libhelper.a 27 | 28 | l1-dcache-stores: l1-dcache-stores.o $(LIB)/libhelper.a 29 | 30 | instructions: instructions.o $(LIB)/libhelper.a 31 | 32 | install: all 33 | $(INSTALL) -d $(prefix)/tests/generalized_events 34 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/generalized_events 35 | 36 | clean: clean-local 37 | @- $(RM) $(PROGRAM_LIST) 38 | @- $(RM) *.o 39 | 40 | clean-local: 41 | @- $(RM) *~ 42 | -------------------------------------------------------------------------------- /tests/multiplexing/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | check_multiplexing \ 10 | check_papi_multiplexing \ 11 | old_multiplexing 12 | 13 | all: $(PROGRAM_LIST) 14 | 15 | 16 | check_papi_multiplexing: check_papi_multiplexing.o \ 17 | $(LIB)/libhelper.a 18 | 19 | check_multiplexing: check_multiplexing.o \ 20 | $(LIB)/libhelper.a 21 | 22 | old_multiplexing: old_multiplexing.o $(LIB)/libhelper.a 23 | 24 | install: all 25 | $(INSTALL) -d $(prefix)/tests/multiplexing 26 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/multiplexing 27 | 28 | clean: clean-local 29 | @- $(RM) $(PROGRAM_LIST) 30 | @- $(RM) *.o 31 | 32 | clean-local: 33 | @- $(RM) *~ 34 | -------------------------------------------------------------------------------- /tests/multithread/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | fork_then_read \ 10 | lots_of_forks \ 11 | open_fork_close_kill 12 | 13 | all: $(PROGRAM_LIST) 14 | 15 | fork_then_read: fork_then_read.o \ 16 | $(LIB)/libhelper.a 17 | 18 | lots_of_forks: lots_of_forks.o \ 19 | $(LIB)/libhelper.a 20 | 21 | open_fork_close_kill: open_fork_close_kill.o \ 22 | $(LIB)/libhelper.a 23 | 24 | install: all 25 | $(INSTALL) -d $(prefix)/tests/multithread 26 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/multithread 27 | 28 | clean: clean-local 29 | @- $(RM) $(PROGRAM_LIST) 30 | @- $(RM) *.o 31 | 32 | clean-local: 33 | @- $(RM) *~ 34 | -------------------------------------------------------------------------------- /tests/multithread/TODO: -------------------------------------------------------------------------------- 1 | inherit? 2 | 3 | messing around with the fd from the child process 4 | 5 | SW_EVENT 6 | 7 | free after bug 8 | 9 | -------------------------------------------------------------------------------- /tests/openmp/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -fopenmp 5 | LDLIBS += -fopenmp 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = openmp_test openmp_overflow openmp_sample 9 | 10 | all: $(PROGRAM_LIST) 11 | 12 | openmp_test: openmp_test.o \ 13 | $(LIB)/libhelper.a 14 | 15 | openmp_overflow: openmp_overflow.o \ 16 | $(LIB)/libhelper.a 17 | 18 | openmp_sample: openmp_sample.o \ 19 | $(LIB)/libhelper.a 20 | 21 | install: all 22 | $(INSTALL) -d $(prefix)/tests/openmp 23 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/openmp 24 | 25 | clean: clean-local 26 | @- $(RM) $(PROGRAM_LIST) 27 | @- $(RM) *.o 28 | 29 | clean-local: 30 | @- $(RM) *~ 31 | -------------------------------------------------------------------------------- /tests/periodic_stats/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDLIBS += -lpthread 6 | LIB = ../../lib 7 | 8 | 9 | PROGRAM_LIST = \ 10 | print_record_sample 11 | 12 | all: $(PROGRAM_LIST) 13 | 14 | print_record_sample: print_record_sample.o 15 | 16 | install: all 17 | $(INSTALL) -d $(prefix)/tests/attr_fields 18 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/attr_fields 19 | 20 | clean: clean-local 21 | @- $(RM) $(PROGRAM_LIST) 22 | @- $(RM) *.o 23 | 24 | clean-local: 25 | @- $(RM) *~ 26 | -------------------------------------------------------------------------------- /tests/prctl/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | prctl \ 10 | prctl_attach \ 11 | prctl_child \ 12 | prctl_inherit \ 13 | prctl_parent 14 | 15 | 16 | 17 | 18 | all: $(PROGRAM_LIST) 19 | 20 | prctl: prctl.o $(LIB)/libhelper.a 21 | 22 | prctl_attach: prctl_attach.o $(LIB)/libhelper.a 23 | 24 | prctl_child: prctl_child.o $(LIB)/libhelper.a 25 | 26 | prctl_inherit: prctl_inherit.o $(LIB)/libhelper.a 27 | 28 | prctl_parent: prctl_parent.o $(LIB)/libhelper.a 29 | 30 | install: all 31 | $(INSTALL) -d $(prefix)/tests/prctl 32 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/prctl 33 | 34 | clean: clean-local 35 | @- $(RM) $(PROGRAM_LIST) 36 | @- $(RM) *.o 37 | 38 | clean-local: 39 | @- $(RM) *~ 40 | -------------------------------------------------------------------------------- /tests/rdpmc/rdpmc_invalid.c: -------------------------------------------------------------------------------- 1 | /* This test runs rdpmc() without enabling it via perf_event_open()/mmap() */ 2 | 3 | /* It's not a validation test, but just a utility for experimenting with */ 4 | /* rdpmc behavior */ 5 | 6 | /* Try messing with /sys/devices/cpu/rdpmc */ 7 | /* 0 should be disabled for all */ 8 | /* 1 should be per-process enabled if perf_event_open() followed by mmap() */ 9 | /* 2 should be enabled for all */ 10 | 11 | #include 12 | 13 | #include "rdpmc_lib.h" 14 | 15 | #if 0 16 | 17 | inline unsigned long long rdpmc(unsigned int counter) { 18 | 19 | unsigned int low, high; 20 | 21 | __asm__ volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (counter)); 22 | 23 | return (unsigned long long)low | ((unsigned long long)high) <<32; 24 | } 25 | 26 | 27 | #endif 28 | 29 | int main(int argc, char **argv) { 30 | 31 | 32 | printf("%lld\n",rdpmc(0)); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tests/rdpmc/rdpmc_lib.h: -------------------------------------------------------------------------------- 1 | unsigned long long mmap_read_self(void *addr, 2 | unsigned long long *enabled, 3 | unsigned long long *running); 4 | int detect_rdpmc(int quiet); 5 | 6 | extern unsigned long long rdtsc(void); 7 | extern unsigned long long rdpmc(unsigned int counter); 8 | 9 | #ifdef __aarch64__ 10 | #define ARCH_EVENT_CONFIG1_VAL 0x2 11 | #else 12 | #define ARCH_EVENT_CONFIG1_VAL 0 13 | #endif 14 | -------------------------------------------------------------------------------- /tests/size/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | header_mismatch \ 10 | just_right \ 11 | too_big \ 12 | too_little 13 | 14 | all: $(PROGRAM_LIST) 15 | 16 | header_mismatch: header_mismatch.o $(LIB)/libhelper.a 17 | 18 | just_right: just_right.o $(LIB)/libhelper.a 19 | 20 | too_big: too_big.o $(LIB)/libhelper.a 21 | 22 | too_little: too_little.o $(LIB)/libhelper.a 23 | 24 | install: all 25 | $(INSTALL) -d $(prefix)/tests/size 26 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/size 27 | 28 | clean: clean-local 29 | @- $(RM) $(PROGRAM_LIST) 30 | @- $(RM) *.o 31 | 32 | clean-local: 33 | @- $(RM) *~ 34 | -------------------------------------------------------------------------------- /tests/socket/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = socket_pass 9 | 10 | all: $(PROGRAM_LIST) 11 | 12 | socket_pass: socket_pass.o $(LIB)/libhelper.a 13 | 14 | install: all 15 | $(INSTALL) -d $(prefix)/tests/socket 16 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/socket 17 | 18 | clean: clean-local 19 | @- $(RM) $(PROGRAM_LIST) 20 | @- $(RM) *.o 21 | 22 | clean-local: 23 | @- $(RM) *~ 24 | -------------------------------------------------------------------------------- /tests/sysfs/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = events 9 | 10 | all: $(PROGRAM_LIST) 11 | 12 | events: events.o $(LIB)/libhelper.a 13 | 14 | install: all 15 | $(INSTALL) -d $(prefix)/tests/sysfs 16 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/sysfs 17 | 18 | clean: clean-local 19 | @- $(RM) $(PROGRAM_LIST) 20 | @- $(RM) *.o 21 | 22 | clean-local: 23 | @- $(RM) *~ 24 | -------------------------------------------------------------------------------- /tests/tracepoints/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = tracepoint_alias 9 | 10 | all: $(PROGRAM_LIST) 11 | 12 | tracepoint_alias: tracepoint_alias.o $(LIB)/libhelper.a 13 | 14 | install: all 15 | $(INSTALL) -d $(prefix)/tests/tracepoints 16 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/tracepoints 17 | 18 | clean: clean-local 19 | @- $(RM) $(PROGRAM_LIST) 20 | @- $(RM) *.o 21 | 22 | clean-local: 23 | @- $(RM) *~ 24 | -------------------------------------------------------------------------------- /tests/utils/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.globals.inc 2 | 3 | CPPFLAGS += -I../../include 4 | CFLAGS += -Wall -O2 -g 5 | LDFLAGS += 6 | LIB = ../../lib 7 | 8 | PROGRAM_LIST = \ 9 | check_paranoid \ 10 | get_cache_info 11 | 12 | all: $(PROGRAM_LIST) 13 | 14 | check_paranoid: check_paranoid.o $(LIB)/libhelper.a 15 | 16 | get_cache_info: get_cache_info.o $(LIB)/libhelper.a 17 | 18 | install: all 19 | $(INSTALL) -d $(prefix)/tests/utils 20 | $(INSTALL) -m755 $(PROGRAM_LIST) $(prefix)/tests/utils 21 | 22 | clean: clean-local 23 | @- $(RM) $(PROGRAM_LIST) 24 | @- $(RM) *.o 25 | 26 | clean-local: 27 | @- $(RM) *~ 28 | -------------------------------------------------------------------------------- /tests/utils/check_paranoid.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "test_utils.h" 4 | 5 | int main(int argc, char **argv) { 6 | 7 | int quiet; 8 | int result=0; 9 | char test_string[]="Checking /proc/sys/kernel/perf_event_paranoid setting..."; 10 | 11 | quiet=test_quiet(); 12 | 13 | result=check_paranoid_setting(2,quiet); 14 | if (result<0) { 15 | test_fail(test_string); 16 | } 17 | 18 | test_pass(test_string); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /tests/utils/get_cache_info.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "test_utils.h" 4 | #include "detect_cache.h" 5 | 6 | int main(int argc, char **argv) { 7 | 8 | int quiet; 9 | int i,j,max_level=0; 10 | int result=0; 11 | char test_string[]="Seeing if cache info is provided by the kernel..."; 12 | 13 | quiet=test_quiet(); 14 | 15 | result=gather_cache_info(quiet,test_string); 16 | if (result<0) { 17 | test_skip(test_string); 18 | } 19 | 20 | max_level=cache_get_max_levels(quiet,test_string); 21 | if (!quiet) { 22 | printf("Max level of cache=%d\n",max_level); 23 | } 24 | 25 | for(i=1;i<=max_level;i++) { 26 | for(j=0;j