powerpc: Fix kernel crash in show_instructions() w/DEBUG_VIRTUAL
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Sun, 24 May 2020 09:38:19 +0000 (15:08 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Jun 2020 15:50:45 +0000 (17:50 +0200)
commit7b307d292ab26ef6a9b85754a608aa2b5b607318
treeebf0e742b7d32e68a59b8ad3b6f80128aba46fad
parentf651e94899ed08b1766bda30f410d33fdd3970ff
powerpc: Fix kernel crash in show_instructions() w/DEBUG_VIRTUAL

[ Upstream commit a6e2c226c3d51fd93636320e47cabc8a8f0824c5 ]

With CONFIG_DEBUG_VIRTUAL=y, we can hit a BUG() if we take a hard
lockup watchdog interrupt when in OPAL mode.

This happens in show_instructions() if the kernel takes the watchdog
NMI IPI, or any other interrupt, with MSR_IR == 0. show_instructions()
updates the variable pc in the loop and the second iteration will
result in BUG().

We hit the BUG_ON due the below check in  __va()

  #define __va(x)
  ({
   VIRTUAL_BUG_ON((unsigned long)(x) >= PAGE_OFFSET);
   (void *)(unsigned long)((phys_addr_t)(x) | PAGE_OFFSET);
  })

Fix it by moving the check out of the loop. Also update nip so that
the nip == pc check still matches.

Fixes: 4dd7554a6456 ("powerpc/64: Add VIRTUAL_BUG_ON checks for __va and __pa addresses")
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
[mpe: Use IS_ENABLED(), massage change log]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200524093822.423487-1-aneesh.kumar@linux.ibm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/process.c