[PATCH 18/28] KVM: arm64: Add kvm_has_nv{2,3}() predicates
Marc Zyngier
maz at kernel.org
Fri Jul 10 15:36:14 PDT 2026
On Fri, 10 Jul 2026 16:30:16 +0100,
Joey Gouly <joey.gouly at arm.com> wrote:
>
> Question,
>
> On Thu, Jul 02, 2026 at 05:02:38PM +0100, Marc Zyngier wrote:
> > 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 (NV2, NV3, NV2 on NV3...).
> >
> > Signed-off-by: Marc Zyngier <maz at kernel.org>
> > ---
> > arch/arm64/include/asm/kvm_emulate.h | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > 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
> > @@ -266,6 +266,26 @@ static inline bool vserror_state_is_nested(struct kvm_vcpu *vcpu)
> > (__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_TMEA);
> > }
> >
> > +static inline bool kvm_has_nv2(struct kvm *kvm)
> > +{
> > + return (cpus_have_final_cap(ARM64_HAS_NESTED_VIRT) &&
> > + kvm_has_feat(kvm, ID_AA64MMFR4_EL1, NV_frac, NV2_ONLY));
>
> Should this also check ID_AA64MMFR2_EL1.NV=0b10? (aka NV2, not just NV2_ONLY)
That'd be unnecessary, as KVM always exposes ID_AA64MMFR2_EL1.NV==0,
owing to the absence of support for the original FEAT_NV (we only
support FEAT_NV2, and treat FEAT_NV with the utmost contempt).
For all intents and purposes, ID_AA64MMFR2_EL1.NV is a dead field, and
KVM will forever expose it as 0 (unless someone at ARM is mad enough
to repurpose it...).
Thanks,
M.
--
Jazz isn't dead. It just smells funny.
More information about the linux-arm-kernel
mailing list