freebsd-src/lib/libpmc
Jessica Clarke 21f7397a61 libpmc: Handle PMCALLOCATE log with PMC code on PMU event system
On an arm64 system that reports as a Cortex A72 r0p3, running

  pmcstat -P CPU_CYCLES command

works, but

  pmcstat -P cpu-cycles command

does not. This is because the former uses the PMU event from the JSON
source, resulting in pl_event in the log event being a small index
(here, 5) into the generated events table, whilst the latter does not
match any of the JSON events and falls back on PMC's own tables, mapping
it to the PMC event 0x14111, i.e. PMC_EV_ARMV8_EVENT_11H. Then, when
libpmc gets the PMCALLOCATE event, it tries to use the event as an index
into the JSON-derived table, but doing so only makes sense for the
former, whilst for the latter it will go way out of bounds and either
read junk (which may trigger the != NULL assertion) or segfault. As far
as I can tell we don't have anything lying around to tell us which of
the two cases we're in, but we can exploit the fact that the first
0x1000 PMC event codes are reserved, and that none of our PMU events
tables reach that number of entries yet.

PR:		268857
Reviewed by:	mhorne
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D39592
2023-06-07 15:24:29 +01:00
..
pmu-events pmc(3): Correct some typos in event descriptions 2022-09-04 12:52:38 +02:00
libpmc.c libpmc: Handle PMCALLOCATE log with PMC code on PMU event system 2023-06-07 15:24:29 +01:00
libpmc_json.cc pmc: Rework PROCEXEC event to support PIEs 2023-05-31 00:20:36 +01:00
libpmc_pmu_util.c spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
libpmcinternal.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
Makefile libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library. 2023-03-23 09:31:58 -07:00
Makefile.depend Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Makefile.inc Fix warnings with lib/libpmc 2019-04-14 00:06:49 +00:00
pmc.3 pmc: Keep a list sorted. 2023-04-05 20:09:28 +01:00
pmc.atom.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.atomsilvermont.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.cmn-600.3 Add the Arm CoreLink CMN-600 Coherent Mesh Network Controller PMU driver man page. 2022-07-10 12:26:55 +03:00
pmc.core.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.core2.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.corei7.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.corei7uc.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.dmc-620.3 Add pmc.dmc-620(3) man page. 2022-07-26 11:17:50 +03:00
pmc.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
pmc.haswell.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.haswelluc.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.haswellxeon.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.iaf.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.ivybridge.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.ivybridgexeon.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.k7.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.k8.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.sandybridge.3 pmc.sandybridge(3): Fix a few EVENT_ vs Event inconsistencies 2022-10-11 00:50:58 +01:00
pmc.sandybridgeuc.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.sandybridgexeon.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.soft.3 pmc: intr pmc.soft(3) update 2021-09-23 06:13:58 +02:00
pmc.tsc.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.ucf.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.westmere.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc.westmereuc.3 pmc(3): remove Pentium-related man pages and references 2021-08-10 17:19:58 -03:00
pmc_allocate.3 pmc_allocate(3): document the count argument 2021-04-21 17:35:03 -03:00
pmc_attach.3
pmc_capabilities.3
pmc_configure_logfile.3
pmc_disable.3
pmc_event_names_of_class.3
pmc_get_driver_stats.3
pmc_get_msr.3
pmc_init.3
pmc_name_of_capability.3
pmc_read.3
pmc_set.3
pmc_start.3
pmcformat.h spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD 2023-05-12 10:44:03 -06:00
pmclog.3
pmclog.c libpmc: Handle PMCALLOCATE log with PMC code on PMU event system 2023-06-07 15:24:29 +01:00
pmclog.h pmc: Rework PROCEXEC event to support PIEs 2023-05-31 00:20:36 +01:00