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 05EC8397331; Thu, 2 Jul 2026 17:59:56 +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=1783015198; cv=none; b=W+vB2fttn3U2FGAKbFa8OdqpPkH0RtP+faVk6BVS+Az+bvAHwvMveAhfXkYLNogVQdh4IiRvpbmA3xauPfxbAcb8pDFF2+4KigwsDVLlRxb32EMDMyHEjZvBd0PYcXvFdMhEn1ZyPWVgQfnC1S9+k/GAUxjuDrtRP4xubXmVXDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783015198; c=relaxed/simple; bh=JA7zzd8bNR6cG7/sc2t+cCuhMn28W41qhvQE5775Kn8=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=sYG9+4+Wagms+QBDZ7EuQ1HwO14IeSE14hBY8Bsx+DnkHHJKx8ublrsEGPTlN3ImpPH3gvAGsXcwrgUdb24n/ijQ9LlJSAp9lpsdM9uSdDx0ZEuHC5bF/N4oUluLYXFjz3CaIlvkJaQlyNBNm6w1lnTwYipgLJZr8Fzo8M3zv/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HJVmu5N1; 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="HJVmu5N1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8C401F000E9; Thu, 2 Jul 2026 17:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783015196; bh=f2tGSoghUAj8sAx3DE3zlIQnEkvxY18ZQfnsf4mVnwc=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=HJVmu5N1yIMqby3EAVNHLo2H7grPbWvpAfSfLrR34YAJeY4Da6BRgKmg5ySh8zNAI 3eMtQvYXR7iXj94ywQ8qfIFSRYZfPPoAqeg/NL1PrzGe5yS1YikqIDzvAhO0sWb6tl x3Jc1a47JtQjuWe+ntZHB/+Hc98c71TXdi/Kz2AfxSTEhJkEjgEKN+5f2wRASpVgQh cXYQtmxL+7zAfcPw3TmJv01Yz24Kz1/UvodVGWJppwawAmtItuJlSsnZJOE3eazJW6 pGHER7Ynq+e/ZpOeltd0u0+LUtuIcX0lPaiLu5S9X5knstAh4GNaaUJ9X/eFaqovfC EY1AxWVyVLsNg== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-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 1wfLha-00000000rau-43s3; Thu, 02 Jul 2026 17:59:55 +0000 Date: Thu, 02 Jul 2026 19:01:43 +0100 Message-ID: <87y0ft6zjs.wl-maz@kernel.org> From: Marc Zyngier To: sashiko-reviews@lists.linux.dev Cc: kvm@vger.kernel.org, "Oliver Upton" , kvmarm@lists.linux.dev Subject: Re: [PATCH 18/28] KVM: arm64: Add kvm_has_nv{2,3}() predicates In-Reply-To: <20260702162518.0ACF11F00A3F@smtp.kernel.org> References: <20260702160248.1377250-1-maz@kernel.org> <20260702160248.1377250-19-maz@kernel.org> <20260702162518.0ACF11F00A3F@smtp.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: sashiko-reviews@lists.linux.dev, kvm@vger.kernel.org, oupton@kernel.org, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Thu, 02 Jul 2026 17:25:17 +0100, sashiko-bot@kernel.org wrote: > > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [High] `is_nested_nv3_ctxt()` incorrectly identifies NV3 context when the guest clears `HCR_EL2.E2H`, diverging from hardware execution semantics. > -- > > commit c75857355bb73ff60c1d0206705bb863784f8183 > Author: Marc Zyngier > > KVM: arm64: Add kvm_has_nv{2,3}() predicates > > Add a new set of predicates indicating whether VM is capable of > NV2, NV3, and is in a nested NV3 context. This is going to become > useful as we start dealing with a mix of behaviours. > > > diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h > > index 9831166695186..c562d8171d5e1 100644 > > --- a/arch/arm64/include/asm/kvm_emulate.h > > +++ b/arch/arm64/include/asm/kvm_emulate.h > > [ ... ] > > > +static inline bool kvm_has_nv3(struct kvm *kvm) > > +{ > > + return (cpus_have_final_cap(ARM64_HAS_NESTED_VIRT) && > > + cpus_have_final_cap(ARM64_HAS_NV3) && > > + kvm_has_feat(kvm, ID_AA64MMFR4_EL1, NV_frac, NV3)); > > +} > > + > > +static inline bool is_nested_nv3_ctxt(struct kvm_vcpu *vcpu) > > +{ > > + return (has_vhe() && kvm_has_nv3(vcpu->kvm) && is_nested_ctxt(vcpu) && > > + (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_EL2_NV) && > > + (__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_NVTGE)); > > +} > > [Severity: High] > Does this predicate miss a mandatory check for HCR_EL2.E2H? > > Architecturally, NVTGE is RES0 when E2H is 0. If a guest sets HCR_EL2.NV = 1 > and HCRX_EL2.NVTGE = 1, but leaves HCR_EL2.E2H = 0, the hardware will not > execute the guest under NV3 semantics. Stop inventing the architecture. NV3 is only applicable to E2H==1, and KVM doesn't allow NV with E2H==0. M. -- Jazz isn't dead. It just smells funny.