aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2013-05-03 08:11:25 -0400
committerIngo Molnar <mingo@kernel.org>2013-05-05 04:58:11 -0400
commit7cc23cd6c0c7d7f4bee057607e7ce01568925717 (patch)
tree9d2b46d8cc614f6ad11ed82b0f93e855e8531f42 /arch/x86/kernel
parent6e15eb3ba6c0249c9e8c783517d131b47db995ca (diff)
perf/x86/intel/lbr: Demand proper privileges for PERF_SAMPLE_BRANCH_KERNEL
We should always have proper privileges when requesting kernel data. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: <stable@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: eranian@google.com Link: http://lkml.kernel.org/r/20130503121256.230745028@chello.nl [ Fix build error reported by fengguang.wu@intel.com, propagate error code back. ] Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/n/tip-v0x9ky3ahzr6nm3c6ilwrili@git.kernel.org
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_lbr.c13
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 */
313static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event) 313static 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