Date: Tue, 01 Aug 2023 21:07:32 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 268857] pmcstat crashes on particular event/CPU combination Message-ID: <bug-268857-227-LVrmimPiR4@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-268857-227@https.bugs.freebsd.org/bugzilla/> References: <bug-268857-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D268857 --- Comment #2 from commit-hook@FreeBSD.org --- A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=3D051f41ddb517a9d3f6872678ccc3d0b6c= 0fffca1 commit 051f41ddb517a9d3f6872678ccc3d0b6c0fffca1 Author: Jessica Clarke <jrtc27@FreeBSD.org> AuthorDate: 2023-06-07 14:21:18 +0000 Commit: Jessica Clarke <jrtc27@FreeBSD.org> CommitDate: 2023-08-01 20:42:53 +0000 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 !=3D NULL assertion) or segfault. As f= ar 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 (cherry picked from commit 21f7397a61f7bff61a1221cc6340cd980a922540) lib/libpmc/libpmc.c | 9 ++++++++- lib/libpmc/pmclog.c | 27 +++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-268857-227-LVrmimPiR4>