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 3FD8B3CCFB4; Wed, 15 Jul 2026 08:19:12 +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=1784103553; cv=none; b=p+Bi1KK1XouU4dn3MWoXPzWC9zyM+CbJzYiKePYq+us4u06o37IvfccyrdKbDbkypSa7ANQdIQIiFei2Cv/H5bYKwVa8wy/QOSZRRVMs4uPb77mAXFalJm8bjU+QgjMpvDLhrpnGPXEYlUVSa7kxfEch+8qSCx4BFYC9OTOjqt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784103553; c=relaxed/simple; bh=gNxk6vXq829mh4d+7zt2FEOFWIMJWMdp/e4v1P0G1ds=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=KmZvVvZVy2UdZGCFrTGH+NZUhaD5r74bsK96bGSkMduiXBFW22vQWrPJlRvbHSwUKp0ffwnqRk1oKjWeYsDWiaetR80HYapEoo2Avosh6hsv4bzq36eYjAhhgmQAidzqy2m93ZCX6vmc2iFpow7Tm/wR3gXJbDBazmExqXNMXxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kQK1MBtw; 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="kQK1MBtw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DADDF1F000E9; Wed, 15 Jul 2026 08:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784103551; bh=9di0iPNirA8i2aRvfh+nDPIZh/v7N+As+I0AKLeoCG0=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=kQK1MBtwlgMoUlw+ZFZSEhZkWzYiwM2C/vf8niFWavErPgPikzRicOEYoGcwwepk7 YZg960F967Jt5M7QRlZl11I5DfvP0ZMzXEkdaAufi9S065qa7Q/+o1ClThI1TMWY7Z nCG3wDL2zfiO8jbCKZEsajqFsSO8cvdXFXSY/CUOXLBqveWGc+nf+RuP82N8xYqjOg BEJIF5uG8RcqPog75uL5SxO3HOGy9ibKdI64bDU/HO3+8I2+EB0wB3Bf4UvID2uqE6 MmV8LPG6YKD2vNb7HDEmBEzJs1q0S95BCZvEmqilgFpsp2D13u1xsNEFd7Fbg/9mLK XhJNXkIYxRrJA== 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 1wjuph-00000005CWU-3n29; Wed, 15 Jul 2026 08:19:09 +0000 Date: Wed, 15 Jul 2026 09:19:09 +0100 Message-ID: <86ech4oebm.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Steffen Eiden , Joey Gouly , Suzuki K Poulose , Zenghui Yu Subject: Re: [PATCH v2 07/28] KVM: arm64: Don't evaluate HCR_EL2.NV nor HFGITR_EL2.ERET on ERET fast path In-Reply-To: References: <20260714091641.1970822-1-maz@kernel.org> <20260714091641.1970822-8-maz@kernel.org> 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: oupton@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 15 Jul 2026 09:00:37 +0100, Oliver Upton wrote: > > Hey, > > On Tue, Jul 14, 2026 at 10:16:20AM +0100, Marc Zyngier wrote: > > We currently avoid using the ERET fast path if the guest has HCR_EL2.NV > > set. This is an odd check, as NV doesn't mean much if HCR_EL2.TGE==1. > > > > Similarly, evaluating HFGITR_EL2.ERET makes little sense, as > > this only applies to the nested context, while the ERET fast-path > > is purely for the benefit of L1. > > > > Replace these bizarre checks with is_nested_ctxt() which makes a lot > > more sense: if we are running an L2, the ERET trap must go to L1. > > > > Fixes: dd0717a998f77 ("KVM: arm64: nv: Fast-track 'InHost' exception returns") > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/kvm/hyp/vhe/switch.c | 9 +++------ > > 1 file changed, 3 insertions(+), 6 deletions(-) > > > > diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c > > index bbe9cebd3d9d5..a83be345f8450 100644 > > --- a/arch/arm64/kvm/hyp/vhe/switch.c > > +++ b/arch/arm64/kvm/hyp/vhe/switch.c > > @@ -344,13 +344,10 @@ static bool kvm_hyp_handle_eret(struct kvm_vcpu *vcpu, u64 *exit_code) > > * if this is a VHE guest hypervisor returning to its own > > * userspace, or the hypervisor performing a local exception > > * return. No need to save/restore registers, no need to > > - * switch S2 MMU. Just do the canonical ERET. > > - * > > - * Unless the trap has to be forwarded further down the line, > > - * of course... > > + * switch S2 MMU. Just do the canonical ERET unlesss we are in > > + * nested context. > > */ > > typo: unless > > I feel like it wouldn't hurt to add a bit more detail to the comment > here, that L0 KVM doesn't use ERET traps in the nested context. > Otherwise it isn't clear why these always belong to the L1. We already have a tiny bit of information in kvm_handle_eret(), but that's obviously a bit far down the line. Something like this? diff --git a/arch/arm64/kvm/hyp/vhe/switch.c b/arch/arm64/kvm/hyp/vhe/switch.c index a83be345f8450..684cebf23aa0e 100644 --- a/arch/arm64/kvm/hyp/vhe/switch.c +++ b/arch/arm64/kvm/hyp/vhe/switch.c @@ -344,8 +344,13 @@ static bool kvm_hyp_handle_eret(struct kvm_vcpu *vcpu, u64 *exit_code) * if this is a VHE guest hypervisor returning to its own * userspace, or the hypervisor performing a local exception * return. No need to save/restore registers, no need to - * switch S2 MMU. Just do the canonical ERET unlesss we are in + * switch S2 MMU. Just do the canonical ERET unless we are in * nested context. + * + * Note that this is made possible because KVM itself never traps + * ERET when running an L2. The consequence is that any ERET trap is + * the result of HCR_EL2 or HFGITR_EL2 programming by L1 for its own + * guest, and the exception must be forwarded to L1. */ if (is_nested_ctxt(vcpu)) return false; Thanks, M. -- Without deviation from the norm, progress is not possible.