summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel
diff options
context:
space:
mode:
authorNeil Leeder <nleeder@codeaurora.org>2014-07-11 14:06:02 -0400
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:48:15 -0700
commitb70837c8b27f553abe1722e2f52f8adad4cb012f (patch)
treef0c59120037fcde382454c29178efebd15af5606 /arch/arm64/kernel
parenta585783352a95554b39461d50110e96ceb31d3bd (diff)
Perf: arm64: add perf user-mode permissions
Allow user-mode applications to use the performance counters for debugging and performance analysis. Change-Id: I3985c0fccfe925c50ace5d33435f6f69b31e07a5 Signed-off-by: Neil Leeder <nleeder@codeaurora.org> [satyap: trivial merge conflict resolution] Signed-off-by: Satya Durga Srinivasu Prabhala <satyap@codeaurora.org>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r--arch/arm64/kernel/perf_debug.c3
-rw-r--r--arch/arm64/kernel/perf_event.c19
2 files changed, 19 insertions, 3 deletions
diff --git a/arch/arm64/kernel/perf_debug.c b/arch/arm64/kernel/perf_debug.c
index b0b4da762f95..4ae6c598e9d5 100644
--- a/arch/arm64/kernel/perf_debug.c
+++ b/arch/arm64/kernel/perf_debug.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -24,6 +24,7 @@
static char *descriptions =
" 0 arm64: perf: add debug patch logging framework\n"
" 1 Perf: arm64: Add L1 counters to tracepoints\n"
+ " 5 Perf: arm64: add perf user-mode permissions\n"
;
static ssize_t desc_read(struct file *fp, char __user *buf,
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index c7491471b04d..8f466a07ee5f 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -561,6 +561,22 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
return 0;
}
+#ifdef CONFIG_PERF_EVENTS_USERMODE
+static void armv8pmu_init_usermode(void)
+{
+ /* Enable access from userspace. */
+ asm volatile("msr pmuserenr_el0, %0" :: "r" (0xF));
+
+}
+#else
+static inline void armv8pmu_init_usermode(void)
+{
+ /* Disable access from userspace. */
+ asm volatile("msr pmuserenr_el0, %0" :: "r" (0));
+
+}
+#endif
+
static void armv8pmu_reset(void *info)
{
struct arm_pmu *cpu_pmu = (struct arm_pmu *)info;
@@ -575,8 +591,7 @@ static void armv8pmu_reset(void *info)
/* Initialize & Reset PMNC: C and P bits. */
armv8pmu_pmcr_write(armv8pmu_pmcr_read() | ARMV8_PMCR_P | ARMV8_PMCR_C);
- /* Disable access from userspace. */
- asm volatile("msr pmuserenr_el0, %0" :: "r" (0));
+ armv8pmu_init_usermode();
}
static int armv8_pmuv3_map_event(struct perf_event *event)