[PATCH 2/3] KVM: arm64: nv: Don't request or attempt L1 VNCR mapping without vncr_tlb

Jia He justin.he at arm.com
Mon Nov 23 07:09:16 PST 2026


vcpu->arch.vncr_tlb is only allocated when ID_AA64MMFR4_EL1.NV_frac
advertises FEAT_NV2. When NV_frac is cleared to 0 (or E2H0 is selected),
vncr_tlb is NULL for the lifetime of the vCPU.

Don't set KVM_REQ_MAP_L1_VNCR_EL2 in kvm_vcpu_load_hw_mmu() when
vncr_tlb is NULL. The only other place that sets this request is
kvm_translate_vncr(), which only runs on a FEAT_NV2 VNCR abort. Warn and
return early in kvm_map_l1_vncr() if vt is NULL before disabling
preemption and taking kvm->mmu_lock.

Signed-off-by: Jia He <justin.he at arm.com>
---
 arch/arm64/kvm/nested.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 4d83281a7a28..2f52c128f3a7 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -979,7 +979,8 @@ void kvm_vcpu_load_hw_mmu(struct kvm_vcpu *vcpu)
 				vcpu->arch.hw_mmu = get_s2_mmu_nested(vcpu);
 		}
 
-		if (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_EL2_NV)
+		if (vcpu->arch.vncr_tlb &&
+		    (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_EL2_NV))
 			kvm_make_request(KVM_REQ_MAP_L1_VNCR_EL2, vcpu);
 	}
 }
@@ -1761,6 +1762,9 @@ static void kvm_map_l1_vncr(struct kvm_vcpu *vcpu)
 	struct vncr_tlb *vt = vcpu->arch.vncr_tlb;
 	pgprot_t prot;
 
+	if (WARN_ON_ONCE(!vt))
+		return;
+
 	guard(preempt)();
 	guard(read_lock)(&vcpu->kvm->mmu_lock);
 
-- 
2.34.1




More information about the linux-arm-kernel mailing list