diff options
author | jkoshy <jkoshy@FreeBSD.org> | 2005-08-22 18:18:20 +0000 |
---|---|---|
committer | jkoshy <jkoshy@FreeBSD.org> | 2005-08-22 18:18:20 +0000 |
commit | 6720641d7ad75aaa7afe715e3f70703ffd73c3a3 (patch) | |
tree | 1ef45ceadd99efd38414c3d3cb817716aa08185b /sys/dev/hwpmc/hwpmc_mod.c | |
parent | 24bcb580cb1c10ea3f7a215861dddea12fccfa13 (diff) | |
download | FreeBSD-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.c | 16 |
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); |