mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-16 12:10:38 -04:00
perf/smmuv3: Validate group size
Ensure that a group will actually fit into the available counters. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
d91cc2f46a
commit
33e84ea433
@@ -323,6 +323,7 @@ static int smmu_pmu_event_init(struct perf_event *event)
|
|||||||
struct smmu_pmu *smmu_pmu = to_smmu_pmu(event->pmu);
|
struct smmu_pmu *smmu_pmu = to_smmu_pmu(event->pmu);
|
||||||
struct device *dev = smmu_pmu->dev;
|
struct device *dev = smmu_pmu->dev;
|
||||||
struct perf_event *sibling;
|
struct perf_event *sibling;
|
||||||
|
int group_num_events = 1;
|
||||||
u16 event_id;
|
u16 event_id;
|
||||||
|
|
||||||
if (event->attr.type != event->pmu->type)
|
if (event->attr.type != event->pmu->type)
|
||||||
@@ -347,18 +348,23 @@ static int smmu_pmu_event_init(struct perf_event *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Don't allow groups with mixed PMUs, except for s/w events */
|
/* Don't allow groups with mixed PMUs, except for s/w events */
|
||||||
if (event->group_leader->pmu != event->pmu &&
|
if (!is_software_event(event->group_leader)) {
|
||||||
!is_software_event(event->group_leader)) {
|
if (event->group_leader->pmu != event->pmu)
|
||||||
dev_dbg(dev, "Can't create mixed PMU group\n");
|
return -EINVAL;
|
||||||
return -EINVAL;
|
|
||||||
|
if (++group_num_events > smmu_pmu->num_counters)
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_sibling_event(sibling, event->group_leader) {
|
for_each_sibling_event(sibling, event->group_leader) {
|
||||||
if (sibling->pmu != event->pmu &&
|
if (is_software_event(sibling))
|
||||||
!is_software_event(sibling)) {
|
continue;
|
||||||
dev_dbg(dev, "Can't create mixed PMU group\n");
|
|
||||||
|
if (sibling->pmu != event->pmu)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (++group_num_events > smmu_pmu->num_counters)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hwc->idx = -1;
|
hwc->idx = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user