Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] iommu/riscv: Keep page table pages when IOTLB invalidation fails
@ 2026-10-20  5:34 Yuho Choi
  2026-10-20  5:34 ` [PATCH v1 1/2] " Yuho Choi
  2026-10-20  5:34 ` [PATCH v1 2/2] iommu/riscv: Do not report a stalled command queue as completed Yuho Choi
  0 siblings, 2 replies; 3+ messages in thread
From: Yuho Choi @ 2026-10-20  5:34 UTC (permalink / raw)
  To: Tomasz Jeznach, Joerg Roedel, Will Deacon
  Cc: Robin Murphy, Fangyu Yu, Zong Li, Lu Baolu, Paul Walmsley,
	Palmer Dabbelt, Albert Ou, Alexandre Ghiti, iommu, linux-riscv,
	linux-kernel, Yuho Choi

riscv_iommu_iotlb_sync() frees the page table pages on gather->freelist
without knowing whether the invalidation that should have removed the
cached references to them was queued and completed. Patch 1 makes the
command helpers report a failure and leaks the freelist in that case.
Patch 2 fixes riscv_iommu_queue_wait() reporting success when the
command queue stopped on an error before the IOFENCE.C ran, so that
patch 1 also catches that case.

Neither failure is expected on working hardware, but when one happens,
freeing the pages lets the IOMMU walk memory that has a new owner.

The pages that the dma-iommu flush queue frees after flush_iotlb_all()
and the data pages released by iommu_unmap() callers are not covered,
as the IOMMU core does not let those callbacks report a failure.

The issues were found with a static analysis tool from ongoing, not yet
published research, and confirmed by code inspection. Compile-tested
only (ARCH=riscv defconfig with RISCV_IOMMU=y, W=1, each patch).

Yuho Choi (2):
  iommu/riscv: Keep page table pages when IOTLB invalidation fails
  iommu/riscv: Do not report a stalled command queue as completed

 drivers/iommu/riscv/iommu.c | 74 ++++++++++++++++++++++++++-----------
 1 file changed, 53 insertions(+), 21 deletions(-)


base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2026-10-20  5:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-20  5:34 [PATCH v1 0/2] iommu/riscv: Keep page table pages when IOTLB invalidation fails Yuho Choi
2026-10-20  5:34 ` [PATCH v1 1/2] " Yuho Choi
2026-10-20  5:34 ` [PATCH v1 2/2] iommu/riscv: Do not report a stalled command queue as completed Yuho Choi

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