diff options
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_lbr.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c index de341d4ec92a..d978353c939b 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c | |||
@@ -310,7 +310,7 @@ void intel_pmu_lbr_read(void) | |||
310 | * - in case there is no HW filter | 310 | * - in case there is no HW filter |
311 | * - in case the HW filter has errata or limitations | 311 | * - in case the HW filter has errata or limitations |
312 | */ | 312 | */ |
313 | static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event) | 313 | static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event) |
314 | { | 314 | { |
315 | u64 br_type = event->attr.branch_sample_type; | 315 | u64 br_type = event->attr.branch_sample_type; |
316 | int mask = 0; | 316 | int mask = 0; |
@@ -318,8 +318,11 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event) | |||
318 | if (br_type & PERF_SAMPLE_BRANCH_USER) | 318 | if (br_type & PERF_SAMPLE_BRANCH_USER) |
319 | mask |= X86_BR_USER; | 319 | mask |= X86_BR_USER; |
320 | 320 | ||
321 | if (br_type & PERF_SAMPLE_BRANCH_KERNEL) | 321 | if (br_type & PERF_SAMPLE_BRANCH_KERNEL) { |
322 | if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN)) | ||
323 | return -EACCES; | ||
322 | mask |= X86_BR_KERNEL; | 324 | mask |= X86_BR_KERNEL; |
325 | } | ||
323 | 326 | ||
324 | /* we ignore BRANCH_HV here */ | 327 | /* we ignore BRANCH_HV here */ |
325 | 328 | ||
@@ -339,6 +342,8 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event) | |||
339 | * be used by fixup code for some CPU | 342 | * be used by fixup code for some CPU |
340 | */ | 343 | */ |
341 | event->hw.branch_reg.reg = mask; | 344 | event->hw.branch_reg.reg = mask; |
345 | |||
346 | return 0; | ||
342 | } | 347 | } |
343 | 348 | ||
344 | /* | 349 | /* |
@@ -386,7 +391,9 @@ int intel_pmu_setup_lbr_filter(struct perf_event *event) | |||
386 | /* | 391 | /* |
387 | * setup SW LBR filter | 392 | * setup SW LBR filter |
388 | */ | 393 | */ |
389 | intel_pmu_setup_sw_lbr_filter(event); | 394 | ret = intel_pmu_setup_sw_lbr_filter(event); |
395 | if (ret) | ||
396 | return ret; | ||
390 | 397 | ||
391 | /* | 398 | /* |
392 | * setup HW LBR filter, if any | 399 | * setup HW LBR filter, if any |