From owner-dev-commits-src-branches@freebsd.org Thu Jul 29 15:25:16 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18575675CD1; Thu, 29 Jul 2021 15:25:16 +0000 (UTC) (envelope-from git@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 4GbDqb70vyz4spT; Thu, 29 Jul 2021 15:25:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 D8A47141E8; Thu, 29 Jul 2021 15:25:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16TFPFsx009624; Thu, 29 Jul 2021 15:25:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16TFPFBv009623; Thu, 29 Jul 2021 15:25:15 GMT (envelope-from git) Date: Thu, 29 Jul 2021 15:25:15 GMT Message-Id: <202107291525.16TFPFBv009623@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 19135e372ff1 - stable/13 - arm64: Fix finding the pmc event ID MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 19135e372ff1627d2337f3014ee0bfe2e178d00a Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Jul 2021 15:25:16 -0000 The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=19135e372ff1627d2337f3014ee0bfe2e178d00a commit 19135e372ff1627d2337f3014ee0bfe2e178d00a Author: Andrew Turner AuthorDate: 2021-04-01 14:38:09 +0000 Commit: Mitchell Horne CommitDate: 2021-07-29 15:00:37 +0000 arm64: Fix finding the pmc event ID The lower pmc event bits were masked off to find the PMC event ID. The doesn't work when there are more events. Switch it to use the offser relative to the first event while also checking the ID is in the expected range. Reviewed by: gnn, ray Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D29600 (cherry picked from commit 24b2f4ea49229618c5608846acfc10be2eb0d567) --- sys/dev/hwpmc/hwpmc_arm64.c | 4 +++- sys/dev/hwpmc/hwpmc_arm64.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 49375219a485..050f861a74fe 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -181,7 +181,9 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, } pe = a->pm_ev; - config = (pe & EVENT_ID_MASK); + config = (uint32_t)pe - PMC_EV_ARMV8_FIRST; + if (config > (PMC_EV_ARMV8_LAST - PMC_EV_ARMV8_FIRST)) + return (EINVAL); pm->pm_md.pm_arm64.pm_arm64_evsel = config; PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config); diff --git a/sys/dev/hwpmc/hwpmc_arm64.h b/sys/dev/hwpmc/hwpmc_arm64.h index f0d43aa58ef8..fb7637a39c60 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.h +++ b/sys/dev/hwpmc/hwpmc_arm64.h @@ -40,7 +40,6 @@ #define ARMV8_RELOAD_COUNT_TO_PERFCTR_VALUE(R) (-(R)) #define ARMV8_PERFCTR_VALUE_TO_RELOAD_COUNT(P) (-(P)) -#define EVENT_ID_MASK 0xFF #ifdef _KERNEL /* MD extension for 'struct pmc' */