Skip to content

KVM: arm64: Fix PMU handling in pKVM

Fuad Tabba kvmarm linux-arm-kernel lkml 3 versions – Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 1 replyApplied
  2. v23 patches 2 repliesSuperseded
  3. v13 patches 4 repliesSuperseded

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3KVM: arm64: Synchronise kvm_host_data before host deprivilegingarch/arm64/kvm/pkvm.c+6 -00 replies
2/3KVM: arm64: Pass the PMU events to the hyp vCPU of non-protected guestsarch/arm64/kvm/hyp/nvhe/hyp-main.c+11 -00 replies
3/3KVM: arm64: Disable host PMU counters for protected guestsarch/arm64/kvm/hyp/nvhe/switch.c+24 -00 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchVincent Donnefort
1/3
2/3T-b R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] KVM: arm64: Fix PMU handling in pKVM

Hi folks,

Changes since v2 [1]:
- Stop the host's counters with PMCR_EL0.E rather than the individual counter enables. (Marc)

Two fixes and a hardening patch for PMU handling in pKVM, as one series [2].

The first is Vincent's rework of his HPMN fix. It supersedes his earlier posting [3]. Rather than read nr_event_counters through a different accessor, the host copies the hypervisor's kvm_host_data before it's deprivileged, so host_data_ptr() returns what was set up at init. Otherwise, HPMN is 0 and a non-protected guest's event counters don't count.

The second is the non-protected half of Oliver's patch from 2024 [4]. It passes the host's PMU events to the hyp vCPU of a non-protected guest, whose counters otherwise all read 0.

The third covers the protected half. It stops the host's counters while a protected guest runs, so the host can't count the guest's cycles and events. Side channels are outside pKVM's threat model, so it carries no
Fixes: tag.

Based on kvmarm/next (dd0bc00e3e920).

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (1):
KVM: arm64: Disable host PMU counters for protected guests

Oliver Upton (1):
KVM: arm64: Pass the PMU events to the hyp vCPU of non-protected
guests

Vincent Donnefort (1):
KVM: arm64: Synchronise kvm_host_data before host deprivileging

 arch/arm64/kvm/hyp/nvhe/hyp-main.c | 11 +++++++++++
 arch/arm64/kvm/hyp/nvhe/switch.c   | 24 ++++++++++++++++++++++++
 arch/arm64/kvm/pkvm.c              |  6 ++++++
 3 files changed, 41 insertions(+)

base-commit: dd0bc00e3e9201fd49b62ff9cc07890c89003afe

Signature · 1 line
2.47.3