From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E01FD606A692 for ; Fri, 4 Dec 2026 18:28:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=p9VV9le0; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=W0L+L4Ua; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mmQCsLaI DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=6zqEjATheBaCNLwp07YOAGgEwfDX8+Ej3PfgJ7qih+Y=; b=p9VV9le0lzdHMvAqpu3jjNDw6K zqIDfzCg5ALwORQGpETFigGPpQH9ux8JE4EX8DuUf634L8Kl8K3VKXgFo2AudOf3adZ6uiPL02QhA zP7crv0t4pKk6pmDGAG2zBDoxcGpy0iIc5tdUCojMhLaRoy2iGV6Lf7FT8aUA+2Oz1GrLKQUSdEtD TZ35pQeC7tFkUKT71T77nMVsoz2XPeUlSGlWMPSQgxxTBH/kqgxTWuIXnrmXPlmVA8YbvNm97l7D7 czCtwV66wwvnbDVbv4OCEFZ70gcAU1x7aeIIibjkoAb1sU65vr4X2nvgII3DjglyC+sVE5g7IGoxZ q0e13DgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZXy9-00000001AA8-0DZ7; Fri, 04 Dec 2026 18:25:18 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZXxa-00000001A3c-1HVt for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Dec 2026 18:24:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6zqEjATheBaCNLwp07YOAGgEwfDX8+Ej3PfgJ7qih+Y=; b=W0L+L4UaRZ63mTG0T9GtZzWKtu oLuO2Hy5uPDVX7h3y5kpq1vwk+/sllLBfahzAUpqWdNsFPspCo3sGwgky5tRtP2iH38OYYEb7dXiK Ebupy/oEcBBaIM/gGaRPs4eAx1na863ohwgf29cZitKb+YyE/+POv0XZQM4vXzAHSwec+Q/F3BTWr vCW7lIpt3S3ZSVZY7Gqfr68oRA2xSMGTxNH36Z16ylAJooU9BveglMOefWPx0PRSka9XX2BrpCVRr hxBKuz8xhy6847g1H76DEDvP+z3DO3LVzllqHOdY2J8GJydCOHWXIqz+q1tY2zPZIRC/9Jrf/5ejq N/i90uBQ==; Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by desiato.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZXxU-0000000EgYT-3DL7 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 18:24:39 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 4291540C59; Fri, 4 Dec 2026 18:22:05 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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