From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE2D11643F for ; Tue, 11 Jul 2023 07:23:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47F12C433C9; Tue, 11 Jul 2023 07:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689060208; bh=vkZgS++QwVDhnRXO1d9T2q8nnAlRlxQqK1dITmIMh00=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VfxJqo+pEgBOrb7/CxFe6DcYtBzt3+lwvsCWy+8ilfTklN3SZfa6TzuJ1rjqL8Orj QClCeheCMq8JCmkSmFbUSJ5HMPkQEx05vU1hiZ5KSVon0k7sIhzOdNGUSuR+9qBZjI Dn2UM7YGkJ2zcQy8z+gKzl9sH7mu6n4To8yWp0b5VcjDiSVUssPSukgWc0um5Cr6zr 0L09pNWx1ciMh3Zy0l94f4bwmNpVCNrr+SqEl9N7vtj+lIMfeLhv2SuxVNY4+I0IOZ QgVFiYn7qFnqHCw4ejmZMjm+C5K1wXLa1FNGX8BfmW0VObjZx2kYOnEjt6jgEzmwxB hoNd8r6XJzwbQ== 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.95) (envelope-from ) id 1qJ7iY-00C2RY-0x; Tue, 11 Jul 2023 08:23:26 +0100 Date: Tue, 11 Jul 2023 08:23:25 +0100 Message-ID: <86jzv6x66q.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, James Morse , Suzuki K Poulose , Zenghui Yu , stable@vger.kernel.org, Xiang Chen Subject: Re: [PATCH] KVM: arm64: vgic-v4: Consistently request doorbell irq for blocking vCPU In-Reply-To: <20230710175553.1477762-1-oliver.upton@linux.dev> References: <20230710175553.1477762-1-oliver.upton@linux.dev> 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/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: oliver.upton@linux.dev, kvmarm@lists.linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, stable@vger.kernel.org, chenxiang66@hisilicon.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 10 Jul 2023 18:55:53 +0100, Oliver Upton wrote: > > Xiang reports that VMs occasionally fail to boot on GICv4.1 systems when > running a preemptible kernel, as it is possible that a vCPU is blocked > without requesting a doorbell interrupt. > > The issue is that any preemption that occurs between vgic_v4_put() and > schedule() on the block path will mark the vPE as nonresident and *not* > request a doorbell irq. It'd be worth spelling out. You need to go via *three* schedule() calls: one to be preempted (with DB set), one to be made resident again, and then the final one in kvm_vcpu_halt(), clearing the DB on vcpu_put() due to the bug. > > Fix it by consistently requesting a doorbell irq in the vcpu put path if > the vCPU is blocking. While this technically means we could drop the > early doorbell irq request in kvm_vcpu_wfi(), deliberately leave it > intact such that vCPU halt polling can properly detect the wakeup > condition before actually scheduling out a vCPU. > > Cc: stable@vger.kernel.org > Fixes: 8e01d9a396e6 ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put") > Reported-by: Xiang Chen > Tested-by: Xiang Chen > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/vgic/vgic-v3.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c > index c3b8e132d599..8c467e9f4f11 100644 > --- a/arch/arm64/kvm/vgic/vgic-v3.c > +++ b/arch/arm64/kvm/vgic/vgic-v3.c > @@ -749,7 +749,7 @@ void vgic_v3_put(struct kvm_vcpu *vcpu) > { > struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3; > > - WARN_ON(vgic_v4_put(vcpu, false)); > + WARN_ON(vgic_v4_put(vcpu, kvm_vcpu_is_blocking(vcpu))); > > vgic_v3_vmcr_sync(vcpu); > Other than the above nitpicking, this looks good. Thanks both for the very detailed report and the fix. Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.