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 8F771606A31A for ; Tue, 1 Dec 2026 17:36:33 +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=NdoB2tN+; 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=fKTvSMCR; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=UAKLiMSa 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=9gK+Ok6BT2T/Q3gKXWo3P2A37M51T8YkuXMPKmbEUNw=; b=NdoB2tN+RiZ52G2QK9RLjTdxQz tG+TqxcEOt0ADiO7alr5wKufGYSfGYbDyAnZ/bcrbkCeVzdELKDzX8e6wwRopLYFu3ujKAODNAcoe M8RoGKHOxy32F733YAhQ13b3XFYzzsa576Q1T/UlMEzLLbWUnkH4gAAnHw8RR7QwPhPcjjOWfjUOf /mPvoNrIb5esAlMlqklqydJU8/EgrySX1xQ73KekulYVcuteKZbXwUbQvnaNePk7gsig4uTSLSOCc OxFal6arJWkfcjV7dIfBtiuCUNMqEcYqA+iIvN+iBHGN/OgaJmgL/I8hFkLrEE/y++et3e7HckJ+P tEfOqpvw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYRm9-00000008wyJ-3kvm; Tue, 01 Dec 2026 17:36:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYRm7-00000008wxm-1I7k for linux-arm-kernel@bombadil.infradead.org; Tue, 01 Dec 2026 17:36:20 +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=9gK+Ok6BT2T/Q3gKXWo3P2A37M51T8YkuXMPKmbEUNw=; b=fKTvSMCRF509zrJFj/IaldQk7E 9lELVfZkiHDvuIxK3Ub/BTz0ULEnlv3/xuoJiR3jKF6I4ugdcc0SDAJBwSm+YpA6GjtpuL95iArdy BeA8mqRSg3ABuzsHghWedWyXrmE0UI3YzLNjJj+RItKQIpy54X1H23y1HSIulkcTR7EBpBfwCw5tj SgE0CauQuq4c4aVUrrXWGB8WsWX/7oO6MxpTaV33XCfn5YMamutXPSzxMR18D9nmPMfQt2G0LVVBJ RqFrOA3wF6RlT+c3YMikYi1eexkx/3IUEfztBiidNNVgIptcxatGDBYjv/recvpSqqnWXgdSYLl24 pw5TdmDg==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYRm3-0000000BKud-3exb for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 17:36:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21523339; Tue, 1 Dec 2026 09:36:10 -0800 (PST) Received: from raptor (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F1883F632; Tue, 1 Dec 2026 09:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796146572; bh=GZWdioGZHvgnXMlpfJa536Pvgodsynqiano8h1LSHbU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UAKLiMSaQqsDp+CLAIg4236COtVPMuIqYWc+WpI1XqXlwo4slVhdJWGpd9iZBpF5j mggs3VfX2G13XtWjDC/3lv3SAjgfAb2aVZ07RWmRFaOLf/wlXksNP+OyzYWUEyB4cW mRCsQVnqiey5S9zm+sK8fkUMlHiHhe8I9vsPgIDY= Date: Tue, 1 Dec 2026 17:36:05 +0000 From: Alexandru Elisei To: "Lorenzo Stoakes (ARM)" 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_173616_192390_23540A9E X-CRM114-Status: GOOD ( 28.08 ) X-Spam-Score: -2.5 (--) 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=-10.9 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 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