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