xref: /linux/include/linux/iommu-debug-pagealloc.h (revision 1e0ea4dff0f46a3575b6882941dc7331c232d72c)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2025 - Google Inc
4  * Author: Mostafa Saleh <smostafa@google.com>
5  * IOMMU API debug page alloc sanitizer
6  */
7 
8 #ifndef __LINUX_IOMMU_DEBUG_PAGEALLOC_H
9 #define __LINUX_IOMMU_DEBUG_PAGEALLOC_H
10 
11 #ifdef CONFIG_IOMMU_DEBUG_PAGEALLOC
12 DECLARE_STATIC_KEY_FALSE(iommu_debug_initialized);
13 
14 extern struct page_ext_operations page_iommu_debug_ops;
15 
16 void __iommu_debug_check_unmapped(const struct page *page, int numpages);
17 
iommu_debug_check_unmapped(const struct page * page,int numpages)18 static inline void iommu_debug_check_unmapped(const struct page *page, int numpages)
19 {
20 	if (static_branch_unlikely(&iommu_debug_initialized))
21 		__iommu_debug_check_unmapped(page, numpages);
22 }
23 
24 #else
iommu_debug_check_unmapped(const struct page * page,int numpages)25 static inline void iommu_debug_check_unmapped(const struct page *page,
26 					      int numpages)
27 {
28 }
29 
30 #endif /* CONFIG_IOMMU_DEBUG_PAGEALLOC */
31 
32 #endif /* __LINUX_IOMMU_DEBUG_PAGEALLOC_H */
33