The branch main has been updated by mhorne:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=0e78510b75497d183ab1aafbd99ff1031798bd84

commit 0e78510b75497d183ab1aafbd99ff1031798bd84
Author:     Mitchell Horne <[email protected]>
AuthorDate: 2021-08-30 17:03:18 +0000
Commit:     Mitchell Horne <[email protected]>
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) {
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to