Patch "arm64: perf: Ignore exclude_hv when kernel is running in HYP" has been added to the 4.9-stable tree
Subsystems (4)
This is a note to let you know that I've just added the patch titled
arm64: perf: Ignore exclude_hv when kernel is running in HYP
to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-perf-ignore-exclude_hv-when-kernel-is-running-in-hyp.patch
and it can be found in the queue-4.9 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Mon Apr 9 17:09:24 CEST 2018
From: Ganapatrao Kulkarni <[email protected]>
Date: Tue, 2 May 2017 21:59:34 +0530
Subject: arm64: perf: Ignore exclude_hv when kernel is running in HYP
From: Ganapatrao Kulkarni <[email protected]>
[ Upstream commit 78a19cfdf37d19002c83c8790853c1cc10feccdc ]
commit d98ecdaca296 ("arm64: perf: Count EL2 events if the kernel is running in HYP") returns -EINVAL when perf system call perf_event_open is called with exclude_hv != exclude_kernel. This change breaks applications on VHE enabled ARMv8.1 platforms. The issue was observed with HHVM application, which calls perf_event_open with exclude_hv = 1 and exclude_kernel = 0.
There is no separate hypervisor privilege level when VHE is enabled, the host kernel runs at EL2. So when VHE is enabled, we should ignore exclude_hv from the application. This behaviour is consistent with PowerPC where the exclude_hv is ignored when the hypervisor is not present and with x86 where this flag is ignored.
--- arch/arm64/kernel/perf_event.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
arch/arm64/kernel/perf_event.c +16 -7
@@ -871,15 +871,24 @@ static int armv8pmu_set_event_filter(strif (attr->exclude_idle)return -EPERM ; -if (is_kernel_in_hyp_mode () && - attr->exclude_kernel != attr->exclude_hv) -return -EINVAL ; + +/* +* If we're running in hyp mode, then we *are* the hypervisor. +* Therefore we ignore exclude_hv in this configuration, since +* there's no hypervisor to sample anyway. This is consistent +* with other architectures (x86 and Power). +*/ +if (is_kernel_in_hyp_mode ()) { +if (!attr->exclude_kernel) + config_base |=ARMV8_PMU_INCLUDE_EL2 ; + }else { +if (attr->exclude_kernel) + config_base |=ARMV8_PMU_EXCLUDE_EL1 ; +if (!attr->exclude_hv) + config_base |=ARMV8_PMU_INCLUDE_EL2 ; + }if (attr->exclude_user) config_base |=ARMV8_PMU_EXCLUDE_EL0 ; -if (!is_kernel_in_hyp_mode () && attr->exclude_kernel) - config_base |=ARMV8_PMU_EXCLUDE_EL1 ; -if (!attr->exclude_hv) - config_base |=ARMV8_PMU_INCLUDE_EL2 ;/* * Install the filter into config_base as this is used to
Patches currently in stable-queue which might be from [email protected] are
queue-4.9/arm64-perf-ignore-exclude_hv-when-kernel-is-running-in-hyp.patch