diff options
| -rw-r--r-- | arch/x86/events/core.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index a6006e7bb729..b1be0ac51ce0 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
| @@ -304,17 +304,20 @@ set_ext_hw_attr(struct hw_perf_event *hwc, struct perf_event *event) | |||
| 304 | 304 | ||
| 305 | config = attr->config; | 305 | config = attr->config; |
| 306 | 306 | ||
| 307 | cache_type = (config >> 0) & 0xff; | 307 | cache_type = (config >> 0) & 0xff; |
| 308 | if (cache_type >= PERF_COUNT_HW_CACHE_MAX) | 308 | if (cache_type >= PERF_COUNT_HW_CACHE_MAX) |
| 309 | return -EINVAL; | 309 | return -EINVAL; |
| 310 | cache_type = array_index_nospec(cache_type, PERF_COUNT_HW_CACHE_MAX); | ||
| 310 | 311 | ||
| 311 | cache_op = (config >> 8) & 0xff; | 312 | cache_op = (config >> 8) & 0xff; |
| 312 | if (cache_op >= PERF_COUNT_HW_CACHE_OP_MAX) | 313 | if (cache_op >= PERF_COUNT_HW_CACHE_OP_MAX) |
| 313 | return -EINVAL; | 314 | return -EINVAL; |
| 315 | cache_op = array_index_nospec(cache_op, PERF_COUNT_HW_CACHE_OP_MAX); | ||
| 314 | 316 | ||
| 315 | cache_result = (config >> 16) & 0xff; | 317 | cache_result = (config >> 16) & 0xff; |
| 316 | if (cache_result >= PERF_COUNT_HW_CACHE_RESULT_MAX) | 318 | if (cache_result >= PERF_COUNT_HW_CACHE_RESULT_MAX) |
| 317 | return -EINVAL; | 319 | return -EINVAL; |
| 320 | cache_result = array_index_nospec(cache_result, PERF_COUNT_HW_CACHE_RESULT_MAX); | ||
| 318 | 321 | ||
| 319 | val = hw_cache_event_ids[cache_type][cache_op][cache_result]; | 322 | val = hw_cache_event_ids[cache_type][cache_op][cache_result]; |
| 320 | 323 | ||
