From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796210455; b=YMyA7Hn42Go+gHa/YbxFnaIN4DY9L2L3PKeH3UCWSrEjF58/XrIopbcW/pMXAQxujMLW tcuxuO/S8alV6Rh2JZEblDH2QPnGryv98X7yj29C0R63P+siDYHcYYjE7YRN+gccEaCmW OHJDITvw/8lLSe3diZVIbdmtTHsnHSFBg/aGsxwchZvTYGEUhzc9Jre73gkEHLW8+X9Wn PnG1+9ARrlQklxhuVZGzaigLP5IbYhOArCm3NYDV3LyDgGe6bfIScTJXjVXuu0l7qllbs ef3zD3g7CtF3iP5LRjwwBixla1CfTpisH5fSBCa+mv2nkPU3fGt09iWXB06zQN/DWRA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796210455; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Received:Date:In-Reply-To:Mime-Version: References:X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=WQ+NPjeKxDCuSwaccLwmHmBs2TfLGO1HT9j8egbE8Tg=; b=opg2u6+S+H465DGNEeBf4PUSm8WHHTKSUIZu6GSYRvUVt38o3hgq53Z3GPicK1tI3x7F 9J7ptY759Ylmuu9hLz9Nm/EhtdSze1C6XrkfI+uQKq8l+s7uyNlnDnlOGzH02xRAEIO3N bqxarwlNRX3Xpr0guJ0ZNAcgk4SB3VkYap6MNW/pvMEUTLb5HKM8BatCConk7DiAfmKq3 IBVLkb8hLBylrhpeGX6rQc4YLFs92kIZM4eHkNM7iDDWFW4z0Tsg+jkbdO932jNzTBopQ 1fg4LawftDIj4HoDm+D2NhNf/XqU0APuBx6I+By/vfFXKJ3gg+7YVUBCFVNQKg3yyGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Fl6v0Jl9; arc=none smtp.remote-ip=209.85.218.69 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A531B60A2605 for ; Wed, 2 Dec 2026 11:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A531B60A2605 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--smostafa.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Fl6v0Jl9 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c521ac612bfso238606666b.1 for ; Wed, 02 Dec 2026 03:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796210453; x=1796815253; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WQ+NPjeKxDCuSwaccLwmHmBs2TfLGO1HT9j8egbE8Tg=; b=Fl6v0Jl9gxtU3MdC5GoKn3C11P2V+r8iuZFN8AoupISOFh5y459KQG1qHb76KK98nP vNiqpujm6zbVJq2dpZ9t3yaok8ZCJ75/U6v1istV1cXWef0bo/vbPhMrBJBoOzedaf46 CHWmn9+E70T8DkkecUv85H2n7O/u4VyK62SYbrxqox9eq1gg3xufyQtRU55uq+b4Pixh GxVTWbNdKQBXIFCBKuzybVQs1h20oy7raJE3m8dWi4KW2UQOgxDRea/RZyUnmk/YC16B f7srUGXo4y+emWLed7K6LWknBnS6R5fe8Xk9mn9zgkBFLVnHI0zpS2UinM9sDBTbbaj4 71Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796210453; x=1796815253; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WQ+NPjeKxDCuSwaccLwmHmBs2TfLGO1HT9j8egbE8Tg=; b=bavIfhigWBFThJDmCeLyk56OxsSK3sOiO4rVInRM0/D33OidPHI5AX9GMnPD1Wla/4 GtW1QhogNQNTSPDmOajhrNHOTGcBnUaRZEX2KTe+9O+fKfYborgqdIfsvmU/nLSeOJWf ZTtP2+BvldZX7t8Od3Qay5pU5Nvg8E/AlOCO7yk+yBZexLQqriUYCcH/qv5VsNcUHoRM u4Q5W+jlU+0FJcEWZJSMCQHmSjBAsdZyLJxZp6LCRJJaYsOdzqJsK+NLwbF80EGDPgOb 3gVWXdNYLXl7vyHbG2enI5ls/HoLUnBcdaP9Xri8VYZGyN9HsxGrt0XGZ16VELocJNe7 tRnA== X-Gm-Message-State: APuU4Z8WKT6EP86eL0gnNNjBBrgW2UIzPTfn/e7qFuca85efF9l8m6f6 8YpS5Yy3vuv3xaLu7bQhi7f9Zh6AXNkbZae6/zV9pn7Te4FBKBZjECqOi+91wwyKBP2XZ+Hw+qF DS85SSx1R/UlUywzbGSBjUy4LMemppVEpuvwaLde9Urogdcc/3g/2zfbOQjsG8yrPdRE0IY2L4z w9EvPFnn0b7O/uHL6AyaCnzeaHpDnZBjOuPWUzwipotK9LyQ== X-Received: from edse3.prod.google.com ([2002:aa7:d7c3:0:b0:6bb:cbbf:2c7e]) (user=smostafa job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:c6d0:20b0:6bc:3171:989f with SMTP id 4fb4d7f45d1cf-6bc31719b9amr3267936a12.36.1796210452980; Wed, 02 Dec 2026 03:20:52 -0800 (PST) Date: Wed, 2 Dec 2026 11:20:46 +0000 In-Reply-To: <20261202112047.509228-1-smostafa@google.com> X-Mailing-List: iommu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202112047.509228-1-smostafa@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202112047.509228-3-smostafa@google.com> Subject: [PATCH v2 2/2] iommu: debug-pagealloc: Fix mappings starting at phys 0 From: Mostafa Saleh To: iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, Mostafa Saleh Content-Type: text/plain; charset="UTF-8" __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; - for (off = 0 ; off < size ; off += page_size) + for (off = 0 ; off < size ; off += page_size) { + /* Unmap cannot tell PA 0 from an unmapped IOVA */ + if (!(phys + off)) + continue; + iommu_debug_inc_page(phys + off); + } } static void __iommu_debug_update_iova(struct iommu_domain *domain, -- 2.56.1.911.g883d8bcb20-goog