18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * IOMMU debugfs core infrastructure 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2018 Advanced Micro Devices, Inc. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: Gary R Hook <gary.hook@amd.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/pci.h> 118c2ecf20Sopenharmony_ci#include <linux/iommu.h> 128c2ecf20Sopenharmony_ci#include <linux/debugfs.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct dentry *iommu_debugfs_dir; 158c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(iommu_debugfs_dir); 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/** 188c2ecf20Sopenharmony_ci * iommu_debugfs_setup - create the top-level iommu directory in debugfs 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Provide base enablement for using debugfs to expose internal data of an 218c2ecf20Sopenharmony_ci * IOMMU driver. When called, this function creates the 228c2ecf20Sopenharmony_ci * /sys/kernel/debug/iommu directory. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * Emit a strong warning at boot time to indicate that this feature is 258c2ecf20Sopenharmony_ci * enabled. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * This function is called from iommu_init; drivers may then use 288c2ecf20Sopenharmony_ci * iommu_debugfs_dir to instantiate a vendor-specific directory to be used 298c2ecf20Sopenharmony_ci * to expose internal data. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_civoid iommu_debugfs_setup(void) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci if (!iommu_debugfs_dir) { 348c2ecf20Sopenharmony_ci iommu_debugfs_dir = debugfs_create_dir("iommu", NULL); 358c2ecf20Sopenharmony_ci pr_warn("\n"); 368c2ecf20Sopenharmony_ci pr_warn("*************************************************************\n"); 378c2ecf20Sopenharmony_ci pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); 388c2ecf20Sopenharmony_ci pr_warn("** **\n"); 398c2ecf20Sopenharmony_ci pr_warn("** IOMMU DebugFS SUPPORT HAS BEEN ENABLED IN THIS KERNEL **\n"); 408c2ecf20Sopenharmony_ci pr_warn("** **\n"); 418c2ecf20Sopenharmony_ci pr_warn("** This means that this kernel is built to expose internal **\n"); 428c2ecf20Sopenharmony_ci pr_warn("** IOMMU data structures, which may compromise security on **\n"); 438c2ecf20Sopenharmony_ci pr_warn("** your system. **\n"); 448c2ecf20Sopenharmony_ci pr_warn("** **\n"); 458c2ecf20Sopenharmony_ci pr_warn("** If you see this message and you are not debugging the **\n"); 468c2ecf20Sopenharmony_ci pr_warn("** kernel, report this immediately to your vendor! **\n"); 478c2ecf20Sopenharmony_ci pr_warn("** **\n"); 488c2ecf20Sopenharmony_ci pr_warn("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n"); 498c2ecf20Sopenharmony_ci pr_warn("*************************************************************\n"); 508c2ecf20Sopenharmony_ci } 518c2ecf20Sopenharmony_ci} 52