linux/arch/powerpc/mm/book3s64
Nicholas Piggin 8b91cee5ea powerpc/64s/hash: Make hash faults work in NMI context
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
2022-02-24 12:46:54 +11:00
..
hash_4k.c powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation 2020-12-04 01:01:25 +11:00
hash_64k.c powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation 2020-12-04 01:01:25 +11:00
hash_hugepage.c powerpc/book3s64/kuap: Use Key 3 for kernel mapping with hash translation 2020-12-04 01:01:25 +11:00
hash_native.c powerpc/mm/book3s64/hash: Switch pre 2.06 tlbiel to .long 2021-12-23 22:35:13 +11:00
hash_pgtable.c powerpc/64s: move THP trace point creation out of hash specific file 2021-12-02 22:57:23 +11:00
hash_tlb.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
hash_utils.c powerpc/64s/hash: Make hash faults work in NMI context 2022-02-24 12:46:54 +11:00
hugetlbpage.c powerpc/mm: Update default hugetlb size early 2022-02-12 22:47:44 +11:00
internal.h powerpc/mm/64s: Fix no previous prototype warning 2021-02-11 23:28:51 +11:00
iommu_api.c powerpc/mm/book3s64/iommu: fix some RCU-list locks 2021-01-31 22:35:49 +11:00
Makefile powerpc/64s: Move hash MMU support code under CONFIG_PPC_64S_HASH_MMU 2021-12-09 22:41:13 +11:00
mmu_context.c powerpc/mm: Add __init attribute to eligible functions 2021-12-23 22:33:11 +11:00
pgtable.c powerpc/64s: Move hash MMU support code under CONFIG_PPC_64S_HASH_MMU 2021-12-09 22:41:13 +11:00
pkeys.c powerpc/mm: Add __init attribute to eligible functions 2021-12-23 22:33:11 +11:00
radix_hugetlbpage.c powerpc/book3s64/mm: update flush_tlb_range to flush page walk cache 2021-07-08 11:48:23 -07:00
radix_pgtable.c powerpc/mm: Add __init attribute to eligible functions 2021-12-23 22:33:11 +11:00
radix_tlb.c powerpc: rename powerpc_debugfs_root to arch_debugfs_dir 2021-08-13 22:04:26 +10:00
slb.c powerpc/64s: Move and rename do_bad_slb_fault as it is not hash specific 2021-12-02 22:57:23 +11:00
subpage_prot.c mmap locking API: convert mmap_sem comments 2020-06-09 09:39:14 -07:00
trace.c powerpc/64s: move THP trace point creation out of hash specific file 2021-12-02 22:57:23 +11:00