| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Written by Pekka Paalanen, 2008-2009 <pq@iki.fi> |
|---|
| 3 | 4 | */ |
|---|
| .. | .. |
|---|
| 7 | 8 | #include <linux/module.h> |
|---|
| 8 | 9 | #include <linux/io.h> |
|---|
| 9 | 10 | #include <linux/mmiotrace.h> |
|---|
| 11 | +#include <linux/security.h> |
|---|
| 10 | 12 | |
|---|
| 11 | 13 | static unsigned long mmio_address; |
|---|
| 12 | 14 | module_param_hw(mmio_address, ulong, iomem, 0); |
|---|
| .. | .. |
|---|
| 77 | 79 | |
|---|
| 78 | 80 | static void do_test(unsigned long size) |
|---|
| 79 | 81 | { |
|---|
| 80 | | - void __iomem *p = ioremap_nocache(mmio_address, size); |
|---|
| 82 | + void __iomem *p = ioremap(mmio_address, size); |
|---|
| 81 | 83 | if (!p) { |
|---|
| 82 | 84 | pr_err("could not ioremap, aborting.\n"); |
|---|
| 83 | 85 | return; |
|---|
| .. | .. |
|---|
| 102 | 104 | int i; |
|---|
| 103 | 105 | |
|---|
| 104 | 106 | for (i = 0; i < 10; ++i) { |
|---|
| 105 | | - p = ioremap_nocache(mmio_address, PAGE_SIZE); |
|---|
| 107 | + p = ioremap(mmio_address, PAGE_SIZE); |
|---|
| 106 | 108 | if (p) |
|---|
| 107 | 109 | iounmap(p); |
|---|
| 108 | 110 | } |
|---|
| .. | .. |
|---|
| 114 | 116 | static int __init init(void) |
|---|
| 115 | 117 | { |
|---|
| 116 | 118 | unsigned long size = (read_far) ? (8 << 20) : (16 << 10); |
|---|
| 119 | + int ret = security_locked_down(LOCKDOWN_MMIOTRACE); |
|---|
| 120 | + |
|---|
| 121 | + if (ret) |
|---|
| 122 | + return ret; |
|---|
| 117 | 123 | |
|---|
| 118 | 124 | if (mmio_address == 0) { |
|---|
| 119 | 125 | pr_err("you have to use the module argument mmio_address.\n"); |
|---|
| .. | .. |
|---|
| 121 | 127 | return -ENXIO; |
|---|
| 122 | 128 | } |
|---|
| 123 | 129 | |
|---|
| 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); |
|---|
| 127 | 133 | do_test(size); |
|---|
| 128 | 134 | do_test_bulk_ioremapping(); |
|---|
| 129 | 135 | pr_info("All done.\n"); |
|---|