Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: nv: Never invalidate less than a page for a TTL hint
@ 2026-11-23 10:30 Dan Carpenter
  2026-11-23 13:35 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-11-23 10:30 UTC (permalink / raw)
  To: Marc Zyngier, Oliver Upton, Fuad Tabba, Joey Gouly, Steffen Eiden,
	Suzuki K Poulose, Zenghui Yu, Catalin Marinas, Will Deacon,
	Mark Rutland
  Cc: Karthik Bhargavan, Clément Blaudeau, linux-arm-kernel,
	kvmarm, stable, Dan Carpenter

The compute_tlb_inval_range() function takes the size of a nested TLB
invalidation from the TTL hint in the TLBI operand.  A guest hypervisor
can give a 4K level-3 hint, which asks for a 4K invalidation.  On a host
with 16K or 64K pages that is less than one page.  s2_mmu_unmap_ipa()
passes the 4K size to kvm_stage2_unmap_range(), which hits
WARN_ON(size & ~PAGE_MASK).

WARNING: arch/arm64/kvm/mmu.c:407 at kvm_stage2_unmap_range+0x38/0x60, CPU#1: ipas2e1_ttl_tes/568
Call trace:
 kvm_stage2_unmap_range (arch/arm64/kvm/mmu.c:410) (P)
 s2_mmu_unmap_ipa (arch/arm64/kvm/sys_regs.c:4246)
 kvm_s2_mmu_iterate_by_vmid (arch/arm64/kvm/nested.c:770)
 handle_ipas2e1is (arch/arm64/kvm/sys_regs.c:4258)
 perform_access (arch/arm64/kvm/sys_regs.c:4917)
 kvm_handle_sys_reg (arch/arm64/kvm/sys_regs.c:5455)
 handle_exit (arch/arm64/kvm/handle_exit.c:466)
 kvm_arch_vcpu_ioctl_run (arch/arm64/kvm/arm.c:1583)
 kvm_vcpu_ioctl (virt/kvm/kvm_main.c:4595)

The shadow stage-2 is built from host pages, so invalidating less than
a page makes no sense.  Return at least PAGE_SIZE.

Fixes: d1de1576dc21 ("KVM: arm64: nv: Handle FEAT_TTL hinted TLB operations")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan@pereq.eu>
---
 arch/arm64/kvm/nested.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 78d5b18dbd2d..e964b122e9d0 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -735,7 +735,7 @@ unsigned long compute_tlb_inval_range(struct kvm_s2_mmu *mmu, u64 val)
 	}
 
 	WARN_ON(!max_size);
-	return max_size;
+	return max(max_size, PAGE_SIZE);
 }
 
 /*

---
base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
change-id: 20261123-inval_range-095bffa0d3e3

Best regards,
--  
Dan Carpenter <dan@pereq.eu>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 10:30 [PATCH] KVM: arm64: nv: Never invalidate less than a page for a TTL hint Dan Carpenter
2026-11-23 13:35 ` Marc Zyngier

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