linux-stable/arch
Baolin Wang ae07562909 mm: change huge_ptep_clear_flush() to return the original pte
Patch series "Fix CONT-PTE/PMD size hugetlb issue when unmapping or migrating", v4.

presently, migrating a hugetlb page or unmapping a poisoned hugetlb page,
we'll use ptep_clear_flush() and set_pte_at() to nuke the page table entry
and remap it, and this is incorrect for CONT-PTE or CONT-PMD size hugetlb
page, which will cause potential data consistent issue.  This patch set
will change to use hugetlb related APIs to fix this issue.

Note: Mike pointed out the huge_ptep_get() will only return the one
specific value, and it would not take into account the dirty or young bits
of CONT-PTE/PMDs like the huge_ptep_get_and_clear() [1].  This
inconsistent issue is not introduced by this patch set, and this issue
will be addressed in another thread [2].  Meanwhile the uffd for hugetlb
case [3] pointed out by Gerald also needs another patch to address.

[1] https://lore.kernel.org/linux-mm/85bd80b4-b4fd-0d3f-a2e5-149559f2f387@oracle.com/
[2] https://lore.kernel.org/all/cover.1651998586.git.baolin.wang@linux.alibaba.com/
[3] https://lore.kernel.org/linux-mm/20220503120343.6264e126@thinkpad/


This patch (of 3):

It is incorrect to use ptep_clear_flush() to nuke a hugetlb page table
when unmapping or migrating a hugetlb page, and will change to use
huge_ptep_clear_flush() instead in the following patches.

So this is a preparation patch, which changes the huge_ptep_clear_flush()
to return the original pte to help to nuke a hugetlb page table.

[baolin.wang@linux.alibaba.com: fix build in several more architectures]
  Link: https://lkml.kernel.org/r/0009a4cd-2826-e8be-e671-f050d4f18d5d@linux.alibaba.com
[sfr@canb.auug.org.au: fixup]
  Link: https://lkml.kernel.org/r/20220511181531.7f27a5c1@canb.auug.org.au
Link: https://lkml.kernel.org/r/cover.1652270205.git.baolin.wang@linux.alibaba.com
Link: https://lkml.kernel.org/r/20f77ddab90baa249bd24504c413189b82acde69.1652270205.git.baolin.wang@linux.alibaba.com
Link: https://lkml.kernel.org/r/cover.1652147571.git.baolin.wang@linux.alibaba.com
Link: https://lkml.kernel.org/r/dcf065868cce35bceaf138613ad27f17bb7c0c19.1652147571.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Yoshinori Sato <ysato@users.osdn.me>
Cc: Rich Felker <dalias@libc.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-05-13 16:48:55 -07:00
..
alpha alpha: fix alloc_zeroed_user_highpage_movable() 2022-05-13 07:20:14 -07:00
arc ARC: remove redundant READ_ONCE() in cmpxchg loop 2022-04-18 14:47:05 -07:00
arm Pin control fixes for v5.18: 2022-04-26 16:34:11 -07:00
arm64 mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
csky printk: stop including cache.h from printk.h 2022-05-13 07:20:07 -07:00
h8300 Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2022-04-01 19:57:03 -07:00
hexagon ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
ia64 mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
m68k Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2022-04-01 19:57:03 -07:00
microblaze Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
mips mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
nios2 ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
openrisc ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
parisc mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
powerpc mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
riscv riscv/mm: enable ARCH_SUPPORTS_PAGE_TABLE_CHECK 2022-05-13 07:20:17 -07:00
s390 mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
sh mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
sparc mm: change huge_ptep_clear_flush() to return the original pte 2022-05-13 16:48:55 -07:00
um Kbuild fixes for v5.18 2022-04-02 12:33:31 -07:00
x86 mm: functions may simplify the use of return values 2022-05-13 07:20:18 -07:00
xtensa xtensa: fix a7 clobbering in coprocessor context load/store 2022-04-15 18:44:02 -07:00
.gitignore
Kconfig vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP 2022-04-19 12:08:57 -07:00