linux-stable/arch
Nicholas Piggin 1455294939 powerpc/64s/hash: Make hash faults work in NMI context
[ Upstream commit 8b91cee5ea ]

Hash faults are not resoved in NMI context, instead causing the access
to fail. This is done because perf interrupts can get backtraces
including walking the user stack, and taking a hash fault on those could
deadlock on the HPTE lock if the perf interrupt hits while the same HPTE
lock is being held by the hash fault code. The user-access for the stack
walking will notice the access failed and deal with that in the perf
code.

The reason to allow perf interrupts in is to better profile hash faults.

The problem with this is any hash fault on a kernel access that happens
in NMI context will crash, because kernel accesses must not fail.

Hard lockups, system reset, machine checks that access vmalloc space
including modules and including stack backtracing and symbol lookup in
modules, per-cpu data, etc could all run into this problem.

Fix this by disallowing perf interrupts in the hash fault code (the
direct hash fault is covered by MSR[EE]=0 so the PMI disable just needs
to extend to the preload case). This simplifies the tricky logic in hash
faults and perf, at the cost of reduced profiling of hash faults.

perf can still latch addresses when interrupts are disabled, it just
won't get the stack trace at that point, so it would still find hot
spots, just sometimes with confusing stack chains.

An alternative could be to allow perf interrupts here but always do the
slowpath stack walk if we are in nmi context, but that slows down all
perf interrupt stack walking on hash though and it does not remove as
much tricky code.

Reported-by: Laurent Dufour <ldufour@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Laurent Dufour <ldufour@linux.ibm.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220204035348.545435-1-npiggin@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-13 19:27:18 +02:00
..
alpha bitmap patches for 5.17-rc1 2022-01-23 06:20:44 +02:00
arc uaccess: fix type mismatch warnings from access_ok() 2022-04-08 13:58:44 +02:00
arm ARM: dts: spear13xx: Update SPI dma properties 2022-04-08 13:59:03 +02:00
arm64 KVM: arm64: Do not change the PMU event filter after a VCPU has run 2022-04-13 19:27:13 +02:00
csky uaccess: fix type mismatch warnings from access_ok() 2022-04-08 13:58:44 +02:00
h8300 bitmap patches for 5.17-rc1 2022-01-23 06:20:44 +02:00
hexagon uaccess: fix integer overflow on access_ok() 2022-03-28 10:03:21 +02:00
ia64 ia64: make IA64_MCA_RECOVERY bool instead of tristate 2022-01-30 09:56:58 +02:00
m68k m68k: coldfire/device.c: only build for MCF_EDMA when h/w macros are defined 2022-04-08 13:57:51 +02:00
microblaze uaccess: fix nios2 and microblaze get_user_8() 2022-04-08 13:57:49 +02:00
mips mips: Enable KCSAN - take 2 2022-04-08 13:58:59 +02:00
nds32 nds32: fix access_ok() checks in get/put_user 2022-03-28 10:03:22 +02:00
nios2 uaccess: fix type mismatch warnings from access_ok() 2022-04-08 13:58:44 +02:00
openrisc bitmap patches for 5.17-rc1 2022-01-23 06:20:44 +02:00
parisc parisc: Fix handling off probe non-access faults 2022-04-08 13:58:38 +02:00
powerpc powerpc/64s/hash: Make hash faults work in NMI context 2022-04-13 19:27:18 +02:00
riscv riscv module: remove (NOLOAD) 2022-04-08 13:58:57 +02:00
s390 KVM: s390x: fix SCK locking 2022-04-08 13:57:30 +02:00
sh bitmap patches for 5.17-rc1 2022-01-23 06:20:44 +02:00
sparc uaccess: fix type mismatch warnings from access_ok() 2022-04-08 13:58:44 +02:00
um um: fix and optimize xor select template for CONFIG64 and timetravel mode 2022-04-13 19:27:06 +02:00
x86 x86/mce: Work around an erratum on fast string copy instructions 2022-04-13 19:27:16 +02:00
xtensa xtensa: add missing XCHAL_HAVE_WINDOWED check 2022-04-08 13:58:17 +02:00
.gitignore
Kconfig stack: Constrain and fix stack offset randomization with Clang builds 2022-04-08 13:57:34 +02:00