diff options
| author | Marc Zyngier <[email protected]> | 2025-07-08 17:25:08 +0000 |
|---|---|---|
| committer | Oliver Upton <[email protected]> | 2025-07-08 17:40:30 +0000 |
| commit | 1d6fea7663b2d3fc8569cf14c91a49fb9b37067b (patch) | |
| tree | bc1faa45e70d551bd34eb4c4515becdbace0890f /arch/arm64/kvm/emulate-nested.c | |
| parent | arm64: Detect FEAT_DoubleFault2 (diff) | |
| download | kernel-1d6fea7663b2d3fc8569cf14c91a49fb9b37067b.tar.gz kernel-1d6fea7663b2d3fc8569cf14c91a49fb9b37067b.zip | |
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 <[email protected]>
Reviewed-by: Marc Zyngier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Oliver Upton <[email protected]>
Diffstat (limited to 'arch/arm64/kvm/emulate-nested.c')
| -rw-r--r-- | arch/arm64/kvm/emulate-nested.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index 3a384e9660b8..1de4a9001d9d 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -2592,13 +2592,8 @@ inject: static bool __forward_traps(struct kvm_vcpu *vcpu, unsigned int reg, u64 control_bit) { - bool control_bit_set; - - if (!vcpu_has_nv(vcpu)) - return false; - - control_bit_set = __vcpu_sys_reg(vcpu, reg) & control_bit; - if (!is_hyp_ctxt(vcpu) && control_bit_set) { + if (is_nested_ctxt(vcpu) && + (__vcpu_sys_reg(vcpu, reg) & control_bit)) { kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu)); return true; } |
