mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: nv: Ignore TLBI IPAS2E1 above the IPA limit
@ 2026-11-18 15:35 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-11-18 15:35 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden,
	Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon,
	Mark Rutland, Christoffer Dall, Jintack Lim, linux-arm-kernel,
	kvmarm, linux-kernel, kernel-janitors, Karthik Bhargavan,
	Clément Blaudeau

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")
Signed-off-by: Dan Carpenter <dan@pereq.eu>
---
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(+)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index ef4554656ddf..19a914941aff 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -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.
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18 15:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 15:35 [PATCH] KVM: arm64: nv: Ignore TLBI IPAS2E1 above the IPA limit Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®