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 C995FCC6B3A for ; Thu, 15 Oct 2026 13:52:16 +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=jffrM+FBQqUwiZ21cymkCC4MhlAofj7fyNSPSMCMd8A=; b=P9y4Qvr1HKrGUVfoyY60H983ce 6cAxkW7yFRRxN2seTz3LJiJczNqBAKZs0hYUkvVRUagyyuTSqLXz5g2FJZ+yGILNtE324iWAIm/Xk 097N6KU5NpyAJiZFToaJR6a4TrLdMZ1+c5EDXptv8JTerJojO3Xh9x0p/S0/TxRv/5E+rRPcsx6Pk xb10dm+/u3Z++znszHLGSuzqex55UgwN2s/uzMAe2ERlLPrWJL50ovGQv0chmp3jYKzO/ylftexMH jMIb0QM5EfaTmAiP1PiEpbmlbGpNPImhI+t9LqsLTwtzkz+MQU2hf5pyzquTy9TT33dG2wJ0BjGKB rEB2zQPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHLsP-00000000IUv-1XXd; Thu, 15 Oct 2026 13:52:09 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHLsO-00000000IUk-1IhB for linux-arm-kernel@lists.infradead.org; Thu, 15 Oct 2026 13:52:08 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id C0649432C2; Thu, 15 Oct 2026 13:52:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33DD1F000C4; Thu, 15 Oct 2026 13:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792072327; bh=jffrM+FBQqUwiZ21cymkCC4MhlAofj7fyNSPSMCMd8A=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=mxo+pNTHLo6MUL8x9zySsXumotxTHNpP1g/C2J2kydv5SBdfm8hVSK6pAx0CDehZ/ BlmUF6hyq4rCRB4S4U1+VQeQEXdQF7n90+sI4+Bx3DD0p//ayxdaPOKsjcRhFGGp28 rO/6lAg8hkCpkecU4mwU0jOl0SfCUJD5RnIEFysjW9IweXALp5d7XqE8i9euCk0PTH 3oxLYmA2wxc2wl4dl/Oh43rQbmn+KFpnNH4w9yZ7wtlyIjY5x2gD9zk71ZbZQobBhG w9/0f5++QHH70EQcbAvtgthUGRbIEkGrFXBmEKxbBBBJ0ge1YKiE4FBcT3phDElOK3 TiZ0GnCRiSu6g== 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 1xHLsL-00000003KaI-2QOu; Thu, 15 Oct 2026 13:52:05 +0000 Date: Thu, 15 Oct 2026 14:52:05 +0100 Message-ID: <86ik33137e.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Steffen Eiden , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Fuad Tabba Subject: Re: [PATCH 2/7] KVM: arm64: Move OUTSIDE_GUEST_MODE publication past context being saved In-Reply-To: <20261015125713.2650696-1-fuad.tabba@linux.dev> References: <20261015100539.1011760-3-maz@kernel.org> <20261015125713.2650696-1-fuad.tabba@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/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: fuad.tabba@linux.dev, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, seiden@linux.ibm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, tabba@google.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 Thu, 15 Oct 2026 13:57:13 +0100, Fuad Tabba wrote: > > Hi Marc, > > On Thu, 15 Oct 2026 11:05:34 +0100, Marc Zyngier wrote: > [...] > > However, code that uses OUTSIDE_GUEST_MODE as a synchronisation point > > relies on the vcpu state to have been written back to the in-memory > > structures. Clearly, this is not what is happening > > nit: missing full stop. > > [...] > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > [...] > > @@ -1390,6 +1389,12 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) > > > > kvm_arch_vcpu_ctxsync_fp(vcpu); > > > > + /* > > + * All the state has been synchronised, let advertise > > + * we're outside of the guest. > > + */ > > + smp_store_release(&vcpu->mode, OUTSIDE_GUEST_MODE); > > nit: could this say the vgic state rather than all the state? In pKVM, > a non-protected guest's context comes back later, in > handle_exit_pkvm_state() or on demand, and with VHE the EL1 sysregs > stay on the CPU until vcpu_put(). Also "let's advertise". I don't really want to make this vgic specific, as there could be more. But I can more precisely describe what state were talking about: diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 8b46fafdd3494..7ce9f3bfa7fff 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1390,8 +1390,9 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) kvm_arch_vcpu_ctxsync_fp(vcpu); /* - * All the state has been synchronised, let advertise - * we're outside of the guest. + * The state that was pushed into the CPU on entering + * the guest has been synchronised back, let's + * advertise we're outside of the guest. */ smp_store_release(&vcpu->mode, OUTSIDE_GUEST_MODE); Thanks, M. -- Without deviation from the norm, progress is not possible.