linux/arch/mips/mm
Yang Shi 7768fdc079 mips: rt: Replace pagefault_* to raw version
In k{un}map_coherent, pagefault_disable and pagefault_enable are called
respectively, but k{un}map_coherent needs preempt disabled according to
commit f8829caee3 ("[MIPS] Fix aliasing bug
in copy_to_user_page / copy_from_user_page") to avoid dcache alias on COW.

k{un}map_coherent are just called when cpu_has_dc_aliases == 1 with VIPT cache.
However, actually, the most modern MIPS processors have PIPT dcache without
dcache alias issue. In such case, k{un}map_atomic will be called with preempt
enabled.

To fix this, we replace pagefault_* to raw version in k{un}map_coherent, which
disables preempt, otherwise the following kernel panic may be caught:

CPU 0 Unable to handle kernel paging request at virtual address fffffffffffd5000, epc == ffffffff80122c00, ra == ffffffff8011fbcc
Oops[#1]:
CPU: 0 PID: 409 Comm: runltp Not tainted 3.14.17-rt5 #1
task: 980000000fa936f0 ti: 980000000eed0000 task.ti: 980000000eed0000
$ 0 : 0000000000000000 000000001400a4e1 fffffffffffd5000 0000000000000001
$ 4 : 980000000cded000 fffffffffffd5000 980000000cdedf00 ffffffffffff00fe
$ 8 : 0000000000000000 ffffffffffffff00 000000000000000d 0000000000000004
$12 : 980000000eed3fe0 000000000000a400 ffffffffa00ae278 0000000000000000
$16 : 980000000cded000 000000726eb855c8 98000000012ccfe8 ffffffff8095e0c0
$20 : ffffffff80ad0000 ffffffff8095e0c0 98000000012d0bd8 980000000fb92000
$24 : 0000000000000000 ffffffff80177fb0
$28 : 980000000eed0000 980000000eed3b60 980000000fb92060 ffffffff8011fbcc
Hi : 000000000002cb02
Lo : 000000000000ee56
epc : ffffffff80122c00 copy_page+0x38/0x548
    Not tainted
ra : ffffffff8011fbcc copy_user_highpage+0x16c/0x180
Status: 1400a4e3 KX SX UX KERNEL EXL IE
Cause : 10800408
BadVA : fffffffffffd5000
PrId : 00010000 (MIPS64R2-generic)
Modules linked in: i2c_piix4 i2c_core uhci_hcd
Process runltp (pid: 409, threadinfo=980000000eed0000, task=980000000fa936f0, tls=000000fff7756700)
Stack : 98000000012ccfe8 980000000eeb7ba8 980000000ecc7508 000000000666da5b
000000726eb855c8 ffffffff802156e0 000000726ea4a000 98000000010007e0
980000000fb92060 0000000000000000 0000000000000000 6db6db6db6db6db7
0000000000000080 000000726eb855c8 980000000fb92000 980000000eeeec28
980000000ecc7508 980000000fb92060 0000000000000001 00000000000000a9
ffffffff80995e60 ffffffff80218910 000000001400a4e0 ffffffff804efd24
980000000ee25b90 ffffffff8079cec4 ffffffff8079d49c ffffffff80979658
000000000666da5b 980000000eeb7ba8 000000726eb855c8 00000000000000a9
980000000fb92000 980000000fa936f0 980000000eed3eb0 0000000000000001
980000000fb92088 0000000000030002 980000000ecc7508 ffffffff8011ecd0
...
Call Trace:
[<ffffffff80122c00>] copy_page+0x38/0x548
[<ffffffff8011fbcc>] copy_user_highpage+0x16c/0x180
[<ffffffff802156e0>] do_wp_page+0x658/0xcd8
[<ffffffff80218910>] handle_mm_fault+0x7d8/0x1070
[<ffffffff8011ecd0>] __do_page_fault+0x1a0/0x508
[<ffffffff80104d84>] resume_userspace_check+0x0/0x10

Or there may be random segmentation fault happened.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Yang Shi <yang.shi@windriver.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2020-10-14 00:59:24 +03:00
..
Makefile MIPS: Move generated code to .text for microMIPS 2013-07-01 15:10:56 +02:00
c-octeon.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
c-r3k.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
c-r4k.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2014-01-30 17:20:32 -08:00
c-tx39.c MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code 2013-07-14 19:36:51 -04:00
cache.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
cerr-sb1.c MIPS: Sibyte: Fix build for SIBYTE_BW_TRACE on BCM1x55 and BCM1x80. 2013-06-21 18:07:02 +02:00
cex-gen.S MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
cex-oct.S MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
cex-sb1.S mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
dma-default.c MIPS: improve checks for noncoherent DMA 2014-01-22 20:43:10 +01:00
extable.c MIPS: Eleminate filenames from comments 2009-08-03 17:52:40 +01:00
fault.c mm: pagefault_disabled() 2020-10-14 00:59:09 +03:00
gup.c MIPS: Fix get_user_page_fast() for mips with cache alias 2013-08-26 15:26:48 +02:00
highmem.c MIPS: Highmem: Fix build error if CONFIG_DEBUG_HIGHMEM is disabled 2012-12-13 18:15:27 +01:00
hugetlbpage.c hugetlb: restrict hugepage_migration_support() to x86_64 2014-06-30 20:11:53 -07:00
init.c mips: rt: Replace pagefault_* to raw version 2020-10-14 00:59:24 +03:00
ioremap.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
mmap.c mm: remove free_area_cache 2013-07-10 18:11:34 -07:00
page-funcs.S MIPS: Refactor 'clear_page' and 'copy_page' functions. 2012-07-19 11:23:43 +02:00
page.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
pgtable-32.c MIPS: Limit fixrange_init() to the FIXMAP region 2011-07-25 17:26:54 +01:00
pgtable-64.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
sc-ip22.c MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code 2013-07-14 19:36:51 -04:00
sc-mips.c MIPS: Add support for interAptiv cores 2014-01-22 20:19:01 +01:00
sc-r5k.c MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code 2013-07-14 19:36:51 -04:00
sc-rm7k.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
tlb-funcs.S MIPS: mm: Use scratch for PGD when !CONFIG_MIPS_PGD_C0_CONTEXT 2013-10-29 21:24:51 +01:00
tlb-r3k.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
tlb-r4k.c MIPS: Add support for FTLBs 2014-01-22 20:19:00 +01:00
tlb-r8k.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
tlbex-fault.S MIPS: Don't include <asm/page.h> unnecessarily. 2012-12-28 17:04:04 +01:00
tlbex.c MIPS: tlbex: Properly fix HUGE TLB Refill exception handler 2014-11-14 08:59:57 -08:00
uasm-micromips.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
uasm-mips.c mips: delete non-required instances of include <linux/init.h> 2014-01-24 22:39:56 +01:00
uasm.c MIPS: Delete __cpuinit/__CPUINIT usage from MIPS code 2013-07-14 19:36:51 -04:00