git: b475ab8c78ac - stable/13 - hwpmc: don't validate capabilities in allocation method
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 05 Jul 2022 17:10:25 UTC
The branch stable/13 has been updated by mav:
URL: https://cgit.FreeBSD.org/src/commit/?id=b475ab8c78ace041c6b55cd26155ccced4ae75a2
commit b475ab8c78ace041c6b55cd26155ccced4ae75a2
Author: Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2021-08-30 17:03:18 +0000
Commit: Alexander Motin <mav@FreeBSD.org>
CommitDate: 2022-07-05 16:39:02 +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
(cherry picked from commit 0e78510b75497d183ab1aafbd99ff1031798bd84)
---
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 f0b202af8038..2b5356924ae6 100644
--- a/sys/dev/hwpmc/hwpmc_amd.c
+++ b/sys/dev/hwpmc/hwpmc_amd.c
@@ -609,8 +609,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 675e93c5771d..988cd1744a07 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 eaef95932c60..090e4523102d 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 c9a040f44ffd..7ec22c36019c 100644
--- a/sys/dev/hwpmc/hwpmc_core.c
+++ b/sys/dev/hwpmc/hwpmc_core.c
@@ -238,10 +238,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;
@@ -293,6 +290,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)
@@ -736,7 +734,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(),
@@ -747,10 +744,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 85ef0f441b5c..0d9085564c2a 100644
--- a/sys/dev/hwpmc/hwpmc_uncore.c
+++ b/sys/dev/hwpmc/hwpmc_uncore.c
@@ -192,7 +192,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));
@@ -202,10 +202,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;
@@ -518,7 +515,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(),
@@ -529,11 +525,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) {