Merge tag 'arm64-perf' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[sfrench/cifs-2.6.git] / arch / arm64 / kernel / perf_event.c
index c4c97655662e7f75a42bfef505299c2a7a223053..767c4f6e1f5ba0293e3bddff1910b6bb50cf5660 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include <asm/irq_regs.h>
+#include <asm/virt.h>
 
 #include <linux/of.h>
 #include <linux/perf/arm_pmu.h>
@@ -749,9 +750,12 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event,
 
        if (attr->exclude_idle)
                return -EPERM;
+       if (is_kernel_in_hyp_mode() &&
+           attr->exclude_kernel != attr->exclude_hv)
+               return -EINVAL;
        if (attr->exclude_user)
                config_base |= ARMV8_EXCLUDE_EL0;
-       if (attr->exclude_kernel)
+       if (!is_kernel_in_hyp_mode() && attr->exclude_kernel)
                config_base |= ARMV8_EXCLUDE_EL1;
        if (!attr->exclude_hv)
                config_base |= ARMV8_INCLUDE_EL2;