xref: /openbmc/linux/drivers/iommu/iommu-debugfs.c (revision 18b3af44)
1bad614b2SGary R Hook // SPDX-License-Identifier: GPL-2.0
2bad614b2SGary R Hook /*
3bad614b2SGary R Hook  * IOMMU debugfs core infrastructure
4bad614b2SGary R Hook  *
5bad614b2SGary R Hook  * Copyright (C) 2018 Advanced Micro Devices, Inc.
6bad614b2SGary R Hook  *
7bad614b2SGary R Hook  * Author: Gary R Hook <gary.hook@amd.com>
8bad614b2SGary R Hook  */
9bad614b2SGary R Hook 
10bad614b2SGary R Hook #include <linux/pci.h>
11bad614b2SGary R Hook #include <linux/iommu.h>
12bad614b2SGary R Hook #include <linux/debugfs.h>
13bad614b2SGary R Hook 
14bad614b2SGary R Hook struct dentry *iommu_debugfs_dir;
1518b3af44SGeert Uytterhoeven EXPORT_SYMBOL_GPL(iommu_debugfs_dir);
16bad614b2SGary R Hook 
17bad614b2SGary R Hook /**
18bad614b2SGary R Hook  * iommu_debugfs_setup - create the top-level iommu directory in debugfs
19bad614b2SGary R Hook  *
20bad614b2SGary R Hook  * Provide base enablement for using debugfs to expose internal data of an
21bad614b2SGary R Hook  * IOMMU driver. When called, this function creates the
22bad614b2SGary R Hook  * /sys/kernel/debug/iommu directory.
23bad614b2SGary R Hook  *
24bad614b2SGary R Hook  * Emit a strong warning at boot time to indicate that this feature is
25bad614b2SGary R Hook  * enabled.
26bad614b2SGary R Hook  *
2718b3af44SGeert Uytterhoeven  * This function is called from iommu_init; drivers may then use
2818b3af44SGeert Uytterhoeven  * iommu_debugfs_dir to instantiate a vendor-specific directory to be used
2918b3af44SGeert Uytterhoeven  * to expose internal data.
30bad614b2SGary R Hook  */
iommu_debugfs_setup(void)31bad614b2SGary R Hook void iommu_debugfs_setup(void)
32bad614b2SGary R Hook {
33bad614b2SGary R Hook 	if (!iommu_debugfs_dir) {
34bad614b2SGary R Hook 		iommu_debugfs_dir = debugfs_create_dir("iommu", NULL);
35bad614b2SGary R Hook 		pr_warn("\n");
36bad614b2SGary R Hook 		pr_warn("*************************************************************\n");
37bad614b2SGary R Hook 		pr_warn("**     NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE    **\n");
38bad614b2SGary R Hook 		pr_warn("**                                                         **\n");
39bad614b2SGary R Hook 		pr_warn("**  IOMMU DebugFS SUPPORT HAS BEEN ENABLED IN THIS KERNEL  **\n");
40bad614b2SGary R Hook 		pr_warn("**                                                         **\n");
41bad614b2SGary R Hook 		pr_warn("** This means that this kernel is built to expose internal **\n");
42bad614b2SGary R Hook 		pr_warn("** IOMMU data structures, which may compromise security on **\n");
43bad614b2SGary R Hook 		pr_warn("** your system.                                            **\n");
44bad614b2SGary R Hook 		pr_warn("**                                                         **\n");
45bad614b2SGary R Hook 		pr_warn("** If you see this message and you are not debugging the   **\n");
46bad614b2SGary R Hook 		pr_warn("** kernel, report this immediately to your vendor!         **\n");
47bad614b2SGary R Hook 		pr_warn("**                                                         **\n");
48bad614b2SGary R Hook 		pr_warn("**     NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE    **\n");
49bad614b2SGary R Hook 		pr_warn("*************************************************************\n");
50bad614b2SGary R Hook 	}
51bad614b2SGary R Hook }
52