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 7FE54606A698 for ; Fri, 4 Dec 2026 18:34:43 +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=GvbfSmE5; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bp1a1/Nf 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=xT/h5Yq0zii0HdRG5cpM3Njd9fgaRdLBIdEzafr54UA=; b=GvbfSmE5Mkl3FMTFaq+PvRE2Rg cIkzeRr9GH5AQFzudETjPz/gfT9xAy601lwO7p0Es6LoDZ75cmjeh1N9oPPrJriZtWpI8HWliryLg ibJAEB02w6Ex3O0Wxz+BB/LpshZOXu1S5ny+LN1/37H24C7miFzJZsd01PRvVLjrzaa9T+SkdZPR9 7CHFR5Q22TbQqnGYMmUF+JrnBgY/pCbWbWHC0XND5fH+zSsKVFSSy6pjB+MoPlaKrVfoInjETz6Bo Dsd5dYR29AUyzLlSjt24bMw2AEmqevCm2UqhgRTxgtp+Cb9QM1NxuNLYHdJGicgNU0R/477tjNuue hLbcPdYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZY6s-00000001AiF-1kJQ; Fri, 04 Dec 2026 18:34:18 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZY5m-00000001ASn-1tE1 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 18:33:37 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 7B15945DDB; Fri, 4 Dec 2026 18:33:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02D341F00A07; Fri, 4 Dec 2026 18:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796409189; bh=xT/h5Yq0zii0HdRG5cpM3Njd9fgaRdLBIdEzafr54UA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=bp1a1/NfcT/w9QNMsqBEFDejSGQrxFfDxSc1KJfmhxff+yp1TDlPADXOcbqIgcOIJ zPqjZxtTYLk4zGHCk9YrusQTl7ZTn97CLhvfzt4EiPln/olJf+Aopko070xtuG8c6i Ysl8PNTMfh23kzs0caCXT3QrgWAGwCtnjg4+RWtmfqAJgOsSkrbtOMSZNBO0AFbI82 QlL2j4MU4xLN1JplnUz71/izdVO3fzyyikPcs7m0H7bPVeaypoMC6C93sldjWUUBee gyK9723v8v+bFGrW9zlIUboHzSbQm0Gy1Cx9O41Noj62QT5lZI9VlWMnZbm+iIk1Ir FXYMz9VYD9s/A== Date: Fri, 4 Dec 2026 18:33:02 +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, Sudeep Holla Subject: Re: [RFC PATCH v7 12/28] KVM: arm64: Add SPE VCPU device attribute to set the interrupt number Message-ID: References: <20260903160623.315525-1-alexandru.elisei@arm.com> <20260903160623.315525-13-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 On Fri, Nov 27, 2026 at 03:06:45PM +0000, Alexandru Elisei wrote: (Thanks for all the above, trimming mail to make it easy to parse :) > > > diff --git a/arch/arm64/kvm/spe.c b/arch/arm64/kvm/spe.c > > > index fe45ad4c703a..dd5f80318ba4 100644 > > > --- a/arch/arm64/kvm/spe.c > > > +++ b/arch/arm64/kvm/spe.c > > > @@ -59,17 +59,99 @@ bool kvm_supports_spe(void) > > > return !list_empty(&spe_pmus); > > > } > > > > > > +static bool kvm_spe_irq_is_valid(struct kvm *kvm, int irq) > > > +{ > > > + struct kvm_vcpu *vcpu; > > > + struct kvm_vcpu_spe *vcpu_spe; > > > + unsigned long i; > > > + > > > > Maybe worth a small comment: > > > > /* Every vCPU must have either the same or no IRQ set. */ > > I think that's misleading, because someone reading that might get the idea > that it is allowed for a VCPU not to have an interrupt number set. I think > the documentation is enough. Fair point! :) > > > int kvm_spe_set_attr(struct kvm_vcpu *vcpu, struct kvm_device_attr *attr) > > > { > > > + struct kvm_vcpu_spe *vcpu_spe = &vcpu->arch.vcpu_spe; > > > + struct kvm *kvm = vcpu->kvm; > > > + > > > + lockdep_assert_held(&kvm->arch.config_lock); > > > + > > > + if (!vcpu_has_spe(vcpu)) > > > + return -ENODEV; > > > + > > > + switch (attr->attr) { > > > + case KVM_ARM_VCPU_SPE_IRQ: { > > > + int __user *uaddr = (int __user *)(long)attr->addr; > > > + int irq; > > > + > > > + if (!irqchip_in_kernel(kvm)) > > > + return -EINVAL; > > > + > > > + if (get_user(irq, uaddr)) > > > + return -EFAULT; > > > + > > > + if (!irq_is_ppi(kvm, irq)) > > > + return -EINVAL; > > > + > > > + if (!kvm_spe_irq_is_valid(kvm, irq)) > > > + return -EINVAL; > > > > What about changing the IRQ for vcpu? kvm_spe_irq_is_valid() will abort > > even if only the current vCPU has an IRQ set. > > kvm_spe_irq_is_valid() aborts if userspace attempts to set a different > interrupt number than the number that has already been set on a VCPU, > including the one on which the ioctl is executing. In particular, if no > VCPU has an SPE interrupt number set, kvm_spe_irq_is_valid() returns true > (success). Right. > > The requirement is that all VCPUs have the same interrupt number configured > because (I would assume that) KVM doesn't want to have to deal with > heterogenous systems. Yeah, makes sense. > > As for why it cannot be changed to a different value once set: I am not > aware of any reason for userspace to do that - I assume that if there was > one, it would also apply to the PMU, and the PMU has a similar behaviour of > rejecting reassignment. Yeah, it doesn't seem sensible to want to change that! > > > > > Also what about the case of setting the current vCPU's IRQ to the same > > value? Should that be -EBUSY? > > > > PMU seems to do something like that, so maybe worth doing that for > > consistency? Not exactly a huge thing, that though! > > Good point. To be on the safe side, I'll just replicate it. I'll also move > irq_is_ppi() into kvm_spe_irq_is_valid(), because being a PPI is a > requirement for a valid interrupt number. Thanks! > > > > > Also looking at PMU there's: > > > > /* On GICv5, the PMUIRQ is architecturally mandated to be PPI 23 */ > > if (vgic_is_v5(kvm) && irq != KVM_ARMV8_PMU_GICV5_IRQ) > > return false; > > > > Is that something you have to worry about for SPE? > > Thanks for pointing it out, didn't know that GICv5 mandates interrupt > number assignments. It's 21 for PMBIRQ, will update accordingly. Thanks! Though I think there's a gotcha here as the GICv5 value seems to encode the IRQ number rather than just having the raw number, e.g. for the PMU value above: /* PPI #23 - architecturally specified for GICv5 */ #define KVM_ARMV8_PMU_GICV5_IRQ 0x20000017 Which is GICV5_HWIRQ_TYPE_PPI in GICV5_HWIRQ_TYPE (bits 31:29) + GICV5_ARCH_PPI_PMUIRQ. So SPE will need the equivalent for GICV5_ARCH_PPI_PMBIRQ (0x15). -- Cheers, Lorenzo