]> Git Repo - linux.git/commitdiff
mm: userfaultfd: support UFFDIO_POISON for hugetlbfs
authorAxel Rasmussen <[email protected]>
Fri, 7 Jul 2023 21:55:37 +0000 (14:55 -0700)
committerAndrew Morton <[email protected]>
Fri, 18 Aug 2023 17:12:17 +0000 (10:12 -0700)
The behavior here is the same as it is for anon/shmem.  This is done
separately because hugetlb pte marker handling is a bit different.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Axel Rasmussen <[email protected]>
Acked-by: Peter Xu <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Brian Geffon <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Gaosheng Cui <[email protected]>
Cc: Huang, Ying <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: James Houghton <[email protected]>
Cc: Jan Alexander Steffens (heftig) <[email protected]>
Cc: Jiaqi Yan <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Kefeng Wang <[email protected]>
Cc: Liam R. Howlett <[email protected]>
Cc: Miaohe Lin <[email protected]>
Cc: Mike Kravetz <[email protected]>
Cc: Mike Rapoport (IBM) <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Nadav Amit <[email protected]>
Cc: Naoya Horiguchi <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Suleiman Souhlal <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: T.J. Alumbaugh <[email protected]>
Cc: Yu Zhao <[email protected]>
Cc: ZhangPeng <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/hugetlb.c
mm/userfaultfd.c

index ffee2978dfed4ba367f466977c51e414e022fe6c..7b076eb07a290e4bd71ad5d6755006a3b39e6132 100644 (file)
@@ -6262,6 +6262,25 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_pte,
        int writable;
        bool folio_in_pagecache = false;
 
+       if (uffd_flags_mode_is(flags, MFILL_ATOMIC_POISON)) {
+               ptl = huge_pte_lock(h, dst_mm, dst_pte);
+
+               /* Don't overwrite any existing PTEs (even markers) */
+               if (!huge_pte_none(huge_ptep_get(dst_pte))) {
+                       spin_unlock(ptl);
+                       return -EEXIST;
+               }
+
+               _dst_pte = make_pte_marker(PTE_MARKER_POISONED);
+               set_huge_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);
+
+               /* No need to invalidate - it was non-present before */
+               update_mmu_cache(dst_vma, dst_addr, dst_pte);
+
+               spin_unlock(ptl);
+               return 0;
+       }
+
        if (is_continue) {
                ret = -EFAULT;
                folio = filemap_lock_folio(mapping, idx);
index dd167184575e2a398920332b6070e95e686199a3..0fc69efa4f1ff8a2acda394f501d1009c957d1ae 100644 (file)
@@ -377,8 +377,7 @@ static __always_inline ssize_t mfill_atomic_hugetlb(
         * by THP.  Since we can not reliably insert a zero page, this
         * feature is not supported.
         */
-       if (uffd_flags_mode_is(flags, MFILL_ATOMIC_ZEROPAGE) ||
-           uffd_flags_mode_is(flags, MFILL_ATOMIC_POISON)) {
+       if (uffd_flags_mode_is(flags, MFILL_ATOMIC_ZEROPAGE)) {
                mmap_read_unlock(dst_mm);
                return -EINVAL;
        }
This page took 0.072204 seconds and 4 git commands to generate.