mm: add early FAULT_FLAG_UNSHARE consistency checks
authorDavid Hildenbrand <david@redhat.com>
Wed, 16 Nov 2022 10:26:43 +0000 (11:26 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 30 Nov 2022 23:58:57 +0000 (15:58 -0800)
commitcdc5021cda194112bc0962d6a0e90b379968c504
tree12c5231ee46f8a17f2b12d6c80a021c866d2723b
parent97713a3abe338bb6c968e77264edbb68eb8d932a
mm: add early FAULT_FLAG_UNSHARE consistency checks

For now, FAULT_FLAG_UNSHARE only applies to anonymous pages, which
implies a COW mapping. Let's hide FAULT_FLAG_UNSHARE early if we're not
dealing with a COW mapping, such that we treat it like a read fault as
documented and don't have to worry about the flag throughout all fault
handlers.

While at it, centralize the check for mutual exclusion of
FAULT_FLAG_UNSHARE and FAULT_FLAG_WRITE and just drop the check that
either flag is set in the WP handler.

Link: https://lkml.kernel.org/r/20221116102659.70287-5-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/huge_memory.c
mm/hugetlb.c
mm/memory.c