WSL2-Linux-Kernel/arch/powerpc/mm
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
..
book3s32 powerpc/32s: Fix kasan_init_region() for KASAN 2022-01-16 20:51:05 +11:00
book3s64 powerpc/64s/hash: Make hash faults work in NMI context 2022-02-24 12:46:54 +11:00
kasan powerpc/kasan: Fix early region not updated correctly 2022-02-03 22:37:44 +11:00
nohash powerpc updates for 5.17 2022-01-14 15:17:26 +01:00
ptdump powerpc/ptdump: Fix sparse warning in hashpagetable.c 2022-02-02 20:32:11 +11:00
Makefile powerpc/ptdump: Convert powerpc to GENERIC_PTDUMP 2021-08-25 13:35:48 +10:00
cacheflush.c powerpc/mem: Use kmap_local_page() in flushing functions 2021-04-14 23:04:19 +10:00
copro_fault.c powerpc/64s: Move hash MMU support code under CONFIG_PPC_64S_HASH_MMU 2021-12-09 22:41:13 +11:00
dma-noncoherent.c dma-mapping: merge <linux/dma-noncoherent.h> into <linux/dma-map-ops.h> 2020-10-06 07:07:06 +02:00
drmem.c pseries/drmem: update LMBs after LPM 2021-08-10 23:14:55 +10:00
fault.c Merge branch 'akpm' (patches from Andrew) 2022-01-15 20:37:06 +02:00
hugetlbpage.c powerpc/mm: Update default hugetlb size early 2022-02-12 22:47:44 +11:00
init-common.c powerpc/kuep: Remove 'nosmep' boot time parameter except for book3s/64 2021-12-09 22:41:18 +11:00
init_32.c powerpc: Enable KFENCE for PPC32 2021-03-24 14:09:30 +11:00
init_64.c powerpc/mm: Update default hugetlb size early 2022-02-12 22:47:44 +11:00
ioremap.c powerpc: make memremap_compat_align 64s-only 2021-12-02 22:57:24 +11:00
ioremap_32.c powerpc/mm: Leave a gap between early allocated IO areas 2021-06-25 00:07:10 +10:00
ioremap_64.c powerpc/mm: Leave a gap between early allocated IO areas 2021-06-25 00:07:10 +10:00
maccess.c powerpc/inst: Optimise copy_inst_from_kernel_nofault() 2021-12-09 22:41:21 +11:00
mem.c powerpc/code-patching: Remove init_mem_is_free 2021-12-23 22:35:24 +11:00
mmap.c powerpc/64s: Always define arch unmapped area calls 2021-12-09 22:40:24 +11:00
mmu_context.c powerpc/mm: Switch obsolete dssall to .long 2021-12-23 22:35:13 +11:00
mmu_decl.h powerpc/fsl_booke: Update of TLBCAMs after init 2021-10-22 15:22:03 +11:00
numa.c powerpc/mm: Add __init attribute to eligible functions 2021-12-23 22:33:11 +11:00
pageattr.c powerpc: Add set_memory_{p/np}() and remove set_memory_attr() 2022-02-12 22:47:42 +11:00
pgtable-frag.c powerpc/mm/radix: Fix PTE/PMD fragment count for early page table mappings 2020-07-20 22:57:56 +10:00
pgtable.c powerpc/fixmap: Fix VM debug warning on unmap 2022-01-24 17:29:05 +11:00
pgtable_32.c powerpc/32s: Enable STRICT_MODULE_RWX for the 603 core 2022-02-12 22:47:42 +11:00
pgtable_64.c powerpc/64s/radix: Fix huge vmap false positive 2021-12-20 12:13:32 +11:00
slice.c powerpc/64s: Always define arch unmapped area calls 2021-12-09 22:40:24 +11:00