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 A3200CC6B34 for ; Thu, 15 Oct 2026 10:06:06 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ftytAGPe4YrhA1Qp2eSKEYuT3rIyTX09UwrCpO23iSw=; b=z65XPNqLA/AG4sfYQ7mKJrd141 /W7j8PFF8k0veVXHLfAD9GXD/KEWfE2TDR4uOiahZ8H5ZOSVr/gk0upMzIQDJJJ9jjrabkJsjuGAQ Bg+Nr+ZXS4F2kMm4iDUmZnSQgn5OUr30rG+FX4qZgpccQBeHypC9lrMLx1NF/8RRN2Te5cnO3Rpj4 Z5RnmAkCuK/+LBqaRocJZGbFLPOWCOqD9WbVQJXC+CZIk16yr06bwWBlPyeokXz53yv9fdDp+Ux+c BLX2QFfQiHp5pu9/jTquKLpcwtksWnMdoEIkMAjwChpf4obcyvyds3gJdGU4/TSGfQM+E8f3VnXLO AU3irHTQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHILO-0000000HNrv-0szT; Thu, 15 Oct 2026 10:05:50 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHILK-0000000HNql-1ibr for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2026 10:05:48 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id DA23B6022B; Thu, 15 Oct 2026 10:05:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91F541F000CC; Thu, 15 Oct 2026 10:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792058745; bh=ftytAGPe4YrhA1Qp2eSKEYuT3rIyTX09UwrCpO23iSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gJ0MaTAQt3wPeQOOmR8P8AB084F0RwNTZIjm6awP5V9+qu61z6BCFN3xX/MyUYE2C YqqXULC4zArQRMKhVggM1pnyJHoYVcudr3T1X5NEFqg4jVMr4WUBToE1UsKKocEws5 Ck2B0/hxj6w8yszoLhEI9zlP1JPca6K/bAfloUF7BsuLJkpZnVr6AtCUWSHaPNyNRP UA5k+/+dAh+4RvaHwMjbNe6BFkPH5/5HmtPWThpCGAAkDoCQ64E4j4uuGE2vcB04Ea G2abFJW+warvzmahA+foKK+dYRaB/i5bJRLOOOlDn5jU0xGayXXvjE6jCtwL5GkocO e/R1snzAJnASw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) 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 1xHILH-00000003EfK-3mSN; Thu, 15 Oct 2026 10:05:43 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: Steffen Eiden , Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Fuad Tabba , stable@vger.kernel.org Subject: [PATCH 6/7] KVM: arm64: vgic: Stop the target vcpu when disabling LPIs Date: Thu, 15 Oct 2026 11:05:38 +0100 Message-ID: <20261015100539.1011760-7-maz@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261015100539.1011760-1-maz@kernel.org> References: <20261015100539.1011760-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, fuad.tabba@linux.dev, stable@vger.kernel.org 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 Disabling LPIs is pretty nasty, as it directly messes with the AP list of the affected CPU, which could be running... This has the potential to lead to really bad behaviours, and we should not be doing that. Take example on the way the Active state is handled and simply pause the the vcpu so that we are sure it is in a quiescent state, and the state be safely manipulated. Nobody has any expectation of performance for this anyway. Fixes: 96085b949672d ("KVM: arm/arm64: vgic-v3: Retire pending interrupts on disabling LPIs") Co-developed-by: Oliver Upton Signed-off-by: Oliver Upton Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org --- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 5913a20d83019..f5bd29fbe3a90 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -303,9 +303,19 @@ static void vgic_mmio_write_v3r_ctlr(struct kvm_vcpu *vcpu, if (ctlr != GICR_CTLR_ENABLE_LPIS) return; + /* + * Yes, disabling LPIs is painful, since it can be done from + * a *remote* vcpu! So let's not take any chance, and make + * sure that the target vCPU has written their LRs back to the + * irq structures, and release any reference they would have. + * + * If it hurts, don't do it. + */ + kvm_pause_vcpu(vcpu); vgic_flush_pending_lpis(vcpu); vgic_its_invalidate_all_caches(vcpu->kvm); atomic_set_release(&vgic_cpu->ctlr, 0); + kvm_resume_vcpu(vcpu); } else { ctlr = atomic_cmpxchg_acquire(&vgic_cpu->ctlr, 0, GICR_CTLR_ENABLE_LPIS); -- 2.47.3