From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1C3E9446BE0; Thu, 15 Oct 2026 13:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792072329; cv=none; b=FHJZFDXaak0rRNW4XpxXPIJxI01Cqi/1/5EF5psAn0ePL5nDqw7tf3Wq2PrCfeBwF8TXvMxJN2f02FLOrzitvyMUg8kh5o2l/uMguWJDIA818slCEVGwsEtW/klzZp2uWZrsQf2TcwYBcnojX26iHSsO2flJ/VWE+3RoYWsr9ZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792072329; c=relaxed/simple; bh=XtVkBcKpKVWyMPnHp4mv+xE86MVAO5YiognkJI+iRw4=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=GoEj4uCCxoyAQnaJxhxeNNWeYJXnm4/Vsv4LHhN/Ibsm3Q7d2z3haMQMQX+oju6jztfLL352rVLIY0nAExJR76HcUbcAtbAMQqZxc3z4k07GV8JX+dYiHcXYbEpjpHtu00uH4S/Ys0stZA6HtWbgkc0noALeceXsr8vbKy+g2LQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mxo+pNTH; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mxo+pNTH" 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) Precedence: bulk X-Mailing-List: kvm@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: 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 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.