From nobody Tue Aug 01 21:07:32 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RFnkK5tZyz4prNF for ; Tue, 1 Aug 2023 21:07:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RFnkD42dZz3Lp3 for ; Tue, 1 Aug 2023 21:07:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690924052; a=rsa-sha256; cv=none; b=qshSUTbJ90JlmjtSr/zZ6/R5OQN5tWvzCda0T7fWgtzWlSHU9GBVbUtMxyZJ4NwmEfVSc/ o0NDWpgYK/sg35S99nLDpXyuFKZ5ilQCgmxTWy9QvKOCWXTVvwAsN/Yv2OC6EGP9tpJOoD iNVEGfqkeHd5ynKU9Iyc2K7kmNOX0TJ0RUw449ITzIscMv0vZj7ytJ0+6RkaZyBHd7S1Q4 /VnLV5KfWjsyvlUjbyhFIwv9FuJouQYpyaSTR2i9mZwZuL+u+BXwAT285K6jV/HTJEprzN jdo9gKRs0weW17GVInbgtZqaq1oJFgb2wc6bdRMODlDNCcAQg1aop6Nc8ns/UA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690924052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M6PsXsIDzeS0CMlk1tGqogqwlyjOpTh+AdKpqJ1QoWQ=; b=gP5F1uBnQxM6FBW0Xp1l9FUrE5oe3ulZNnse1filkP5u9/1/H3GhTBCnCOu06xVQFAhpJe 59ogNvTymeLddWK4VoKxZjjDw6dXHPbI9/pv/apx+qhWE+iHoGlce2jVwRLQK8iYlwv9k2 HGbo161M3lvjpn/dF11udCfrpwxR+GbgaBnRz8FMrghOctjYPDlbGRx27LxPze0PP9yy/o GABzzYCwS0PF4OqJHPreE2sNEBK4xEpG6SvO+kcnd5vPN/olF3728K12owu3sJTDOMQvPs 9mWV0Yey2hA3XxKMSt3vDzN2fK/MiIvqxX8V3ZTp6xNCzMmtwaF54PbIQBTJug== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RFnkD2C0pzssj for ; Tue, 1 Aug 2023 21:07:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 371L7VZt066654 for ; Tue, 1 Aug 2023 21:07:31 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from bugzilla@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 371L7VQm066653 for bugs@FreeBSD.org; Tue, 1 Aug 2023 21:07:31 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: bugzilla set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 268857] pmcstat crashes on particular event/CPU combination Date: Tue, 01 Aug 2023 21:07:32 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.1-STABLE X-Bugzilla-Keywords: crash X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: commit-hook@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 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 AuthorDate: 2023-06-07 14:21:18 +0000 Commit: Jessica Clarke 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.=