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
This commit is contained in:
parent
a8eb16c5ea
commit
744d67975f
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user