Skip to content

Commit b35babd

Browse files
Jinrong Liangsean-jc
authored andcommitted
KVM: x86/pmu: Add documentation for fixed ctr on PMU filter
Update the documentation for the KVM_SET_PMU_EVENT_FILTER ioctl to include a detailed description of how fixed performance events are handled in the pmu filter. The action and fixed_counter_bitmap members of the pmu filter to determine whether fixed performance events can be programmed by the guest. This information is helpful for correctly configuring the fixed_counter_bitmap and action fields to filter fixed performance events. Suggested-by: Like Xu <[email protected]> Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/oe-kbuild-all/[email protected] Signed-off-by: Jinrong Liang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 78b5605 commit b35babd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5124,6 +5124,24 @@ Valid values for 'action'::
51245124
#define KVM_PMU_EVENT_ALLOW 0
51255125
#define KVM_PMU_EVENT_DENY 1
51265126

5127+
Via this API, KVM userspace can also control the behavior of the VM's fixed
5128+
counters (if any) by configuring the "action" and "fixed_counter_bitmap" fields.
5129+
5130+
Specifically, KVM follows the following pseudo-code when determining whether to
5131+
allow the guest FixCtr[i] to count its pre-defined fixed event::
5132+
5133+
FixCtr[i]_is_allowed = (action == ALLOW) && (bitmap & BIT(i)) ||
5134+
(action == DENY) && !(bitmap & BIT(i));
5135+
FixCtr[i]_is_denied = !FixCtr[i]_is_allowed;
5136+
5137+
KVM always consumes fixed_counter_bitmap, it's userspace's responsibility to
5138+
ensure fixed_counter_bitmap is set correctly, e.g. if userspace wants to define
5139+
a filter that only affects general purpose counters.
5140+
5141+
Note, the "events" field also applies to fixed counters' hardcoded event_select
5142+
and unit_mask values. "fixed_counter_bitmap" has higher priority than "events"
5143+
if there is a contradiction between the two.
5144+
51275145
4.121 KVM_PPC_SVM_OFF
51285146
---------------------
51295147

0 commit comments

Comments
 (0)