From 6720641d7ad75aaa7afe715e3f70703ffd73c3a3 Mon Sep 17 00:00:00 2001 From: jkoshy Date: Mon, 22 Aug 2005 18:18:20 +0000 Subject: 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 --- sys/dev/hwpmc/hwpmc_mod.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sys/dev/hwpmc') 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); -- cgit v1.1