linux/arch/mips
Paul Burton 523402fa91
MIPS: Fix ioremap() RAM check
We currently attempt to check whether a physical address range provided
to __ioremap() may be in use by the page allocator by examining the
value of PageReserved for each page in the region - lowmem pages not
marked reserved are presumed to be in use by the page allocator, and
requests to ioremap them fail.

The way we check this has been broken since commit 92923ca3aa ("mm:
meminit: only set page reserved in the memblock region"), because
memblock will typically not have any knowledge of non-RAM pages and
therefore those pages will not have the PageReserved flag set. Thus when
we attempt to ioremap a region outside of RAM we incorrectly fail
believing that the region is RAM that may be in use.

In most cases ioremap() on MIPS will take a fast-path to use the
unmapped kseg1 or xkphys virtual address spaces and never hit this path,
so the only way to hit it is for a MIPS32 system to attempt to ioremap()
an address range in lowmem with flags other than _CACHE_UNCACHED.
Perhaps the most straightforward way to do this is using
ioremap_uncached_accelerated(), which is how the problem was discovered.

Fix this by making use of walk_system_ram_range() to test the address
range provided to __ioremap() against only RAM pages, rather than all
lowmem pages. This means that if we have a lowmem I/O region, which is
very common for MIPS systems, we're free to ioremap() address ranges
within it. A nice bonus is that the test is no longer limited to lowmem.

The approach here matches the way x86 performed the same test after
commit c81c8a1eee ("x86, ioremap: Speed up check for RAM pages") until
x86 moved towards a slightly more complicated check using walk_mem_res()
for unrelated reasons with commit 0e4c12b45a ("x86/mm, resource: Use
PAGE_KERNEL protection for ioremap of memory pages").

Signed-off-by: Paul Burton <paul.burton@mips.com>
Reported-by: Serge Semin <fancer.lancer@gmail.com>
Tested-by: Serge Semin <fancer.lancer@gmail.com>
Fixes: 92923ca3aa ("mm: meminit: only set page reserved in the memblock region")
Cc: James Hogan <jhogan@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org # v4.2+
Patchwork: https://patchwork.linux-mips.org/patch/19786/
2018-07-05 14:43:21 -07:00
..
alchemy Merge branch 'i2c/for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2018-06-14 16:21:46 +09:00
ar7
ath25
ath79 MIPS: pb44: Fix i2c-gpio GPIO descriptor table 2018-06-18 22:19:50 +01:00
bcm47xx MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum 2018-06-18 22:19:50 +01:00
bcm63xx
bmips treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
boot MIPS changes for 4.18 2018-06-12 12:56:02 -07:00
cavium-octeon swiotlb: move the SWIOTLB config symbol to lib/Kconfig 2018-05-09 06:58:01 +02:00
cobalt
configs MIPS changes for 4.18 2018-06-12 12:56:02 -07:00
crypto
dec MIPS: Convert update_persistent_clock() to update_persistent_clock64() 2018-05-14 23:58:23 +01:00
emma
fw
generic MIPS: xilfpga: Actually include FDT in fitImage 2018-05-14 23:54:25 +01:00
include MIPS: Wire up io_pgetevents syscall 2018-06-19 21:14:29 -07:00
jazz
jz4740 MIPS: JZ4740: Drop old platform reset code 2018-05-14 23:58:23 +01:00
kernel MIPS: Use async IPIs for arch_trigger_cpumask_backtrace() 2018-06-28 14:14:41 -07:00
kvm Small update for KVM. 2018-06-12 11:34:04 -07:00
lantiq MIPS: lantiq: ase: Enable MFD_SYSCON 2018-03-21 21:57:35 +00:00
lasat MIPS: Convert update_persistent_clock() to update_persistent_clock64() 2018-05-14 23:58:23 +01:00
lib MIPS: memset.S: Reinstate delay slot indentation 2018-05-21 16:01:15 +01:00
loongson32
loongson64 MIPS changes for 4.18 2018-06-12 12:56:02 -07:00
math-emu
mm MIPS: Fix ioremap() RAM check 2018-07-05 14:43:21 -07:00
mti-malta MIPS: Convert read_persistent_clock() to read_persistent_clock64() 2018-05-14 23:58:23 +01:00
net bpf, mips: remove unused function 2018-05-14 19:11:45 -07:00
netlogic scatterlist: move the NEED_SG_DMA_LENGTH config symbol to lib/Kconfig 2018-05-09 06:55:59 +02:00
oprofile MIPS: perf: More robustly probe for the presence of per-tc counters 2018-05-15 15:16:16 +01:00
paravirt
pci pci-v4.18-changes 2018-06-07 12:45:58 -07:00
pic32
pistachio
pmcs-msp71xx
pnx833x
power
ralink MIPS: ralink: Fix booting on MT7621 2018-03-22 00:06:30 +00:00
rb532
sgi-ip22
sgi-ip27
sgi-ip32
sibyte MIPS changes for 4.18 2018-06-12 12:56:02 -07:00
sni MIPS: sni: Remove the read_persistent_clock() 2018-05-14 23:58:25 +01:00
tools
txx9 treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
vdso MIPS: VDSO: Replace __mips_isa_rev with MIPS_ISA_REV 2018-03-09 11:22:48 +00:00
vr41xx
Kbuild
Kbuild.platforms
Kconfig MIPS: Add support for restartable sequences 2018-06-19 21:13:17 -07:00
Kconfig.debug
Makefile kbuild: add machine size to CHECKFLAGS 2018-06-01 11:36:58 +09:00
Makefile.postlink