Commit cb0140ec authored by Nikita Ioffe's avatar Nikita Ioffe
Browse files

ANDROID: KVM: arm64: fix off-by-one error in hyp_trace_find_event



Hypervisor tracing expects 1:1 mapping between tracing events exposed
under /sys/kernel/tracing/hyp/events and their representation in the
hypervisor. Previously this was done by simply using the same id,
however it broke some userspace tracing tools (e.g. Perfetto) that rely
on the fact that event IDs are positive integers.

Patch e5782bee1e84332 (ANDROID: kvm: arm64: start hypervisor event IDs
from 1) attempted to fix the issue, but an off-by-one bug in the
hyp_trace_find_event function which relies on the fact that event ID is
equal to the position of the event relative to the __hyp_events_start.

This patch attempts to properly fix the bug by iterating over all the
known events and finding the one that has the requested ID. This changes
the complexity of the hyp_trace_find_event function from O(|number of
EL2 modules|) to O(|number of registered events|), however since there
are less than 10 hypervisor events the change shouldn't introduce any
impact on hypervisor tracing performance.

Bug: 428904926
Test: presubmit
Test: boot qemu check tracing works
Change-Id: I14426a584980911fc1a3ffc2d0ab6e2141c4fa77
Signed-off-by: default avatarNikita Ioffe <ioffe@google.com>
parent c44bb3fc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment