Skip to content

Commit fe53538

Browse files
akihikodakioupton
authored andcommitted
KVM: arm64: PMU: Reload when resetting
Replace kvm_pmu_vcpu_reset() with the generic PMU reloading mechanism to ensure the consistency with system registers and to reduce code size. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250315-pmc-v5-5-ecee87dab216@daynix.com Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
1 parent 1db4aaa commit fe53538

File tree

4 files changed

+3
-19
lines changed

4 files changed

+3
-19
lines changed

arch/arm64/kvm/pmu-emul.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,6 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
254254
pmu->pmc[i].idx = i;
255255
}
256256

257-
/**
258-
* kvm_pmu_vcpu_reset - reset pmu state for cpu
259-
* @vcpu: The vcpu pointer
260-
*
261-
*/
262-
void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
263-
{
264-
unsigned long mask = kvm_pmu_implemented_counter_mask(vcpu);
265-
int i;
266-
267-
for_each_set_bit(i, &mask, 32)
268-
kvm_pmu_stop_counter(kvm_vcpu_idx_to_pmc(vcpu, i));
269-
}
270-
271257
/**
272258
* kvm_pmu_vcpu_destroy - free perf event of PMU for cpu
273259
* @vcpu: The vcpu pointer

arch/arm64/kvm/reset.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,6 @@ void kvm_reset_vcpu(struct kvm_vcpu *vcpu)
196196
vcpu->arch.reset_state.reset = false;
197197
spin_unlock(&vcpu->arch.mp_state_lock);
198198

199-
/* Reset PMU outside of the non-preemptible section */
200-
kvm_pmu_vcpu_reset(vcpu);
201-
202199
preempt_disable();
203200
loaded = (vcpu->cpu != -1);
204201
if (loaded)

arch/arm64/kvm/sys_regs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4480,6 +4480,9 @@ void kvm_reset_sys_regs(struct kvm_vcpu *vcpu)
44804480
}
44814481

44824482
set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
4483+
4484+
if (kvm_vcpu_has_pmu(vcpu))
4485+
kvm_make_request(KVM_REQ_RELOAD_PMU, vcpu);
44834486
}
44844487

44854488
/**

include/kvm/arm_pmu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ u64 kvm_pmu_implemented_counter_mask(struct kvm_vcpu *vcpu);
5252
u64 kvm_pmu_accessible_counter_mask(struct kvm_vcpu *vcpu);
5353
u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1);
5454
void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu);
55-
void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu);
5655
void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu);
5756
void kvm_pmu_reprogram_counter_mask(struct kvm_vcpu *vcpu, u64 val);
5857
void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu);
@@ -127,7 +126,6 @@ static inline u64 kvm_pmu_accessible_counter_mask(struct kvm_vcpu *vcpu)
127126
return 0;
128127
}
129128
static inline void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu) {}
130-
static inline void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu) {}
131129
static inline void kvm_pmu_vcpu_destroy(struct kvm_vcpu *vcpu) {}
132130
static inline void kvm_pmu_reprogram_counter_mask(struct kvm_vcpu *vcpu, u64 val) {}
133131
static inline void kvm_pmu_flush_hwstate(struct kvm_vcpu *vcpu) {}

0 commit comments

Comments
 (0)