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 54B7D14EC7F for ; Tue, 2 Jul 2024 08:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719909743; cv=none; b=fDByoqaWwKcemktZ6mMGGuBkLyRq2ZyWJXeDkd/Om1c+C20lgrRJ1/IeaTgls+moVoIBuEkFT4YQrjdkTGqDDkslbGg/xHoGHmdbmmmp7Q2sAGgrVanLZ+ceJ5MCokWhcFyGkLoHDL0YzaarcgJW98AKTcEFFa6/w16utZTfzeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719909743; c=relaxed/simple; bh=pYS5RRyQchQqaVKn6EM2vhE4EHTAVpIWZh+Y7hPYh2Y=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=ggu7MxQ8ugc+7VQZvAifJNG7EMR7bU+I3ffTB9UMR8bDtlIS/ro9uP1EOo4sUKymEeByToqoYqyZbZyLs0nd6sd6l3tLzmhIKHdN85aiQxZFsuiqoNwsR3JbOBikVjv8i+MTAVEvFAYUYt/lLN5QCmRfy859UPb52oXuqVADpJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VIWrXpgZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VIWrXpgZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C9748C116B1; Tue, 2 Jul 2024 08:42:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719909742; bh=pYS5RRyQchQqaVKn6EM2vhE4EHTAVpIWZh+Y7hPYh2Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=VIWrXpgZh7LB/3JPCkHmG3Xk1ukNeHu09TIqxDLVu2zJFZor+lCXxykwTE57uCfg7 OjYLFRzRzZ55R/NkRQAnpXIqBDjogTvCEkt6URaLMbwWfJSrDimtVeg3cTdtNYDUXw ZspCnxvr/oBoaxauohU0SMFm9ddY70tKDw8AC1esB8WVzsQuZDFR5vo6LGQHvRlcVJ /1+ekyWvzdgFolJWrFw6drnCrAGaoO10Fvn/l8y1O6SxqAMSKOHb+S+hRtOWtGTBB2 lZBj4exRDm6Cmp/gjn6c5l3TKIPF3cpgs6oGNORzn59DYEki8Zz6Xc/75iOjqNWmlo sIfEJKgGbOjsA== 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 1sOZ5g-0092Vb-Co; Tue, 02 Jul 2024 09:42:20 +0100 Date: Tue, 02 Jul 2024 09:42:18 +0100 Message-ID: <865xtoi3rp.wl-maz@kernel.org> From: Marc Zyngier To: James Gowans Cc: , , , , , Subject: Re: [PATCH 5.10.y] KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption In-Reply-To: <20240701105707.28631-1-jgowans@amazon.com> References: <2023072324-aviation-delirious-b27d@gregkh> <20240701105707.28631-1-jgowans@amazon.com> 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/29.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: jgowans@amazon.com, stable@vger.kernel.org, gregkh@linuxfoundation.org, chenxiang66@hisilicon.com, oliver.upton@linux.dev, yuzenghui@huawei.com, sironi@amazon.de X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 01 Jul 2024 11:57:07 +0100, James Gowans wrote: > > From: Marc Zyngier > > 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. This occurs because when the vcpu thread is > resumed on its way to block, vcpu_load() will make the vPE resident > again. Once the vcpu actually blocks, we don't request a doorbell > anymore, and the vcpu won't be woken up on interrupt delivery. > > Fix it by tracking that we're entering WFI, and key the doorbell > request on that flag. This allows us not to make the vPE resident > when going through a preempt/schedule cycle, meaning we don't lose > any state. > > 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 > Suggested-by: Zenghui Yu > Tested-by: Xiang Chen > Co-developed-by: Oliver Upton > Signed-off-by: Marc Zyngier > Acked-by: Zenghui Yu > Link: https://lore.kernel.org/r/20230713070657.3873244-1-maz@kernel.org > Signed-off-by: Oliver Upton > > (cherry picked from commit b321c31c9b7b309dcde5e8854b741c8e6a9a05f0) > > [modified to wrangle the vCPU flags directly instead of going through > the flag helper macros as they have not yet been introduced. Also doing > the flag wranging in the kvm_arch_vcpu_{un}blocking() hooks as the > introduction of kvm_vcpu_wfi has not yet happened. See: > 6109c5a6ab7f ("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook")] > > Signed-off-by: James Gowans Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.