OpenCloudOS-Kernel/arch/powerpc/mm
Nicholas Piggin 33258a1db1 powerpc/64s: Fix THP PMD collapse serialisation
Commit 1b2443a547 ("powerpc/book3s64: Avoid multiple endian
conversion in pte helpers") changed the actual bitwise tests in
pte_access_permitted by using pte_write() and pte_present() helpers
rather than raw bitwise testing _PAGE_WRITE and _PAGE_PRESENT bits.

The pte_present() change now returns true for PTEs which are
!_PAGE_PRESENT and _PAGE_INVALID, which is the combination used by
pmdp_invalidate() to synchronize access from lock-free lookups.
pte_access_permitted() is used by pmd_access_permitted(), so allowing
GUP lock free access to proceed with such PTEs breaks this
synchronisation.

This bug has been observed on a host using the hash page table MMU,
with random crashes and corruption in guests, usually together with
bad PMD messages in the host.

Fix this by adding an explicit check in pmd_access_permitted(), and
documenting the condition explicitly.

The pte_write() change should be okay, and would prevent GUP from
falling back to the slow path when encountering savedwrite PTEs, which
matches what x86 (that does not implement savedwrite) does.

Fixes: 1b2443a547 ("powerpc/book3s64: Avoid multiple endian conversion in pte helpers")
Cc: stable@vger.kernel.org # v4.20+
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2019-06-07 16:26:44 +10:00
..
book3s32 powerpc/32s: fix flush_hash_pages() on SMP 2019-05-14 22:58:52 +10:00
book3s64 powerpc/64s: Fix THP PMD collapse serialisation 2019-06-07 16:26:44 +10:00
kasan powerpc/kasan: add missing/lost Makefile 2019-05-06 20:21:34 +10:00
nohash powerpc/book3e: move early_alloc_pgtable() to init section 2019-05-03 01:20:24 +10:00
ptdump powerpc/mm: Warn if W+X pages found on boot 2019-05-03 02:54:45 +10:00
Makefile powerpc/mm: fix redundant inclusion of pgtable-frag.o in Makefile 2019-05-06 20:21:56 +10:00
copro_fault.c powerpc/mm/hash: Rename KERNEL_REGION_ID to LINEAR_MAP_REGION_ID 2019-04-21 23:12:40 +10:00
dma-noncoherent.c powerpc/mm: change #include "mmu_decl.h" to <mm/mmu_decl.h> 2019-05-02 21:18:58 +10:00
drmem.c powerpc/pseries: Track LMB nid instead of using device tree 2019-04-29 22:27:16 +10:00
fault.c powerpc/mm: Detect bad KUAP faults 2019-04-21 23:06:04 +10:00
highmem.c powerpc/highmem: Change BUG_ON() to WARN_ON() 2019-04-20 22:02:11 +10:00
hugetlbpage.c powerpc/mm: Fix crashes with hugepages & 4K pages 2019-05-15 11:13:35 +10:00
init-common.c powerpc/mm: fix section mismatch for setup_kup() 2019-05-06 20:21:56 +10:00
init_32.c powerpc/32: Add KASAN support 2019-05-03 01:20:26 +10:00
init_64.c powerpc/mm: change #include "mmu_decl.h" to <mm/mmu_decl.h> 2019-05-02 21:18:58 +10:00
mem.c mm/memory_hotplug: make __remove_pages() and arch_remove_memory() never fail 2019-05-14 09:47:50 -07:00
mmap.c exec: pass stack rlimit into mm layout functions 2018-04-11 10:28:37 -07:00
mmu_context.c powerpc/mm: convert Book3E 64 to pte_fragment 2019-05-03 01:20:24 +10:00
mmu_decl.h powerpc/mm: print hash info in a helper 2019-05-03 01:20:26 +10:00
numa.c powerpc/mm: Move book3s64 specifics in subdirectory mm/book3s64 2019-05-03 01:18:38 +10:00
pgtable-frag.c mm: treewide: remove unused address argument from pte_alloc functions 2019-01-04 13:13:47 -08:00
pgtable.c powerpc/mm: flatten function __find_linux_pte() step 3 2019-05-03 01:20:24 +10:00
pgtable_32.c powerpc/mm: Warn if W+X pages found on boot 2019-05-03 02:54:45 +10:00
pgtable_64.c powerpc/mm: Warn if W+X pages found on boot 2019-05-03 02:54:45 +10:00
slice.c powerpc/mm: define subarch SLB_ADDR_LIMIT_DEFAULT 2019-05-03 01:20:23 +10:00