History

arm64: perf: Ignore exclude_hv when kernel is running in HYP

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.

Ganapatrao Kulkarni committed 9 years ago

Commit 78a19cf1 parent 8df728e1 file · +16 −7Browse files

Unified · Split

arch/arm64/kernel/perf_event.c+16−7
@@ -877,15 +877,24 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event, · 876 unmodified lines
877877
878878 if (attr->exclude_idle)
879879 return -EPERM;
880− if (is_kernel_in_hyp_mode() &&
881− attr->exclude_kernel != attr->exclude_hv)
882− return -EINVAL;
880+
881+ /*
882+ * If we're running in hyp mode, then we *are* the hypervisor.
883+ * Therefore we ignore exclude_hv in this configuration, since
884+ * there's no hypervisor to sample anyway. This is consistent
885+ * with other architectures (x86 and Power).
886+ */
887+ if (is_kernel_in_hyp_mode()) {
888+ if (!attr->exclude_kernel)
889+ config_base |= ARMV8_PMU_INCLUDE_EL2;
890+ } else {
891+ if (attr->exclude_kernel)
892+ config_base |= ARMV8_PMU_EXCLUDE_EL1;
893+ if (!attr->exclude_hv)
894+ config_base |= ARMV8_PMU_INCLUDE_EL2;
895+ }
883896 if (attr->exclude_user)
884897 config_base |= ARMV8_PMU_EXCLUDE_EL0;
885− if (!is_kernel_in_hyp_mode() && attr->exclude_kernel)
886− config_base |= ARMV8_PMU_EXCLUDE_EL1;
887− if (!attr->exclude_hv)
888− config_base |= ARMV8_PMU_INCLUDE_EL2;
889898
890899 /*
891900 * Install the filter into config_base as this is used to

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t