summaryrefslogtreecommitdiff
path: root/arch/arm64/kvm/vgic/vgic-v3-nested.c
diff options
context:
space:
mode:
authorMarc Zyngier <maz@kernel.org>2025-07-08 10:25:08 -0700
committerOliver Upton <oliver.upton@linux.dev>2025-07-08 10:40:30 -0700
commit1d6fea7663b2d3fc8569cf14c91a49fb9b37067b (patch)
treebc1faa45e70d551bd34eb4c4515becdbace0890f /arch/arm64/kvm/vgic/vgic-v3-nested.c
parente3fd66620f10cddfcfe062404cf0ed170133bb43 (diff)
KVM: arm64: Add helper to identify a nested context
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@kernel.org> Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20250708172532.1699409-4-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/kvm/vgic/vgic-v3-nested.c')
-rw-r--r--arch/arm64/kvm/vgic/vgic-v3-nested.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm64/kvm/vgic/vgic-v3-nested.c b/arch/arm64/kvm/vgic/vgic-v3-nested.c
index a50fb7e6841f..9c3997776f50 100644
--- a/arch/arm64/kvm/vgic/vgic-v3-nested.c
+++ b/arch/arm64/kvm/vgic/vgic-v3-nested.c
@@ -116,7 +116,7 @@ bool vgic_state_is_nested(struct kvm_vcpu *vcpu)
{
u64 xmo;
- if (vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu)) {
+ if (is_nested_ctxt(vcpu)) {
xmo = __vcpu_sys_reg(vcpu, HCR_EL2) & (HCR_IMO | HCR_FMO);
WARN_ONCE(xmo && xmo != (HCR_IMO | HCR_FMO),
"Separate virtual IRQ/FIQ settings not supported\n");