From owner-dev-commits-src-main@freebsd.org Mon Aug 30 19:15:56 2021 Return-Path: Delivered-To: dev-commits-src-main@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 BB8B965C3B4; Mon, 30 Aug 2021 19:15:56 +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 4Gz0R005GNz4sJ9; Mon, 30 Aug 2021 19:15:56 +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 DED192352F; Mon, 30 Aug 2021 19:15:55 +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 17UJFtJN056519; Mon, 30 Aug 2021 19:15:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 17UJFtt2056518; Mon, 30 Aug 2021 19:15:55 GMT (envelope-from git) Date: Mon, 30 Aug 2021 19:15:55 GMT Message-Id: <202108301915.17UJFtt2056518@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 0e78510b7549 - main - hwpmc: don't validate capabilities in allocation method 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/main X-Git-Reftype: branch X-Git-Commit: 0e78510b75497d183ab1aafbd99ff1031798bd84 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 19:15:56 -0000 The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=0e78510b75497d183ab1aafbd99ff1031798bd84 commit 0e78510b75497d183ab1aafbd99ff1031798bd84 Author: Mitchell Horne AuthorDate: 2021-08-30 17:03:18 +0000 Commit: Mitchell Horne CommitDate: 2021-08-30 19:12:59 +0000 hwpmc: don't validate capabilities in allocation method These checks were inconsistently applied across the various hwpmc classes. The condition is already checked by the generic code in hwpmc_mod.c, so remove them. MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31388 --- sys/dev/hwpmc/hwpmc_amd.c | 2 -- sys/dev/hwpmc/hwpmc_arm64.c | 3 +-- sys/dev/hwpmc/hwpmc_armv7.c | 2 -- sys/dev/hwpmc/hwpmc_core.c | 11 ++--------- sys/dev/hwpmc/hwpmc_tsc.c | 6 ------ sys/dev/hwpmc/hwpmc_uncore.c | 13 ++----------- 6 files changed, 5 insertions(+), 32 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c index 024024ece19b..b26e31cc1543 100644 --- a/sys/dev/hwpmc/hwpmc_amd.c +++ b/sys/dev/hwpmc/hwpmc_amd.c @@ -600,8 +600,6 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm, if((ri >= 12 && ri < 16) && !(a->pm_md.pm_amd.pm_amd_sub_class == PMC_AMD_SUB_CLASS_DATA_FABRIC)) return EINVAL; - if ((pd->pd_caps & caps) != caps) - return EPERM; if (strlen(pmc_cpuid) != 0) { pm->pm_md.pm_amd.pm_amd_evsel = a->pm_md.pm_amd.pm_amd_config; diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c index 8a149f5f508f..14283b22644d 100644 --- a/sys/dev/hwpmc/hwpmc_arm64.c +++ b/sys/dev/hwpmc/hwpmc_arm64.c @@ -164,7 +164,7 @@ static int arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { - uint32_t caps, config; + uint32_t config; struct arm64_cpu *pac; enum pmc_event pe; @@ -175,7 +175,6 @@ arm64_allocate_pmc(int cpu, int ri, struct pmc *pm, pac = arm64_pcpu[cpu]; - caps = a->pm_caps; if (a->pm_class != PMC_CLASS_ARMV8) { return (EINVAL); } diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c index 84a983bbc69c..12b3fff4d743 100644 --- a/sys/dev/hwpmc/hwpmc_armv7.c +++ b/sys/dev/hwpmc/hwpmc_armv7.c @@ -141,7 +141,6 @@ armv7_allocate_pmc(int cpu, int ri, struct pmc *pm, struct armv7_cpu *pac; enum pmc_event pe; uint32_t config; - uint32_t caps; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[armv7,%d] illegal CPU value %d", __LINE__, cpu)); @@ -150,7 +149,6 @@ armv7_allocate_pmc(int cpu, int ri, struct pmc *pm, pac = armv7_pcpu[cpu]; - caps = a->pm_caps; if (a->pm_class != PMC_CLASS_ARMV7) return (EINVAL); pe = a->pm_ev; diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 507b20488132..84967e8a6248 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -236,10 +236,7 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, if (ri < 0 || ri > core_iaf_npmc) return (EINVAL); - caps = a->pm_caps; - - if (a->pm_class != PMC_CLASS_IAF || - (caps & IAF_PMC_CAPS) != caps) + if (a->pm_class != PMC_CLASS_IAF) return (EINVAL); iap = &a->pm_md.pm_iap; @@ -275,6 +272,7 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm, if (config & IAP_INT) flags |= IAF_PMI; + caps = a->pm_caps; if (caps & PMC_CAP_INTERRUPT) flags |= IAF_PMI; if (caps & PMC_CAP_SYSTEM) @@ -742,7 +740,6 @@ iap_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { uint8_t ev; - uint32_t caps; const struct pmc_md_iap_op_pmcallocate *iap; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -753,10 +750,6 @@ iap_allocate_pmc(int cpu, int ri, struct pmc *pm, if (a->pm_class != PMC_CLASS_IAP) return (EINVAL); - /* check requested capabilities */ - caps = a->pm_caps; - if ((IAP_PMC_CAPS & caps) != caps) - return (EPERM); iap = &a->pm_md.pm_iap; ev = IAP_EVSEL_GET(iap->pm_iap_config); diff --git a/sys/dev/hwpmc/hwpmc_tsc.c b/sys/dev/hwpmc/hwpmc_tsc.c index 6cd098a8113b..d59c8908f4ca 100644 --- a/sys/dev/hwpmc/hwpmc_tsc.c +++ b/sys/dev/hwpmc/hwpmc_tsc.c @@ -83,12 +83,6 @@ tsc_allocate_pmc(int cpu, int ri, struct pmc *pm, if (a->pm_class != PMC_CLASS_TSC) return (EINVAL); - if ((pm->pm_caps & TSC_CAPS) == 0) - return (EINVAL); - - if ((pm->pm_caps & ~TSC_CAPS) != 0) - return (EPERM); - if (a->pm_ev != PMC_EV_TSC_TSC || a->pm_mode != PMC_MODE_SC) return (EINVAL); diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c index 19017cabddd9..adb0e12c7454 100644 --- a/sys/dev/hwpmc/hwpmc_uncore.c +++ b/sys/dev/hwpmc/hwpmc_uncore.c @@ -189,7 +189,7 @@ static int ucf_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { - uint32_t caps, flags; + uint32_t flags; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), ("[uncore,%d] illegal CPU %d", __LINE__, cpu)); @@ -199,10 +199,7 @@ ucf_allocate_pmc(int cpu, int ri, struct pmc *pm, if (ri < 0 || ri > uncore_ucf_npmc) return (EINVAL); - caps = a->pm_caps; - - if (a->pm_class != PMC_CLASS_UCF || - (caps & UCF_PMC_CAPS) != caps) + if (a->pm_class != PMC_CLASS_UCF) return (EINVAL); flags = UCF_EN; @@ -522,7 +519,6 @@ ucp_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { uint8_t ev; - uint32_t caps; const struct pmc_md_ucp_op_pmcallocate *ucp; KASSERT(cpu >= 0 && cpu < pmc_cpu_max(), @@ -533,11 +529,6 @@ ucp_allocate_pmc(int cpu, int ri, struct pmc *pm, if (a->pm_class != PMC_CLASS_UCP) return (EINVAL); - /* check requested capabilities */ - caps = a->pm_caps; - if ((UCP_PMC_CAPS & caps) != caps) - return (EPERM); - ucp = &a->pm_md.pm_ucp; ev = UCP_EVSEL(ucp->pm_ucp_config); switch (uncore_cputype) {