diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/alpha/kernel/perf_event.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/arch/alpha/kernel/perf_event.c b/arch/alpha/kernel/perf_event.c index d821b17047e0..c52e7f0ee5f6 100644 --- a/arch/alpha/kernel/perf_event.c +++ b/arch/alpha/kernel/perf_event.c | |||
@@ -83,6 +83,8 @@ struct alpha_pmu_t { | |||
83 | long pmc_left[3]; | 83 | long pmc_left[3]; |
84 | /* Subroutine for allocation of PMCs. Enforces constraints. */ | 84 | /* Subroutine for allocation of PMCs. Enforces constraints. */ |
85 | int (*check_constraints)(struct perf_event **, unsigned long *, int); | 85 | int (*check_constraints)(struct perf_event **, unsigned long *, int); |
86 | /* Subroutine for checking validity of a raw event for this PMU. */ | ||
87 | int (*raw_event_valid)(u64 config); | ||
86 | }; | 88 | }; |
87 | 89 | ||
88 | /* | 90 | /* |
@@ -203,6 +205,12 @@ success: | |||
203 | } | 205 | } |
204 | 206 | ||
205 | 207 | ||
208 | static int ev67_raw_event_valid(u64 config) | ||
209 | { | ||
210 | return config >= EV67_CYCLES && config < EV67_LAST_ET; | ||
211 | }; | ||
212 | |||
213 | |||
206 | static const struct alpha_pmu_t ev67_pmu = { | 214 | static const struct alpha_pmu_t ev67_pmu = { |
207 | .event_map = ev67_perfmon_event_map, | 215 | .event_map = ev67_perfmon_event_map, |
208 | .max_events = ARRAY_SIZE(ev67_perfmon_event_map), | 216 | .max_events = ARRAY_SIZE(ev67_perfmon_event_map), |
@@ -211,7 +219,8 @@ static const struct alpha_pmu_t ev67_pmu = { | |||
211 | .pmc_count_mask = {EV67_PCTR_0_COUNT_MASK, EV67_PCTR_1_COUNT_MASK, 0}, | 219 | .pmc_count_mask = {EV67_PCTR_0_COUNT_MASK, EV67_PCTR_1_COUNT_MASK, 0}, |
212 | .pmc_max_period = {(1UL<<20) - 1, (1UL<<20) - 1, 0}, | 220 | .pmc_max_period = {(1UL<<20) - 1, (1UL<<20) - 1, 0}, |
213 | .pmc_left = {16, 4, 0}, | 221 | .pmc_left = {16, 4, 0}, |
214 | .check_constraints = ev67_check_constraints | 222 | .check_constraints = ev67_check_constraints, |
223 | .raw_event_valid = ev67_raw_event_valid, | ||
215 | }; | 224 | }; |
216 | 225 | ||
217 | 226 | ||
@@ -609,7 +618,9 @@ static int __hw_perf_event_init(struct perf_event *event) | |||
609 | } else if (attr->type == PERF_TYPE_HW_CACHE) { | 618 | } else if (attr->type == PERF_TYPE_HW_CACHE) { |
610 | return -EOPNOTSUPP; | 619 | return -EOPNOTSUPP; |
611 | } else if (attr->type == PERF_TYPE_RAW) { | 620 | } else if (attr->type == PERF_TYPE_RAW) { |
612 | ev = attr->config & 0xff; | 621 | if (!alpha_pmu->raw_event_valid(attr->config)) |
622 | return -EINVAL; | ||
623 | ev = attr->config; | ||
613 | } else { | 624 | } else { |
614 | return -EOPNOTSUPP; | 625 | return -EOPNOTSUPP; |
615 | } | 626 | } |