[PATCH v9 15/22] KVM: arm64: Allow kvm_vcpu_pmu_resync_el0() to resync filters in process context

From: Colton Lewis

Date: Thu Sep 24 2026 - 14:38:38 EST


Previously, kvm_vcpu_pmu_resync_el0() only scheduled
KVM_REQ_RESYNC_PMU_EL0 when called from interrupt context (such as an
IPI reprogramming host perf events). When perf_pmu_resched_update() is
invoked synchronously from process context during vCPU load/put to
reschedule host events around guest-reserved counters,
armv8pmu_enable_event() calls kvm_set_pmu_events() and
kvm_vcpu_pmu_resync_el0() in process context.

Update kvm_vcpu_pmu_resync_el0() to call kvm_vcpu_pmu_restore_guest()
directly when not in interrupt context so that newly rescheduled host
perf events have their EL0 exclusion filters applied immediately.

Signed-off-by: Colton Lewis <coltonlewis@xxxxxxxxxx>
---
arch/arm64/kvm/pmu.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kvm/pmu.c b/arch/arm64/kvm/pmu.c
index 6f60f86fad387..a8214ab52fcb5 100644
--- a/arch/arm64/kvm/pmu.c
+++ b/arch/arm64/kvm/pmu.c
@@ -213,14 +213,17 @@ void kvm_vcpu_pmu_resync_el0(void)
{
struct kvm_vcpu *vcpu;

- if (!has_vhe() || !in_interrupt())
+ if (!has_vhe())
return;

vcpu = kvm_get_running_vcpu();
if (!vcpu)
return;

- kvm_make_request(KVM_REQ_RESYNC_PMU_EL0, vcpu);
+ if (in_interrupt())
+ kvm_make_request(KVM_REQ_RESYNC_PMU_EL0, vcpu);
+ else
+ kvm_vcpu_pmu_restore_guest(vcpu);
}

void kvm_host_pmu_init(struct arm_pmu *pmu)
--
2.56.0.rc1.310.g51773c2048-goog