From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=85.214.250.239 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796284137; b=dk6zQQzNiphL+Xp0A6/N9YKESl2rVfp+cWDKLcqCsvxTUxgc+3BU5ndAYUMQeBihL/dT 0PAnYLtQoM6BbILPt775UAZ1zooatqgdZsbecQS/keLb/fPbrLHRnJdBHCqtANSO1c8rv y2VyYsimxRRBULXR5qIhtM2X8YmdbaEoNayA9mcUfF/XBWqG/OzVBah9lBzSrLYI2iFpY SZHhJ1mC+uaqswK71zteM6TU9G/mzgbIV+PcsBqb86u1bJPvwUTG2hiHJxeocAPI1Xo0w WoyWiOa7420yGg2xcrW/P3r5eYr6/LG785eiAeD8q/gcc2dQvse1RUkueArTUQdYFWg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796284137; h=DMARC-Filter:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=qiKTILhh3M3oeoOJb/ExOr+fTpRQIuQXLDqpd4dh3UA=; b=hwzMG/wCeJL7HnjZy0WPJIWKSDgX6qjQWWd5h6FEgA2mKMAHC39dGDvfYIm/OTldrc6m fQrx2ZcX+WGSYeAsGHo7rgP/qnhLipGCO5hS6zkV0PbY/5/NsuNTaTpHyxQBXsa5L8vvl t77Is7KYbNwFPDCiSlVHCRZeEnxMa+ChRTjKbrSoKO4iQeRf5Qx8UJC5qLJG4QObOXSgg /jzIGkfYPNR+Uit4oNrZodeVSplLp/RXAbnJLMny9Fnd8gkfXMzvWVDqjbvNm0xNTdOXK /T9+ACvMChVWU/bck2aLf7EMikpqxkbIXg8IcC0qzn4FxUfCiFrKwN2Ae6PlCG6bchg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=8bytes.org; spf=pass smtp.mailfrom=8bytes.org; arc=none smtp.remote-ip=85.214.250.239 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82076606A322 for ; Thu, 3 Dec 2026 07:48:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 82076606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=8bytes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=8bytes.org Received: from 8bytes.org (p549216fa.dip0.t-ipconnect.de [84.146.22.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 39D3A245B57; Thu, 3 Dec 2026 08:48:55 +0100 (CET) Date: Thu, 3 Dec 2026 08:48:54 +0100 From: =?utf-8?B?SsO2cmcgUsO2ZGVs?= To: Mostafa Saleh Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, will@kernel.org, robin.murphy@arm.com Subject: Re: [PATCH v2 2/2] iommu: debug-pagealloc: Fix mappings starting at phys 0 Message-ID: References: <20261202112047.509228-1-smostafa@google.com> <20261202112047.509228-3-smostafa@google.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202112047.509228-3-smostafa@google.com> On Wed, Dec 02, 2026 at 11:20:46AM +0000, Mostafa Saleh wrote: > __iommu_debug_map() warns and counts nothing when phys is 0, but unmap > only skips the page that iommu_iova_to_phys() reports as 0 and > decrements the others, > Unmapping a multi-page mapping that starts at physical address 0 > therefore underflows every other page. > > Drop the warning and skip only that page, as unmap does. > > Fixes: 7e84593795b3 ("iommu: debug-pagealloc: Track IOMMU pages") > Signed-off-by: Mostafa Saleh > --- > drivers/iommu/iommu-debug-pagealloc.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/drivers/iommu/iommu-debug-pagealloc.c b/drivers/iommu/iommu-debug-pagealloc.c > index 5faf53aa29f9..348fc4c57ed2 100644 > --- a/drivers/iommu/iommu-debug-pagealloc.c > +++ b/drivers/iommu/iommu-debug-pagealloc.c > @@ -102,11 +102,16 @@ void __iommu_debug_map(struct iommu_domain *domain, phys_addr_t phys, size_t siz > phys_addr_t end; > size_t page_size = iommu_debug_page_size(domain); > > - if (!size || WARN_ON(!phys || check_add_overflow(phys, size - 1, &end))) > + if (!size || WARN_ON(check_add_overflow(phys, size - 1, &end))) > return; Do phys and size need alignment checks for page_size? Otherwise ... > > - for (off = 0 ; off < size ; off += page_size) > + for (off = 0 ; off < size ; off += page_size) { ... off can overflow here when the above checked add with size passed but page_size is added here. -Joerg