KVM: arm64: nv: Hoist vcpu_has_nv() into is_hyp_ctxt()
authorMarc Zyngier <maz@kernel.org>
Mon, 13 Nov 2023 14:16:02 +0000 (14:16 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 19 Dec 2023 09:50:52 +0000 (09:50 +0000)
commit111903d1f5b9334d1100e1c6ee08e740fa374d91
treed7097573005d232c351553741a6f87f56aaab846
parent2bfc654b89c4dd1c372bb2cbba6b5a0eb578d214
KVM: arm64: nv: Hoist vcpu_has_nv() into is_hyp_ctxt()

A rather common idiom when writing NV code as part of KVM is
to have things such has:

if (vcpu_has_nv(vcpu) && is_hyp_ctxt(vcpu)) {
[...]
}

to check that we are in a hyp-related context. The second part of
the conjunction would be enough, but the first one contains a
static key that allows the rest of the checkis to be elided when
in a non-NV environment.

Rewrite is_hyp_ctxt() to directly use vcpu_has_nv(). The result
is the same, and the code easier to read. The one occurence of
this that is already merged is rewritten in the process.

In order to avoid nasty cirtular dependencies between kvm_emulate.h
and kvm_nested.h, vcpu_has_feature() is itself hoisted into kvm_host.h,
at the cost of some #deferry...

Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/arch_timer.c