hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/mm/testmmiotrace.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Written by Pekka Paalanen, 2008-2009 <pq@iki.fi>
34 */
....@@ -7,6 +8,7 @@
78 #include <linux/module.h>
89 #include <linux/io.h>
910 #include <linux/mmiotrace.h>
11
+#include <linux/security.h>
1012
1113 static unsigned long mmio_address;
1214 module_param_hw(mmio_address, ulong, iomem, 0);
....@@ -77,7 +79,7 @@
7779
7880 static void do_test(unsigned long size)
7981 {
80
- void __iomem *p = ioremap_nocache(mmio_address, size);
82
+ void __iomem *p = ioremap(mmio_address, size);
8183 if (!p) {
8284 pr_err("could not ioremap, aborting.\n");
8385 return;
....@@ -102,7 +104,7 @@
102104 int i;
103105
104106 for (i = 0; i < 10; ++i) {
105
- p = ioremap_nocache(mmio_address, PAGE_SIZE);
107
+ p = ioremap(mmio_address, PAGE_SIZE);
106108 if (p)
107109 iounmap(p);
108110 }
....@@ -114,6 +116,10 @@
114116 static int __init init(void)
115117 {
116118 unsigned long size = (read_far) ? (8 << 20) : (16 << 10);
119
+ int ret = security_locked_down(LOCKDOWN_MMIOTRACE);
120
+
121
+ if (ret)
122
+ return ret;
117123
118124 if (mmio_address == 0) {
119125 pr_err("you have to use the module argument mmio_address.\n");
....@@ -121,9 +127,9 @@
121127 return -ENXIO;
122128 }
123129
124
- pr_warning("WARNING: mapping %lu kB @ 0x%08lx in PCI address space, "
125
- "and writing 16 kB of rubbish in there.\n",
126
- size >> 10, mmio_address);
130
+ pr_warn("WARNING: mapping %lu kB @ 0x%08lx in PCI address space, "
131
+ "and writing 16 kB of rubbish in there.\n",
132
+ size >> 10, mmio_address);
127133 do_test(size);
128134 do_test_bulk_ioremapping();
129135 pr_info("All done.\n");