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 CB73C14E2FB for ; Tue, 2 Jul 2024 08:42:43 +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=1719909763; cv=none; b=QXfzdlK7kS7Iob1X7LaPD8jaODyA0GNDsJrwOjksVK/aJKBDcizXVGTaSGqJhfwAL1oBveEDM9sD0i9P3qBNVXA/GOvu1XO8ZmLWigeGmzDsf8XDy8pf+P5VkQcYHQPJXiVPPL6J6rUseRGDe5lkT+Y7uR/xRH5j7BTA3ePwYYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719909763; c=relaxed/simple; bh=WAKIFiSeV41Ht5XwnPCQZdNase3NIfnh2+5eVub4HoU=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=dVfiOxHPW9I6t6uvZZPIs15185DYV2L4RcNRFTbHYV36S+x94CoRfE5inUVPQxcvNS63fSH36vCdzZdMgi/NOt86/Q8ZGw8BgAHylPkOEoqhJHgW9awgG2UaIAFDhkrU/iI0GmwVZXPQbd6Y1pa8CFSnkZm+rjpbVqab64TUrUo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d6urIkI3; 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="d6urIkI3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6198BC116B1; Tue, 2 Jul 2024 08:42:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719909763; bh=WAKIFiSeV41Ht5XwnPCQZdNase3NIfnh2+5eVub4HoU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d6urIkI3U91Q55RHbgcYR1mF7L7SI074qI283nM41yBAYC7eCqf4r7q9aDVCnPd1a ILiNBb41nW1FoCLDDsClFegENQlBeE5iNY0E3AGiV3MWd14+rc4Fgclsm8mGPJfYFH et8iAmI7gGxu1FXsn6oVFZ/t0aQjoIy/kJJ5TXv4TZJBY37bbeP4oKv70VoUkX16fS cszzwYC7DAIItLZ+T6c0XByKUEfT0nhn7ZKe0xAEr7oIJP24nEZK2Df7ZCKiMYLaE5 /8erlbX6Q7Dis42LkgMeBN8gkk8ZPjtCuGwXuAUyFcnW744aJi5z26NXmFW9WB5zQF /Lbul1OUi+EJg== 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 1sOZ60-0092WK-Sd; Tue, 02 Jul 2024 09:42:41 +0100 Date: Tue, 02 Jul 2024 09:42:40 +0100 Message-ID: <864j98i3r3.wl-maz@kernel.org> From: Marc Zyngier To: James Gowans Cc: , , , , , Subject: Re: [PATCH 5.15.y] KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption In-Reply-To: <20240701111933.41973-1-jgowans@amazon.com> References: <2023072323-trident-unturned-7999@gregkh> <20240701111933.41973-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 12:19:33 +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.