mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
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. Acked-by: David Hildenbrand (Red Hat) <david@kernel.org> Reviewed-by: Pranjal Shrivastava <praan@google.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Mostafa Saleh <smostafa@google.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
33 lines
704 B
C
33 lines
704 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2025 - Google Inc
|
|
* Author: Mostafa Saleh <smostafa@google.com>
|
|
* IOMMU API debug page alloc sanitizer
|
|
*/
|
|
#include <linux/atomic.h>
|
|
#include <linux/iommu-debug-pagealloc.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/page_ext.h>
|
|
|
|
static bool needed;
|
|
|
|
struct iommu_debug_metadata {
|
|
atomic_t ref;
|
|
};
|
|
|
|
static __init bool need_iommu_debug(void)
|
|
{
|
|
return needed;
|
|
}
|
|
|
|
struct page_ext_operations page_iommu_debug_ops = {
|
|
.size = sizeof(struct iommu_debug_metadata),
|
|
.need = need_iommu_debug,
|
|
};
|
|
|
|
static int __init iommu_debug_pagealloc(char *str)
|
|
{
|
|
return kstrtobool(str, &needed);
|
|
}
|
|
early_param("iommu.debug_pagealloc", iommu_debug_pagealloc);
|