Skip to contentSkip to conversation

KVM: arm64: nv: Ignore TLBI IPAS2E1 above the IPA limit

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 18 – Nov 19

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: nv: Ignore TLBI IPAS2E1 above the IPA limit

In theory, an L1 hypervisor could issue a TLBI IPAS2E1 for an IPA above the host's IPA limit. The s2_mmu_unmap_ipa() function would pass it to kvm_stage2_unmap_range(), the page table walk would fail with -ERANGE, and that would trigger the WARN_ON() in kvm_vm_stage2_unmap_range():

	WARN_ON(stage2_apply_range(mmu, start, start + size, fn, may_block));

The TLBI's IPA field goes up to 48 bits, so this needs a host whose IPA limit (its PARange) is below 48 bits, and it would also need to support nested virtualization. There are very few CPUs which meet both these requirements.

The fix for this is to return early. Since there is nothing mapped above the limit, there is nothing to do. This matches how handle_ripas2e1is() also ignores TLBIs that start outside the PA_bits range.

Fixes 70109bcd701e ("KVM: arm64: nv: Handle TLBI IPAS2E1{,IS} operations")

---
This bug was identified as part of our formal analysis work at Pereq. I have not been able to reproduce it on real hardware. The only CPU Claude can think of where you might be able to trigger it is possibly the Apple M2? Not 100% sure about that.

 arch/arm64/kvm/sys_regs.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/kvm/sys_regs.c +3 -0
index ef4554656ddf..19a914941aff 100644
@@ -4236,6 +4236,9 @@ static void s2_mmu_unmap_ipa(struct kvm_s2_mmu *mmu,
 	max_size = compute_tlb_inval_range(mmu, info->ipa.addr);
 	base_addr &= ~(max_size - 1);
 
+	if (base_addr >= kvm_phys_size(mmu))
+		return;
+
 	/*
 	 * See comment in s2_mmu_unmap_range() for why this is allowed to
 	 * reschedule.
Signature · 1 line
2.53.0
maintainer Applied
#1 lore raw
Quoted 9 lines · Dan Carpenter

In theory, an L1 hypervisor could issue a TLBI IPAS2E1 for an IPA above the host's IPA limit. The s2_mmu_unmap_ipa() function would pass it to kvm_stage2_unmap_range(), the page table walk would fail with -ERANGE, and that would trigger the WARN_ON() in kvm_vm_stage2_unmap_range():

	WARN_ON(stage2_apply_range(mmu, start, start + size, fn, may_block));

[...]

Applied to fixes, thanks!

[1/1] KVM: arm64: nv: Ignore TLBI IPAS2E1 above the IPA limit

      commit: 5f9cc7dcda69ed881a3041ad992afaac2a39d687

Cheers,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.