lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJHc60wRuqo3d=7J0jkoKehsrDWbZkwy2ADrPQpqaF-YYpH6DA@mail.gmail.com>
Date:   Wed, 27 Sep 2023 10:36:29 -0700
From:   Raghavendra Rao Ananta <rananta@...gle.com>
To:     Oliver Upton <oliver.upton@...ux.dev>
Cc:     Marc Zyngier <maz@...nel.org>,
        Alexandru Elisei <alexandru.elisei@....com>,
        James Morse <james.morse@....com>,
        Suzuki K Poulose <suzuki.poulose@....com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Zenghui Yu <yuzenghui@...wei.com>,
        Shaoqin Huang <shahuang@...hat.com>,
        Jing Zhang <jingzhangos@...gle.com>,
        Reiji Watanabe <reijiw@...gle.com>,
        Colton Lewis <coltonlewis@...gle.com>,
        linux-arm-kernel@...ts.infradead.org, kvmarm@...ts.linux.dev,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH v6 02/11] KVM: arm64: PMU: Set the default PMU for the
 guest on vCPU reset

Hi Oliver,

On Wed, Sep 27, 2023 at 1:02 AM Oliver Upton <oliver.upton@...ux.dev> wrote:
>
> Hi Raghu,
>
> On Tue, Sep 26, 2023 at 11:39:59PM +0000, Raghavendra Rao Ananta wrote:
> > From: Reiji Watanabe <reijiw@...gle.com>
> >
> > 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@linux.dev
>
> --
> Thanks,
> Oliver

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ