From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A032CCF9E3 for ; Mon, 10 Nov 2025 09:18:59 +0000 (UTC) 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:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fiXuWWmWjojk9SKcuAQx+dNy0VW9X8RvBWE21Zmn7VM=; b=Cbp8xaBrzyjajh5tuivuoH2/mu q1Ascq2I+jSyFtw3iQnXfKYFfAflTDOQBghxtES9qd+DxsNEJB+HACjskl62O2gIaNzDqY+fYaXNW FIM0ZlREMIC/MFAoGP4fep4Af7okTwe/JyDSGPDKJSxN0FDTV8aFqIw2RMJ9i3TxB01r3EBNCgo2S 0EmjWB3IEQOosR7AJMrU/PLzd2mS/gCmSm72LAoaBKmL1sAYKWG9cBktdEgsIzd3yTxhMG3Q5Fdwj qKGHGgxXyTUPN3rW/59Si1lUvEC4Frx4Cr4lUEnisyVsfChGHOwVrRuX7fmihRbE0tnAot8OHEg3Y IppvdTJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vIO30-000000054ci-3H2e; Mon, 10 Nov 2025 09:18:50 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vIO2z-000000054cc-2XDB for linux-arm-kernel@lists.infradead.org; Mon, 10 Nov 2025 09:18:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 71E7E601A9; Mon, 10 Nov 2025 09:18:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13815C16AAE; Mon, 10 Nov 2025 09:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762766328; bh=uquc9KPzJLqmrUGTtW/WL79DTxEiUuvrMXU31YBoEgg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=prmW4Q/xtwy2U5A6XdV9MSU5SGHVbHRrvnGWIZ4Wvk+xk9VUnAj/WgdjB2BXMeoKQ g7py08T3FWOAYMO6srNNHyJG88jTnnn6QDfAPEKquhu6jQxZgNWGJ6FvU46LlybaZh W1rMqEFKcQ2y35yYheggf10/1U4tQKMyvYK+SdsgwgOD2Xdm6FNhrAi8VEYvvZ1/AI X6vA5eKJplGbNSM7OmNOma6PbGxfybGNHRMlN2di/pJ/B8KsqwqleSRUSYBWeicgth 1OZ2gVSR9cZF8qLpRAbeoTbpjsoA7MInJlN1F5Bq0QvrgxSJH5wXPP/NBj5V6qUsLG c8HK2bD4r4rIQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vIO2v-00000003nJj-2qRt; Mon, 10 Nov 2025 09:18:45 +0000 Date: Mon, 10 Nov 2025 09:18:45 +0000 Message-ID: <868qgeutxm.wl-maz@kernel.org> From: Marc Zyngier To: Yao Yuan Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Christoffer Dall , Volodymyr Babchuk Subject: Re: [PATCH v2 12/45] KVM: arm64: GICv3: Extract LR folding primitive In-Reply-To: <3tb7ekdzl5f4rs24bla63vw22awejhbn7ngvttid7v7bzaer2m@62bxshf7uj34> References: <20251109171619.1507205-1-maz@kernel.org> <20251109171619.1507205-13-maz@kernel.org> <3tb7ekdzl5f4rs24bla63vw22awejhbn7ngvttid7v7bzaer2m@62bxshf7uj34> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yaoyuan@linux.alibaba.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, christoffer.dall@arm.com, Volodymyr_Babchuk@epam.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 10 Nov 2025 09:01:21 +0000, Yao Yuan wrote: > > On Sun, Nov 09, 2025 at 05:15:46PM +0800, Marc Zyngier wrote: > > As we are going to need to handle deactivation for interrupts that > > are not in the LRs, split vgic_v3_fold_lr_state() into a helper > > that deals with a single interrupt, and the function that loops > > over the used LRs. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kvm/vgic/vgic-v3.c | 88 +++++++++++++++++------------------ > > 1 file changed, 43 insertions(+), 45 deletions(-) > > > > diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c > > index 3ede79e381513..0fccfe9e3e8dd 100644 > > --- a/arch/arm64/kvm/vgic/vgic-v3.c > > +++ b/arch/arm64/kvm/vgic/vgic-v3.c > > @@ -33,78 +33,76 @@ static bool lr_signals_eoi_mi(u64 lr_val) > > !(lr_val & ICH_LR_HW); > > } > > > > -void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) > > +static void vgic_v3_fold_lr(struct kvm_vcpu *vcpu, u64 val) > > { > > - struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; > > - struct vgic_v3_cpu_if *cpuif = &vgic_cpu->vgic_v3; > > - u32 model = vcpu->kvm->arch.vgic.vgic_model; > > - int lr; > > - > > - DEBUG_SPINLOCK_BUG_ON(!irqs_disabled()); > > - > > - cpuif->vgic_hcr &= ~ICH_HCR_EL2_UIE; > > - > > - for (lr = 0; lr < cpuif->used_lrs; lr++) { > > - u64 val = cpuif->vgic_lr[lr]; > > - u32 intid, cpuid; > > - struct vgic_irq *irq; > > - bool is_v2_sgi = false; > > - bool deactivated; > > - > > - cpuid = val & GICH_LR_PHYSID_CPUID; > > - cpuid >>= GICH_LR_PHYSID_CPUID_SHIFT; > > - > > - if (model == KVM_DEV_TYPE_ARM_VGIC_V3) { > > - intid = val & ICH_LR_VIRTUAL_ID_MASK; > > - } else { > > - intid = val & GICH_LR_VIRTUALID; > > - is_v2_sgi = vgic_irq_is_sgi(intid); > > - } > > + struct vgic_irq *irq; > > + bool is_v2_sgi = false; > > + bool deactivated; > > + u32 intid; > > > > - /* Notify fds when the guest EOI'ed a level-triggered IRQ */ > > - if (lr_signals_eoi_mi(val) && vgic_valid_spi(vcpu->kvm, intid)) > > - kvm_notify_acked_irq(vcpu->kvm, 0, > > - intid - VGIC_NR_PRIVATE_IRQS); > > + if (vcpu->kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) { > > + intid = val & ICH_LR_VIRTUAL_ID_MASK; > > + } else { > > + intid = val & GICH_LR_VIRTUALID; > > + is_v2_sgi = vgic_irq_is_sgi(intid); > > + } > > > > - irq = vgic_get_vcpu_irq(vcpu, intid); > > - if (!irq) /* An LPI could have been unmapped. */ > > - continue; > > + irq = vgic_get_vcpu_irq(vcpu, intid); > > + if (!irq) /* An LPI could have been unmapped. */ > > + return; > > > > - raw_spin_lock(&irq->irq_lock); > > + /* Notify fds when the guest EOI'ed a level-triggered IRQ */ > > + if (lr_signals_eoi_mi(val) && vgic_valid_spi(vcpu->kvm, intid)) > > + kvm_notify_acked_irq(vcpu->kvm, 0, > > + intid - VGIC_NR_PRIVATE_IRQS); > > The fds notifiy happens before checking irq's mapping before > this patch, and now in reversal order w/ above change. It's > fine for vLPI, and for vSPI no necessary call > kvm_notify_acked_irq() if the it has been remapped, no > gsi<->pin mapping there. Is above understanding correct ? We can only notify an irqfd for an SPI, never for an LPI. Given that only looking up an LPI can result in a NULL pointer (if it has been concurrently removed), this change is immaterial This results in something that is easier to understand, as I find it more logical to weed out the error cases first before taking any significant action. Thanks, M. -- Without deviation from the norm, progress is not possible.