[PATCH] KVM: arm64: Add helper to identify a nested context

Marc Zyngier maz at kernel.org
Sat May 31 23:54:40 PDT 2025


On Sat, 31 May 2025 18:52:07 +0100,
Oliver Upton <oliver.upton at linux.dev> wrote:
> 
> On Sat, May 31, 2025 at 05:49:01PM +0100, Marc Zyngier wrote:
> > A common idiom in the KVM code is to check if we are currently
> > dealing with a "nested" context, defined as having NV enabled,
> > but being in the EL1&0 translation regime.
> > 
> > This is usually expressed as:
> > 
> > 	if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu) ... )
> > 
> > which is a mouthful and a bit hard to read, specially when followed
> > by additional conditions.
> > 
> > Introduce a new helper that encapsulate these two terms, allowing
> > the above to be written as
> > 
> > 	if (is_nested_context(vcpu) ... )
> > 
> > which is both shorter and easier to read, and makes more obvious
> > the potential for simplification on some code paths.
> > 
> > Signed-off-by: Marc Zyngier <maz at kernel.org>
> 
> Thanks! I'll probably pick this up as a prefix on my abort routing
> series if that's OK with you.

Of course!

	M.

-- 
Jazz isn't dead. It just smells funny.



More information about the linux-arm-kernel mailing list