All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] KVM: arm64: Filtering PMU events
@ 2020-03-09 12:48 ` Marc Zyngier
  0 siblings, 0 replies; 46+ messages in thread
From: Marc Zyngier @ 2020-03-09 12:48 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm, kvm
  Cc: James Morse, Julien Thierry, Suzuki K Poulose, Robin Murphy,
	Mark Rutland, Eric Auger

It is at times necessary to prevent a guest from being able to sample
certain events if multiple CPUs share resources such as a cache level. In
this case, it would be interesting if the VMM could simply prevent certain
events from being counted instead of hiding the PMU.

Given that most events are not architected, there is no easy way to
designate which events shouldn't be counted other than specifying the raw
event number.

Since I have no idea whether it is better to use an event whitelist or
blacklist, the proposed API takes a cue from the x86 version and allows
either allowing or denying counting of ranges of events. The event space
being pretty large (16bits on ARMv8.1), the default policy is set by the
first filter that gets installed (default deny if we first allow, default
allow if we first deny).

The filter state is global to the guest, despite the PMU being per CPU. I'm
not sure whether it would be worth it making it CPU-private.

As an example of what can be done in userspace, I have the corresponding
kvmtool hack here[1].

* From v1:
  - Cleaned up handling of the cycle counter
  - Documented restrictions on SW_INC, CHAIN and CPU_CYCLES events

[1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/kvmtool.git/commit/?h=pmu-filter

Marc Zyngier (2):
  KVM: arm64: Add PMU event filtering infrastructure
  KVM: arm64: Document PMU filtering API

 Documentation/virt/kvm/devices/vcpu.rst | 40 ++++++++++++
 arch/arm64/include/asm/kvm_host.h       |  6 ++
 arch/arm64/include/uapi/asm/kvm.h       | 16 +++++
 virt/kvm/arm/arm.c                      |  2 +
 virt/kvm/arm/pmu.c                      | 84 ++++++++++++++++++++-----
 5 files changed, 132 insertions(+), 16 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2020-09-02 12:32 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 12:48 [PATCH v2 0/2] KVM: arm64: Filtering PMU events Marc Zyngier
2020-03-09 12:48 ` Marc Zyngier
2020-03-09 12:48 ` Marc Zyngier
2020-03-09 12:48 ` [PATCH v2 1/2] KVM: arm64: Add PMU event filtering infrastructure Marc Zyngier
2020-03-09 12:48   ` Marc Zyngier
2020-03-09 12:48   ` Marc Zyngier
2020-03-09 18:05   ` Auger Eric
2020-03-09 18:05     ` Auger Eric
2020-03-09 18:05     ` Auger Eric
2020-03-10 11:03     ` Marc Zyngier
2020-03-10 11:03       ` Marc Zyngier
2020-03-10 11:03       ` Marc Zyngier
2020-03-10 17:40       ` Auger Eric
2020-03-10 17:40         ` Auger Eric
2020-03-10 17:40         ` Auger Eric
2020-03-10 18:00         ` Marc Zyngier
2020-03-10 18:00           ` Marc Zyngier
2020-03-10 18:00           ` Marc Zyngier
2020-03-10 18:26           ` Auger Eric
2020-03-10 18:26             ` Auger Eric
2020-03-10 18:26             ` Auger Eric
2020-08-18 23:24           ` Alexander Graf
2020-08-18 23:24             ` Alexander Graf
2020-08-18 23:24             ` Alexander Graf
2020-08-20  7:37             ` Marc Zyngier
2020-08-20  7:37               ` Marc Zyngier
2020-08-20  7:37               ` Marc Zyngier
2020-09-02 12:23               ` Alexander Graf
2020-09-02 12:23                 ` Alexander Graf
2020-09-02 12:23                 ` Alexander Graf
2020-03-22 18:08   ` kbuild test robot
2020-03-09 12:48 ` [PATCH v2 2/2] KVM: arm64: Document PMU filtering API Marc Zyngier
2020-03-09 12:48   ` Marc Zyngier
2020-03-09 12:48   ` Marc Zyngier
2020-03-09 18:17   ` Auger Eric
2020-03-09 18:17     ` Auger Eric
2020-03-09 18:17     ` Auger Eric
2020-03-10 11:54     ` Marc Zyngier
2020-03-10 11:54       ` Marc Zyngier
2020-03-10 11:54       ` Marc Zyngier
2020-03-10 17:30       ` Auger Eric
2020-03-10 17:30         ` Auger Eric
2020-03-10 17:30         ` Auger Eric
2020-03-10 18:07         ` Marc Zyngier
2020-03-10 18:07           ` Marc Zyngier
2020-03-10 18:07           ` Marc Zyngier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.