kernel_optimize_test/arch/mips
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
..
alchemy
ar7
ath25
ath79
bcm47xx MIPS: BCM47XX: Add support for Netgear R6200 V1 2019-07-25 22:10:05 -07:00
bcm63xx MIPS: bmips: mark exception vectors as char arrays 2019-10-23 21:07:28 -07:00
bmips
boot MIPS: dts: ar9331: fix interrupt-controller size 2019-09-30 15:22:35 -07:00
cavium-octeon Main MIPS changes for v5.4: 2019-09-22 09:30:30 -07:00
cobalt
configs USB: rio500: Remove Rio 500 kernel driver 2019-10-04 10:53:36 +02:00
crypto
dec
emma
fw MIPS: fw: sni: Fix out of bounds init of o32 stack 2019-10-09 12:47:28 -07:00
generic
include MIPS: bmips: mark exception vectors as char arrays 2019-10-23 21:07:28 -07:00
jazz dma-mapping: explicitly wire up ->mmap and ->get_sgtable 2019-09-04 11:13:18 +02:00
jz4740 Merge branch 'ingenic-tcu-v5.4' into mips-next 2019-08-08 15:33:16 -07:00
kernel MIPS: bmips: mark exception vectors as char arrays 2019-10-23 21:07:28 -07:00
kvm Bugfixes (arm and x86) and cleanups. 2019-08-09 15:46:29 -07:00
lantiq MIPS: lantiq: update the clock alias' for the mainline PCIe PHY driver 2019-08-24 15:13:22 +01:00
lasat
lib
loongson32
loongson64 MIPS: Disable Loongson MMI instructions for kernel build 2019-10-10 11:58:52 -07:00
math-emu
mm MIPS: tlbex: Fix build_restore_pagemask KScratch restore 2019-10-23 21:12:49 -07:00
mti-malta MIPS: malta: Drop prom_free_prom_memory 2019-08-23 14:47:13 +01:00
net
netlogic MIPS: xlp: Drop boot_mem_map 2019-08-23 14:47:21 +01:00
oprofile MIPS: OProfile: Mark expected switch fall-throughs 2019-07-30 09:40:17 -07:00
paravirt
pci Main MIPS changes for v5.4: 2019-09-22 09:30:30 -07:00
pic32
pistachio
pmcs-msp71xx MIPS: pmcs-msp71xx: Remove unused addr variable 2019-10-03 15:47:17 -07:00
pnx833x
power
ralink MIPS: ralink: deactivate PCI support for SOC_MT7621 2019-09-06 08:45:03 -07:00
rb532
sgi-ip22 MIPS: ip22: Drop addr_is_ram 2019-08-23 14:47:18 +01:00
sgi-ip27 MIPS: SGI-IP27: restructure ioc3 register access 2019-08-30 13:54:35 -07:00
sgi-ip32
sibyte
sni
tools
txx9
vdso MIPS: Disable Loongson MMI instructions for kernel build 2019-10-10 11:58:52 -07:00
vr41xx
Kbuild
Kbuild.platforms
Kconfig mips: use generic mmap top-down layout and brk randomization 2019-09-24 15:54:12 -07:00
Kconfig.debug
Makefile MIPS: Remove unused R8000 CPU support 2019-07-23 14:33:51 -07:00
Makefile.postlink