From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D68F23090C6 for ; Fri, 12 Dec 2025 18:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765564660; cv=none; b=A8YDve/+xpJhrbq3pNl7zlW1iaq8/tXHBTpVFFr2Doy/FAq7Vg3rCJ8jM//zrx7ORaG1B2vQWeARU3Dkythn9oH4SFqYFt4pN9+YhTOBK6chvAT/7W753Y0Gym6SzTYusvYJWl+YkrD9v5IG1EeOHcAwy/m2+Q0OAL/BiACgY8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765564660; c=relaxed/simple; bh=r2NGHV/deV/Fuwr/+VkjLSQ7t9QFbqVnzpA7KFlk3vQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WtKo9zGcxXBjcYv8g8kM4jujpiIfQ4c+EpXazxIb3qTenLVoCu6ZEJhIFbQMiAFWzsHLBTgKECwegXHVgqTSKMMQX2g5OdFMZRvwD4OlGwTj0pXq3wnRuEm+YmpXwuw9z3xFf2dr7bSBAHoWTYyKlglblM/mmlTBYmKhQDsah68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=O2beGFR5; arc=none smtp.client-ip=209.85.128.44 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O2beGFR5" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4779a4fb9bfso139055e9.0 for ; Fri, 12 Dec 2025 10:37:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765564656; x=1766169456; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=pSEL5ePgx5RjiFkm4T13sS/CnpCa9se0VHC4VBAtFtg=; b=O2beGFR5fDOQZetWSWYHySXk8iTgRSB/MgK5+fxXO9+n+oagwDL4ziKOsTDShyNjnZ d84UuTFHG6JjQ8kA5KYuGcjzk4bwCJV9SKUcG8R6qHiJC4H8qe6pycJgfKeHHNMn+1Ft wE9PC/rX9A9U+bldL8XWFB+/wTTRuyDvtjTBCcBDjGsVN/DBjAbw3i0krfLgCDHqyOt1 jb/3kuZk4WipGMp/jtbuVhexndCbeiEv90FxWGb305BrQmB2JjgxAGBu4xbjyWYD6npr kND9apcDM8YBDImjGHeHuGkh8NPFGdoIa8jOjJkUem9FgEnpC1x0mvFQmcgD2yjwmSnd BAWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765564656; x=1766169456; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pSEL5ePgx5RjiFkm4T13sS/CnpCa9se0VHC4VBAtFtg=; b=IoTlRo/13+afifnnTIHfU7Jt9jZvLH+KBb5gGGCG5Af8XA/iB1l4CtyUfcwCCLgDTH y4rlZPQBEGBeHrXD2CRG086wOQFlS0IMwryx6PPN+IYZdRptq38N81DHMXnvOfZpEEdt 5V8V/HqRopOlaW3iZgyw1dQNi2ukRq2Vy3XVLpP654UGbadPhtpVPpof1weEU7mW4wEB ZZtFDhqp/W7gZiF8CKG18Kt+Hz9DE/6qHxlS3y10Nk/H1VvOZOzMnMx7MoslPEexNMdg sF34OYfGdXyubCkbweTBq+kPT8DaCovYmB8VOjx53+gLILQph2hXQoET6JIPIVufT69b K46w== X-Forwarded-Encrypted: i=1; AJvYcCXSxE071Wd+ZP7ak858O2a/og/LgVQ4KsOcSJAhQCqVOHV51BE3tw0bKXqDHPtsOK7iA1aQ3IfROj9VjgU=@vger.kernel.org X-Gm-Message-State: AOJu0YyUnIGlg9erPKNLY7yMsjpIxcqQexFrwl+R2+tA3TP6dcZD53IR SmDajNo9k6AIzKNTZB9NBFXZyxbDQnm5L9b+TApDl3i+pP8xP5RJu8HYIqmFAXCTEg== X-Gm-Gg: AY/fxX4tzc14hpUc9wbJmDLBAzzeySCZoWIEr5/po7q9FRm8+IPXPy2gMuaHbYzc3Vu u2Op8AHlspJgOGHHhwSfAyxXu9OWLNtpAHEFGzSOE1wTaUulwWHNJaggVLdTna+ynA6oXn9MWx0 21nlCxcrsBDY2ub3LV0N+Vt77ww/8TmcEQr0etQz+5k/sEVDSbVkAF406MzGnZAtqxoWdYJvxm9 BVSBflfosug/nkXFDsIREEFxbNARs/kFngopFOvRhXaVtA8c5l3xPCfgOsdqK+Y+CJUgPdaOh4Q DwDg0IusktiM9+aE/oc4M1ipn5HokPLJhuss13wyavX9D5GC+BBDym5fTUmc98FbDtTkWymXiDC iszP046XWwOitIJ6zF7X8+g8yre0g33QRqfIA77lHlo09C+kO+K4Wq5pYmUm/5dEZqqoUonyyvE oBrhJMwAp5wRIJjokveRoMvf/NhH0l+lNdD60egDQl/UhkG5M3hg== X-Google-Smtp-Source: AGHT+IHzdWN4hpt7McD7KCWGDX7vpqcZJcLk3uQhWd353UqV22b/mGz1ioCMGsLdTgWVBmvLQWc0hw== X-Received: by 2002:a05:600c:83c4:b0:477:86fd:fb18 with SMTP id 5b1f17b1804b1-47a94869ebbmr37675e9.8.1765564655960; Fri, 12 Dec 2025 10:37:35 -0800 (PST) Received: from google.com (54.140.140.34.bc.googleusercontent.com. [34.140.140.54]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a8f6f2238sm16173315e9.13.2025.12.12.10.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 10:37:35 -0800 (PST) Date: Fri, 12 Dec 2025 18:37:31 +0000 From: Mostafa Saleh To: Baolu Lu Cc: linux-mm@kvack.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, corbet@lwn.net, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, akpm@linux-foundation.org, vbabka@suse.cz, surenb@google.com, mhocko@suse.com, jackmanb@google.com, hannes@cmpxchg.org, ziy@nvidia.com, david@redhat.com, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, rppt@kernel.org, xiaqinxin@huawei.com, rdunlap@infradead.org Subject: Re: [PATCH v4 1/4] iommu: Add page_ext for IOMMU_DEBUG_PAGEALLOC Message-ID: References: <20251211125928.3258905-1-smostafa@google.com> <20251211125928.3258905-2-smostafa@google.com> <341bbfd9-e6bb-4d1e-b9c0-9077dc3eaba3@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <341bbfd9-e6bb-4d1e-b9c0-9077dc3eaba3@linux.intel.com> On Fri, Dec 12, 2025 at 10:17:11AM +0800, Baolu Lu wrote: > On 12/11/25 20:59, Mostafa Saleh wrote: > > Add a new config IOMMU_DEBUG_PAGEALLOC, which registers new data to > > page_ext. > > > > This config will be used by the IOMMU API to track pages mapped in > > the IOMMU to catch drivers trying to free kernel memory that they > > still map in their domains, causing all types of memory corruption. > > > > This behaviour is disabled by default and can be enabled using > > kernel cmdline iommu.debug_pagealloc. > > > > Signed-off-by: Mostafa Saleh > > --- > > .../admin-guide/kernel-parameters.txt | 9 ++++++ > > drivers/iommu/Kconfig | 19 +++++++++++ > > drivers/iommu/Makefile | 1 + > > drivers/iommu/iommu-debug-pagealloc.c | 32 +++++++++++++++++++ > > include/linux/iommu-debug-pagealloc.h | 17 ++++++++++ > > mm/page_ext.c | 4 +++ > > 6 files changed, 82 insertions(+) > > create mode 100644 drivers/iommu/iommu-debug-pagealloc.c > > create mode 100644 include/linux/iommu-debug-pagealloc.h > > Do you need to update the MAINTAINERS file, since a new file (iommu- > debug-pagealloc.h) is being added? > > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index a8d0afde7f85..d484d9d8d0a4 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -2675,6 +2675,15 @@ Kernel parameters > > 1 - Bypass the IOMMU for DMA. > > unset - Use value of CONFIG_IOMMU_DEFAULT_PASSTHROUGH. > > + iommu.debug_pagealloc= > > + [KNL,EARLY] When CONFIG_IOMMU_DEBUG_PAGEALLOC is set, this > > + parameter enables the feature at boot time. By default, it > > + is disabled and the system behaves the same way as a kernel > > + built without CONFIG_IOMMU_DEBUG_PAGEALLOC. > > + Format: { "0" | "1" } > > + 0 - Sanitizer disabled. > > + 1 - Sanitizer enabled, expect runtime overhead. > > "iommu.debug_pagealloc=0" has the same meaning as "unset". Would > "iommu=debug_pagealloc" look more appropriate? "iommu=" seems to be x86 specific. I was following the pattern for "iommu.passthrough=", "iommu.strict=" and also as "debug_pagealloc=" has it's own command line, it made sense to design this way. Thanks, Mostafa > > > + > > io7= [HW] IO7 for Marvel-based Alpha systems > > See comment before marvel_specify_io7 in > > arch/alpha/kernel/core_marvel.c. > > [ ... ] > > Other changes look good to me. > > Reviewed-by: Lu Baolu