From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.208.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796210455; b=Ms6J90tRvk/fGBUXA94hnsEKQN9Hx7kfot9IbzzG2Rt0ifHbqolWuG1fuz31GtmRGldt VQHQRZ4wYarl87TyT9C1kQdea/tJas2FjXFmWOTs46tJKoNrjn73aqaMe3LupjnCa5QGu HOunbtlVQaMX791o6nW8O+eQGxjDNo+jJJrdveqpS10urUj+ELWS4mehJoLYKJChujjmm 6EFpvbF9Ex/O3JSBxDvNRyGpSpbjWlz99L5OUVPWv0a65eOOK7cOy5tT3NqLYZwON3wCt MwbjiNVGeZh/XjCXFhBhQSuA3Qc2Zgi3IX8vJiaGBhnOd3tHs/nhMFQMryXtqlRd+iw== 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-Forwarded-Encrypted: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=12oFxKUa3Bh2XH2Tn1C1Xh/stZw5fSRjV9qKBJysU3bwn0hv7+gfHv77IxZ2toH1gkok Msst+IllxvV37Ot6ZQD8V2uv6bKkOxA9LAF5MwOfJCyyEf4XtknnYalPSjGKgCQX2V0dy 0crXXbfbD01PuxJP5PvtYgEsHy2ojaXgfzGGlDKoQqzVf+HC0kdClNnWNoIHFBWdYMlNo QQKIdkd2df4noqYhw0oSaIRfbSqVnOJ1t4nObVxVLK3TqFH4oAGXnbqC3omDEHvTmvuuH Ii+TeyaS7uxs5TM4VihjB+Sy8v7Et0ULY4HZtBjiSSuuaRpUgwEBBEvI/O/DQewFhMg== 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=T561t0uI; arc=none smtp.remote-ip=209.85.208.71 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (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 A06DE60A2604 for ; Wed, 2 Dec 2026 11:20:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A06DE60A2604 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=T561t0uI Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-6ba91bdc511so3166646a12.3 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=vger.kernel.org; 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=T561t0uIOwdyKi7JP3VaN9VQ2Du0i5YcLcaWTBEyiVGIe+uLC6OCvUR9Px6KGo7oSZ Oy46y5I9Eu5np1hV1hApUCFrwkZ4REEmbHuTrQqSBPdjKJsAU/pkhhWFJPEzkNvEcYVa WAdn4XsXCNLoyEgxT6Ui/c0Vhs/ogD7T+fIXRUAiPErzKqFTmi48DlUkNUqTGFzCDzbA YNUqPjkZ0pSzZPDIEAGwyH00N8NqUvGnmPTZ1jdNLuU6XDgNsn8BGvIasa+XtN4PPuyH B2f57zGvtwujwuPZni2aq2jIHLX1JwMntAOGWS6Q8GZEOXtFzfg/iJey2oBv8WpWsOfw 5y5A== 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=w+8pjcBgIVbsOYIGCIQGZ0smWgpPPUt5xR9sSbjTnilyoim1CwNXNyPcTbvZQ19vb0 vDl6DLhnRb99TbWyRUpNQ4/7fayVPg+rM5cg+LGsBknyPA3Jf0tn5FDRwVg/FcpBUqyo LgRup9BIesvvI9FjEjN06I5t76i/Nei9Di0DDogzwz6ar8V3/paVsQHvoU73QDdw3GQe FUrikBSDE25CctxSUOSPBA/3kK0yE83sHKzM80FHPe1VFUJGpj9nnExSiMKc2S+O0qZw YZGXytZxSDbeur0mzmX4TOagyIz7I7yfsmtd3kxizHVt06Yb8Cwu+3bdQ7o0kFb9hR8X KayA== X-Forwarded-Encrypted: i=1; AL+hErH1JNfc0ys/ZG02LmGoS3F9x2WlcRwplBVS7PUHHY7BFcOAEdR/ivVWxmfQ1wB+5DfC+GbO3w3wTqnRXdg=@vger.kernel.org X-Gm-Message-State: APuU4Z+DDetBBB8dHMehkBU+R9tjHFU022ivVkHCW82Tg5mufoqMoqu9 al/HR87XenXbSh7b5SI8+8gTBVoX+nappgFWUmgH/dkTmeii4rYQLNb+3RA7bHYKSw+Iym3BXdZ PBZ71ouqGZIOWKg== 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: linux-kernel@vger.kernel.org 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