Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: perf: Count EL2 events if the kernel is running in HYP

When the kernel is running in HYP (with VHE), it is necessary to
include EL2 events if the user requests counting kernel or
hypervisor events.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>

+5 -1
+5 -1
arch/arm64/kernel/perf_event.c
··· 20 20 */ 21 21 22 22 #include <asm/irq_regs.h> 23 + #include <asm/virt.h> 23 24 24 25 #include <linux/of.h> 25 26 #include <linux/perf/arm_pmu.h> ··· 692 691 693 692 if (attr->exclude_idle) 694 693 return -EPERM; 694 + if (is_kernel_in_hyp_mode() && 695 + attr->exclude_kernel != attr->exclude_hv) 696 + return -EINVAL; 695 697 if (attr->exclude_user) 696 698 config_base |= ARMV8_EXCLUDE_EL0; 697 - if (attr->exclude_kernel) 699 + if (!is_kernel_in_hyp_mode() && attr->exclude_kernel) 698 700 config_base |= ARMV8_EXCLUDE_EL1; 699 701 if (!attr->exclude_hv) 700 702 config_base |= ARMV8_INCLUDE_EL2;