summaryrefslogtreecommitdiffstats
path: root/sys/dev/hwpmc/hwpmc_mod.c
diff options
context:
space:
mode:
authorjkoshy <jkoshy@FreeBSD.org>2005-08-22 18:18:20 +0000
committerjkoshy <jkoshy@FreeBSD.org>2005-08-22 18:18:20 +0000
commit6720641d7ad75aaa7afe715e3f70703ffd73c3a3 (patch)
tree1ef45ceadd99efd38414c3d3cb817716aa08185b /sys/dev/hwpmc/hwpmc_mod.c
parent24bcb580cb1c10ea3f7a215861dddea12fccfa13 (diff)
downloadFreeBSD-src-6720641d7ad75aaa7afe715e3f70703ffd73c3a3.zip
FreeBSD-src-6720641d7ad75aaa7afe715e3f70703ffd73c3a3.tar.gz
Return EOPNOTSUPP instead of EINVAL if a PMC allocation request
specifies a PMC capability (e.g., sampling) that is not supported by hardware. Return EINVAL early if the PMC class passed in is not recognized. MFC after: 3 days
Diffstat (limited to 'sys/dev/hwpmc/hwpmc_mod.c')
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 5ba6a44..ecd83d2 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -2790,10 +2790,24 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
* All sampling mode PMCs need to be able to interrupt the
* CPU.
*/
-
if (PMC_IS_SAMPLING_MODE(mode))
caps |= PMC_CAP_INTERRUPT;
+ /* A valid class specifier should have been passed in. */
+ for (n = 0; n < md->pmd_nclass; n++)
+ if (md->pmd_classes[n].pm_class == pa.pm_class)
+ break;
+ if (n == md->pmd_nclass) {
+ error = EINVAL;
+ break;
+ }
+
+ /* The requested PMC capabilities should be feasible. */
+ if ((md->pmd_classes[n].pm_caps & caps) != caps) {
+ error = EOPNOTSUPP;
+ break;
+ }
+
PMCDBG(PMC,ALL,2, "event=%d caps=0x%x mode=%d cpu=%d",
pa.pm_ev, caps, mode, cpu);
OpenPOWER on IntegriCloud