Hi Oliver, On Wed, Sep 27, 2023 at 1:02 AM Oliver Upton <oliver.upton@xxxxxxxxx> wrote: > > Hi Raghu, > > On Tue, Sep 26, 2023 at 11:39:59PM +0000, Raghavendra Rao Ananta wrote: > > From: Reiji Watanabe <reijiw@xxxxxxxxxx> > > > > The following patches will use the number of counters information > > from the arm_pmu and use this to set the PMCR.N for the guest > > during vCPU reset. However, since the guest is not associated > > with any arm_pmu until userspace configures the vPMU device > > attributes, and a reset can happen before this event, call > > kvm_arm_support_pmu_v3() just before doing the reset. > > > > No functional change intended. > > I would argue there still is a functional change here, as PMU > initialization failure now shows up on a completely different ioctl for > userspace. > > > @@ -216,6 +217,18 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > vcpu->arch.reset_state.reset = false; > > spin_unlock(&vcpu->arch.mp_state_lock); > > > > + if (kvm_vcpu_has_pmu(vcpu)) { > > + if (!kvm_arm_support_pmu_v3()) > > + return -EINVAL; > > + > > + /* > > + * When the vCPU has a PMU, but no PMU is set for the guest > > + * yet, set the default one. > > + */ > > + if (unlikely(!kvm->arch.arm_pmu) && kvm_arm_set_default_pmu(kvm)) > > + return -EINVAL; > > + } > > + > > Ah, this probably will not mix well with my recent change to get rid of > the return value altogether from kvm_reset_vcpu() [*]. I see two ways to > handle this: > > - Add a separate helper responsible for one-time setup of the vCPU > called from KVM_ARM_VCPU_INIT which may fail. > > - Add a check for !kvm->arch.arm_pmu to kvm_arm_pmu_v3_init(). > > No strong preference, though. > Thanks for the pointer. I think adding it in kvm_arm_pmu_v3_init() may not be feasible as the reset (reset_pmcr()) may happen before this init and we may end up setting 0 as PMCR.N for the guest. I'll explore the other option though. Thank you. Raghavendra > [*]: https://lore.kernel.org/r/20230920195036.1169791-8-oliver.upton@xxxxxxxxx > > -- > Thanks, > Oliver