forked from mirrors/linux
		
	mm: userfaultfd: support UFFDIO_POISON for hugetlbfs
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/20230707215540.2324998-6-axelrasmussen@google.com Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> Acked-by: Peter Xu <peterx@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Brian Geffon <bgeffon@google.com> Cc: Christian Brauner <brauner@kernel.org> Cc: David Hildenbrand <david@redhat.com> Cc: Gaosheng Cui <cuigaosheng1@huawei.com> Cc: Huang, Ying <ying.huang@intel.com> Cc: Hugh Dickins <hughd@google.com> Cc: James Houghton <jthoughton@google.com> Cc: Jan Alexander Steffens (heftig) <heftig@archlinux.org> Cc: Jiaqi Yan <jiaqiyan@google.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Kefeng Wang <wangkefeng.wang@huawei.com> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Miaohe Lin <linmiaohe@huawei.com> Cc: Mike Kravetz <mike.kravetz@oracle.com> Cc: Mike Rapoport (IBM) <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nadav Amit <namit@vmware.com> Cc: Naoya Horiguchi <naoya.horiguchi@nec.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Suleiman Souhlal <suleiman@google.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: T.J. Alumbaugh <talumbau@google.com> Cc: Yu Zhao <yuzhao@google.com> Cc: ZhangPeng <zhangpeng362@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									597425df4f
								
							
						
					
					
						commit
						8a13897fb0
					
				
					 2 changed files with 20 additions and 2 deletions
				
			
		
							
								
								
									
										19
									
								
								mm/hugetlb.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								mm/hugetlb.c
									
									
									
									
									
								
							|  | @ -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); | ||||
|  |  | |||
|  | @ -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; | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Axel Rasmussen
						Axel Rasmussen