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]
Date:   Wed, 27 Sep 2023 08:02:40 +0000
From:   Oliver Upton <oliver.upton@...ux.dev>
To:     Raghavendra Rao Ananta <rananta@...gle.com>
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 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.

[*]: 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