linux/arch
Michael Ellerman 2675c13b29 powerpc/mm/radix: Fix checkstops caused by invalid tlbiel
In tlbiel_radix_set_isa300() we use the PPC_TLBIEL() macro to
construct tlbiel instructions. The instruction takes 5 fields, two of
which are registers, and the others are constants. But because it's
constructed with inline asm the compiler doesn't know that.

We got the constraint wrong on the 'r' field, using "r" tells the
compiler to put the value in a register. The value we then get in the
macro is the *register number*, not the value of the field.

That means when we mask the register number with 0x1 we get 0 or 1
depending on which register the compiler happens to put the constant
in, eg:

  li      r10,1
  tlbiel  r8,r9,2,0,0

  li      r7,1
  tlbiel  r10,r6,0,0,1

If we're unlucky we might generate an invalid instruction form, for
example RIC=0, PRS=1 and R=0, tlbiel r8,r7,0,1,0, this has been
observed to cause machine checks:

  Oops: Machine check, sig: 7 [#1]
  CPU: 24 PID: 0 Comm: swapper
  NIP:  00000000000385f4 LR: 000000000100ed00 CTR: 000000000000007f
  REGS: c00000000110bb40 TRAP: 0200
  MSR:  9000000000201003 <SF,HV,ME,RI,LE>  CR: 48002222  XER: 20040000
  CFAR: 00000000000385d0 DAR: 0000000000001c00 DSISR: 00000200 SOFTE: 1

If the machine check happens early in boot while we have MSR_ME=0 it
will escalate into a checkstop and kill the box entirely.

To fix it we could change the inline asm constraint to "i" which
tells the compiler the value is a constant. But a better fix is to just
pass a literal 1 into the macro, which bypasses any problems with inline
asm constraints.

Fixes: d4748276ae ("powerpc/64s: Improve local TLB flush for boot and MCE on POWER9")
Cc: stable@vger.kernel.org # v4.16+
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
2018-04-12 23:49:55 +10:00
..
alpha Merge branch 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux 2018-04-02 21:22:12 -07:00
arc Merge branch 'akpm' (patches from Andrew) 2018-04-06 14:19:26 -07:00
arm Merge branch 'akpm' (patches from Andrew) 2018-04-06 14:19:26 -07:00
arm64 ARM: SoC platform updates for 4.17 2018-04-05 21:21:08 -07:00
c6x
h8300 h8300: remove extraneous __BIG_ENDIAN definition 2018-03-22 17:07:01 -07:00
hexagon
ia64 pci-v4.17-changes 2018-04-06 18:31:06 -07:00
m68k Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2018-04-05 20:33:38 -07:00
microblaze Merge branch 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux 2018-04-02 21:22:12 -07:00
mips mm: fix races between swapoff and flush dcache 2018-04-05 21:36:26 -07:00
nds32 nds32: To use the generic dump_stack() 2018-03-16 15:45:23 +08:00
nios2 mm: fix races between swapoff and flush dcache 2018-04-05 21:36:26 -07:00
openrisc Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2018-04-04 15:19:26 -07:00
parisc mm: fix races between swapoff and flush dcache 2018-04-05 21:36:26 -07:00
powerpc powerpc/mm/radix: Fix checkstops caused by invalid tlbiel 2018-04-12 23:49:55 +10:00
riscv RISC-V changes for 4.17 2018-04-04 16:43:47 -07:00
s390 headers: untangle kmemleak.h from mm.h 2018-04-05 21:36:27 -07:00
sh mm: fix races between swapoff and flush dcache 2018-04-05 21:36:26 -07:00
sparc pci-v4.17-changes 2018-04-06 18:31:06 -07:00
um mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff() 2018-04-02 20:16:11 +02:00
unicore32 mm: fix races between swapoff and flush dcache 2018-04-05 21:36:26 -07:00
x86 Merge branch 'akpm' (patches from Andrew) 2018-04-06 14:19:26 -07:00
xtensa pci-v4.17-changes 2018-04-06 18:31:06 -07:00
.gitignore
Kconfig kbuild: remove incremental linking option 2018-03-26 02:01:19 +09:00