From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796408525; b=aU+98/8rW7KVqgAMSVnBWCijpdEtVF72NyO5e3oA3+5+kPaqUsaYmBourKnDncbVamwl MiJ0MpXXVVTwzKfIKu+VMLy4wlGmHZD8X/IxWOjanWqZsQa9dgd6E2Bm0r75CEjTvS7Fc sW7+RwqIfX652ExL4AfDukQ27tNIfxLH9lneFB4F/fzdWwWat0c6C3iPwEyXVC5G9GVZo DVQjOGWz1NiE8D5ceY9rgGiDXK6CN4d8XX0PsJ2aCj9LFI/7QQF6ywrmu5KvsP/MrvUNo mIJNZXgjaRJJEWQz9Zqa7AKwKvBJ52nXjmzsRPddkBusBZdqqNiUkzuLHVHKrkknQjw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796408525; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=6zqEjATheBaCNLwp07YOAGgEwfDX8+Ej3PfgJ7qih+Y=; b=qUjfPccmI+NBEX0wSCDlcb9l6nCjL3iePEpnBUtzy8RWE2N8qMfn3/qTcIvV0pdgyZh6 RXj0Zsttgah9woPSMz1YLWAil1L6Fw/hwJZfo65z8NZyhc0/EgjqJQ97u+WrOJsfwPYy4 e4hm1IyAEfhGCqjv/iIwuloTXxMf/TFy4ZbbmqvwWh9GcJ7rZ5kdl77VR82ktvdkQoZUG FS6lS0h39sP+cQa4xg0kWGPhFUefZtzVzIQYX3HShRCps/4P6m/C6FMX063dBeCW/j0Md 3k4Mxjy7Uq91yuH9bq+hfTmPQq0fmyHpUdwV4Mx35TYbAalazYAd2CYX8mrmoHfM9Zg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mmQCsLaI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F3FC606A6A3; Fri, 4 Dec 2026 18:22:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mmQCsLaI Received: by smtp.kernel.org (Postfix) with ESMTPSA id D79401F01815; Fri, 4 Dec 2026 18:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796408524; bh=6zqEjATheBaCNLwp07YOAGgEwfDX8+Ej3PfgJ7qih+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=mmQCsLaINFCGBaY5vtJwfZSun526aCPGQ/7oPdM4xG7ju4BvABgoNPVIQdEZ5Bp0s vKY889MsnfzkUiKD71hJhZ17PpAMwRcD4PFed0w93kZMKmhpjc2lfMuT4OqqfeVTO5 pk/3E6iBF995elDmFJQHYDqClNNM81oGQygP25H2iTIelMCoGg/1AFprKvjj0lbNZZ pzeerv6RoKfv6KgukRM1OXbAhLAPh0C/y75CdZUVL+zBZOBN8KdxM44pkERab72rqK /8ko1K8S839Fhzgcvd40J23X33ljWzOERfhCVh4agTEUS7B5xIT75udDtQWhizTmjJ XzE1BUpFn33zw== Date: Fri, 4 Dec 2026 18:21:58 +0000 From: "Lorenzo Stoakes (ARM)" To: Alexandru Elisei Cc: maz@kernel.org, oupton@kernel.org, fuad.tabba@linux.dev, joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, will@kernel.org, mark.rutland@arm.com, linux-perf-users@vger.kernel.org, catalin.marinas@arm.com, james.clark@linaro.org Subject: Re: [RFC PATCH v7 13/28] KVM: arm64: Add SPE VCPU device attribute to set the SPE device Message-ID: References: <20260903160623.315525-1-alexandru.elisei@arm.com> <20260903160623.315525-14-alexandru.elisei@arm.com> X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Ack and thanks on the below, I trimmed those bits out when replying to the parent mail as obviously addressed here :) On Tue, Dec 01, 2026 at 05:36:05PM +0000, Alexandru Elisei wrote: > Hi, > > While I was refactoring the patch, I reconsidered some things, below. > > On Fri, Nov 27, 2026 at 03:10:28PM +0000, Alexandru Elisei wrote: > > Hi Lorenzo, > > > > On Wed, Oct 28, 2026 at 01:11:54PM +0000, Lorenzo Stoakes (ARM) wrote: > > > On Thu, Sep 03, 2026 at 05:06:08PM +0100, Alexandru Elisei wrote: > > > > [..] > > > > diff --git a/arch/arm64/include/asm/kvm_spe.h b/arch/arm64/include/asm/kvm_spe.h > > > > index 8ded2d821bff..b8afb419c851 100644 > > > > --- a/arch/arm64/include/asm/kvm_spe.h > > > > +++ b/arch/arm64/include/asm/kvm_spe.h > > > > @@ -11,6 +11,11 @@ struct kvm_vcpu; > > > > struct kvm_device_attr; > > > > > > > > #ifdef CONFIG_KVM_ARM_SPE > > > > +struct arm_spe_pmu; > > > > +struct kvm_spe { > > > > + struct arm_spe_pmu *spe_pmu; > > > > > > I feel like 'spe_pmu' as a name is pretty confusing as there is PMU as > > > regards the perf driver thing, which SPE is implemented as, and also the > > > general PMUv3 architecture :) > > > > > > Maybe the _pmu suffix makes sense then on the type (which has to be a > > > performance monitoring unit driver), but could we replace '_pmu' with > > > '_instance' in the field, etc. names? > > > > The driver that KVM depends on calls it a spe_pmu, and this comes directly from > > the driver. I think the name is appropriate. > > I have settled on calling it spe_dev and started replacing all references to SPE > 'instance' with 'device': that's what it is from the kernel's point of view, and > the device lives under /sys/devices, where userspace interacts with it. > > > > > [..] > > > > diff --git a/arch/arm64/kvm/spe.c b/arch/arm64/kvm/spe.c > > > > index dd5f80318ba4..87fcdbbcbd67 100644 > > > > --- a/arch/arm64/kvm/spe.c > > > > +++ b/arch/arm64/kvm/spe.c > > > > +static int kvm_spe_set_spe_id(struct kvm_vcpu *vcpu, int spe_id) > > > > +{ > > > > + struct kvm *kvm = vcpu->kvm; > > > > + struct kvm_spe *kvm_spe = &kvm->arch.kvm_spe; > > > > + struct arm_spe_pmu *existing_spe_pmu, *spe_pmu = NULL; > > > > + struct spe_pmu_entry *entry; > > > > + > > > > + if (kvm_vm_has_ran_once(kvm)) > > > > + return -EBUSY; > > > > + > > > > + guard(mutex)(&spe_pmus_lock); > > > > + > > > > + list_for_each_entry(entry, &spe_pmus, link) { > > > > + if (entry->spe_pmu->pmu.type == spe_id) { > > > > + spe_pmu = entry->spe_pmu; > > > > + break; > > > > + } > > > > + } > > > > + > > > > + if (!spe_pmu) > > > > + return -ENXIO; > > > > + > > > > + existing_spe_pmu = kvm_spe->spe_pmu; > > > > + if (existing_spe_pmu) { > > > > + if (existing_spe_pmu != spe_pmu) > > > > + return -EINVAL; > > > > + return 0; > > > > + } > > > > + > > > > + if (!try_module_get(spe_pmu->pmu.module)) > > > > + return -ENXIO; > > > > + > > > > + if (kvm_spe_update_supported_cpus(kvm, &spe_pmu->supported_cpus)) { > > > > > > You're ignoring the error here, better to do: > > > > I'm not ignoring the error, I am deliberately choosing to return -EINVAL to > > userspace, as per the documentation, instead of propagating the error code from > > the internal function. > > I reconsidered this, and documented -ENOMEM as a possible return return code for > the ioctl. > > Thanks, > Alex -- Cheers, Lorenzo