linux/arch/mips/mm
Paul Burton b42aa3fd59
MIPS: tlbex: Fix build_restore_pagemask KScratch restore
build_restore_pagemask() will restore the value of register $1/$at when
its restore_scratch argument is non-zero, and aims to do so by filling a
branch delay slot. Commit 0b24cae4d5 ("MIPS: Add missing EHB in mtc0
-> mfc0 sequence.") added an EHB instruction (Execution Hazard Barrier)
prior to restoring $1 from a KScratch register, in order to resolve a
hazard that can result in stale values of the KScratch register being
observed. In particular, P-class CPUs from MIPS with out of order
execution pipelines such as the P5600 & P6600 are affected.

Unfortunately this EHB instruction was inserted in the branch delay slot
causing the MFC0 instruction which performs the restoration to no longer
execute along with the branch. The result is that the $1 register isn't
actually restored, ie. the TLB refill exception handler clobbers it -
which is exactly the problem the EHB is meant to avoid for the P-class
CPUs.

Similarly build_get_pgd_vmalloc() will restore the value of $1/$at when
its mode argument equals refill_scratch, and suffers from the same
problem.

Fix this by in both cases moving the EHB earlier in the emitted code.
There's no reason it needs to immediately precede the MFC0 - it simply
needs to be between the MTC0 & MFC0.

This bug only affects Cavium Octeon systems which use
build_fast_tlb_refill_handler().

Signed-off-by: Paul Burton <paulburton@kernel.org>
Fixes: 0b24cae4d5 ("MIPS: Add missing EHB in mtc0 -> mfc0 sequence.")
Cc: Dmitry Korotin <dkorotin@wavecomp.com>
Cc: stable@vger.kernel.org # v3.15+
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
2019-10-23 21:12:49 -07:00
..
Makefile MIPS: Select R3k-style TLB in Kconfig 2019-09-03 14:20:43 +01:00
c-octeon.c MIPS: Delete unused flush_cache_sigtramp() 2019-02-07 12:59:45 -08:00
c-r3k.c MIPS: Delete unused flush_cache_sigtramp() 2019-02-07 12:59:45 -08:00
c-r4k.c MIPS: Remove unused R5432 CPU support 2019-07-23 14:33:34 -07:00
c-tx39.c MIPS: Delete unused flush_cache_sigtramp() 2019-02-07 12:59:45 -08:00
cache.c MIPS: remove the _dma_cache_wback_inv export 2019-06-03 16:00:08 +02:00
cerr-sb1.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07: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 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
context.c MIPS: Export mm switching functions used by KVM 2019-02-05 11:44:44 -08:00
dma-noncoherent.c dma-mapping: remove arch_dma_mmap_pgprot 2019-08-29 16:43:22 +02:00
extable.c Replace <asm/uaccess.h> with <linux/uaccess.h> globally 2016-12-24 11:46:01 -08:00
fault.c signal: Remove the task parameter from force_sig_fault 2019-05-29 09:31:43 -05:00
highmem.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hugetlbpage.c mm/hugetlb: add size parameter to huge_pte_offset() 2017-07-06 16:24:34 -07:00
init.c MIPS: Detect bad _PFN_SHIFT values 2019-09-20 14:55:07 -07:00
ioremap.c MIPS: Fix ioremap() RAM check 2018-07-05 14:43:21 -07:00
mmap.c mips: use generic mmap top-down layout and brk randomization 2019-09-24 15:54:12 -07:00
page-funcs.S MIPS: Export {copy, clear}_page functions alongside their definitions 2017-01-03 16:48:39 +01:00
page.c arch: mips: mm: page: Remove unused function 2018-06-24 09:27:27 -07:00
pgtable-32.c MIPS: Add partial 32-bit huge page support 2019-07-21 14:30:05 -07:00
pgtable-64.c MIPS: Add 48-bit VA space (and 4-level page tables) for 4K pages. 2017-04-10 11:56:06 +02:00
pgtable.c MIPS: Move pgd_alloc() out of header 2017-02-02 15:06:26 +00:00
sc-debugfs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sc-ip22.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sc-mips.c MIPS: Ingenic: Fix bugs when detecting X1000's L2 cache. 2019-08-05 18:30:33 -07:00
sc-r5k.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sc-rm7k.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tlb-funcs.S MIPS: Consistently declare TLB functions 2018-08-10 17:27:53 -07:00
tlb-r3k.c MIPS: mm: Remove local_flush_tlb_mm() 2019-02-04 10:56:24 -08:00
tlb-r4k.c MIPS: MemoryMapID (MMID) Support 2019-02-04 10:56:41 -08:00
tlbex-fault.S MIPS: Add DWARF unwinding to assembly 2017-09-06 11:01:52 +02:00
tlbex.c MIPS: tlbex: Fix build_restore_pagemask KScratch restore 2019-10-23 21:12:49 -07:00
uasm-micromips.c mips: bpf: implement jitting of BPF_ALU | BPF_ARSH | BPF_X 2018-12-07 13:30:48 -08:00
uasm-mips.c MIPS: uasm: Add div, mul and sel instructions for mipsr6 2019-03-19 15:26:06 -07:00
uasm.c MIPS: uasm: Add div, mul and sel instructions for mipsr6 2019-03-19 15:26:06 -07:00