David Hildenbrand 5c8323a24d mm/userfaultfd: Do not place zeropages when zeropages are disallowed
[ Upstream commit 90a7592da14951bd21f74a53246ba30955a648aa ]

s390x must disable shared zeropages for processes running VMs, because
the VMs could end up making use of "storage keys" or protected
virtualization, which are incompatible with shared zeropages.

Yet, with userfaultfd it is possible to insert shared zeropages into
such processes. Let's fallback to simply allocating a fresh zeroed
anonymous folio and insert that instead.

mm_forbids_zeropage() was introduced in commit 593befa6ab74 ("mm: introduce
mm_forbids_zeropage function"), briefly before userfaultfd went
upstream.

Note that we don't want to fail the UFFDIO_ZEROPAGE request like we do
for hugetlb, it would be rather unexpected. Further, we also
cannot really indicated "not supported" to user space ahead of time: it
could be that the MM disallows zeropages after userfaultfd was already
registered.

[ agordeev: Fixed checkpatch complaints ]

Fixes: c1a4de99fada ("userfaultfd: mcopy_atomic|mfill_zeropage: UFFDIO_COPY|UFFDIO_ZEROPAGE preparation")
Reviewed-by: Peter Xu <peterx@redhat.com>
Link: https://lore.kernel.org/r/20240411161441.910170-2-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-05-30 09:49:00 +02:00
..
2024-04-03 15:32:39 +02:00
2023-12-12 10:11:32 +01:00
2024-01-18 15:16:57 -08:00
2024-01-10 16:43:55 -08:00
2023-04-12 17:36:23 -07:00
2024-02-24 15:53:40 -08:00
2022-10-03 14:02:43 -07:00
2024-02-10 08:02:48 -08:00
2024-05-30 09:48:59 +02:00
2023-06-23 16:59:30 -07:00
2023-04-12 17:36:23 -07:00