On Wed, Aug 09, 2023 at 11:55:19AM -0700, Andrew Morton wrote: > > The patch titled > Subject: arm: dma-mapping: fix potential endless loop in __dma_page_dev_to_cpu() > has been added to the -mm mm-unstable branch. Its filename is > arm-implement-the-new-page-table-range-api-fix.patch Thanks. Can you add ia64-implement-the-new-page-table-range-api-fix.patch as well, please? (Debian no longer ships the compilers, so not even compile tested) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index 48d475f10003..c4d477e8bcd4 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c @@ -811,12 +811,16 @@ static void mark_clean(void *addr, size_t size) if (offset) { left -= folio_size(folio) - offset; + if (left <= 0) + return; folio = folio_next(folio); } while (left >= folio_size(folio)) { - set_bit(PG_arch_1, &folio->flags); left -= folio_size(folio); + set_bit(PG_arch_1, &folio->flags); + if (!left) + break; folio = folio_next(folio); } } diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index b95debabdc2a..05b0f2f0c073 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -76,12 +76,16 @@ void arch_dma_mark_clean(phys_addr_t paddr, size_t size) if (offset) { left -= folio_size(folio) - offset; + if (left <= 0) + return; folio = folio_next(folio); } while (left >= (ssize_t)folio_size(folio)) { - set_bit(PG_arch_1, &pfn_to_page(pfn)->flags); left -= folio_size(folio); + set_bit(PG_arch_1, &pfn_to_page(pfn)->flags); + if (!left) + break; folio = folio_next(folio); } }