Pull hotfixes from Andrew Morton: "Mainly MM fixes. About half for issues which were introduced after 5.18 and the remainder for longer-term issues" * tag 'mm-hotfixes-stable-2022-07-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: mm: split huge PUD on wp_huge_pud fallback nilfs2: fix incorrect masking of permission flags for symlinks mm/rmap: fix dereferencing invalid subpage pointer in try_to_migrate_one() riscv/mm: fix build error while PAGE_TABLE_CHECK enabled without MMU Documentation: highmem: use literal block for code example in highmem.h comment mm: sparsemem: fix missing higher order allocation splitting mm/damon: use set_huge_pte_at() to make huge pte old sh: convert nommu io{re,un}map() to static inline functions mm: userfaultfd: fix UFFDIO_CONTINUE on fallocated shmem pages
Unified · Split
| @@ -38,7 +38,7 @@ config RISCV · 37 unmodified lines | ||
| 38 | 38 | select ARCH_SUPPORTS_ATOMIC_RMW |
| 39 | 39 | select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU |
| 40 | 40 | select ARCH_SUPPORTS_HUGETLBFS if MMU |
| 41 | − select ARCH_SUPPORTS_PAGE_TABLE_CHECK | |
| 41 | + select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU | |
| 42 | 42 | select ARCH_USE_MEMTEST |
| 43 | 43 | select ARCH_USE_QUEUED_RWLOCKS |
| 44 | 44 | select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU |
| @@ -271,8 +271,12 @@ static inline void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, · 270 unmodified lines | ||
| 271 | 271 | #endif /* CONFIG_HAVE_IOREMAP_PROT */ |
| 272 | 272 | |
| 273 | 273 | #else /* CONFIG_MMU */ |
| 274 | −#define iounmap(addr) do { } while (0) | |
| 275 | −#define ioremap(offset, size) ((void __iomem *)(unsigned long)(offset)) | |
| 274 | +static inline void __iomem *ioremap(phys_addr_t offset, size_t size) | |
| 275 | +{ | |
| 276 | + return (void __iomem *)(unsigned long)offset; | |
| 277 | +} | |
| 278 | + | |
| 279 | +static inline void iounmap(volatile void __iomem *addr) { } | |
| 276 | 280 | #endif /* CONFIG_MMU */ |
| 277 | 281 | |
| 278 | 282 | #define ioremap_uc ioremap |
| @@ -198,6 +198,9 @@ static inline int nilfs_acl_chmod(struct inode *inode) · 197 unmodified lines | ||
| 198 | 198 | |
| 199 | 199 | static inline int nilfs_init_acl(struct inode *inode, struct inode *dir) |
| 200 | 200 | { |
| 201 | + if (S_ISLNK(inode->i_mode)) | |
| 202 | + return 0; | |
| 203 | + | |
| 201 | 204 | inode->i_mode &= ~current_umask(); |
| 202 | 205 | return 0; |
| 203 | 206 | } |
| @@ -149,19 +149,19 @@ static inline void *kmap_local_folio(struct folio *folio, size_t offset); · 148 unmodified lines | ||
| 149 | 149 | * It is used in atomic context when code wants to access the contents of a |
| 150 | 150 | * page that might be allocated from high memory (see __GFP_HIGHMEM), for |
| 151 | 151 | * example a page in the pagecache. The API has two functions, and they |
| 152 | − * can be used in a manner similar to the following: | |
| 152 | + * can be used in a manner similar to the following:: | |
| 153 | 153 | * |
| 154 | − * -- Find the page of interest. -- | |
| 155 | − * struct page *page = find_get_page(mapping, offset); | |
| 154 | + * // Find the page of interest. | |
| 155 | + * struct page *page = find_get_page(mapping, offset); | |
| 156 | 156 | * |
| 157 | − * -- Gain access to the contents of that page. -- | |
| 158 | − * void *vaddr = kmap_atomic(page); | |
| 157 | + * // Gain access to the contents of that page. | |
| 158 | + * void *vaddr = kmap_atomic(page); | |
| 159 | 159 | * |
| 160 | − * -- Do something to the contents of that page. -- | |
| 161 | − * memset(vaddr, 0, PAGE_SIZE); | |
| 160 | + * // Do something to the contents of that page. | |
| 161 | + * memset(vaddr, 0, PAGE_SIZE); | |
| 162 | 162 | * |
| 163 | − * -- Unmap that page. -- | |
| 164 | − * kunmap_atomic(vaddr); | |
| 163 | + * // Unmap that page. | |
| 164 | + * kunmap_atomic(vaddr); | |
| 165 | 165 | * |
| 166 | 166 | * Note that the kunmap_atomic() call takes the result of the kmap_atomic() |
| 167 | 167 | * call, not the argument. |
| @@ -336,8 +336,7 @@ static void damon_hugetlb_mkold(pte_t *pte, struct mm_struct *mm, · 335 unmodified lines | ||
| 336 | 336 | if (pte_young(entry)) { |
| 337 | 337 | referenced = true; |
| 338 | 338 | entry = pte_mkold(entry); |
| 339 | − huge_ptep_set_access_flags(vma, addr, pte, entry, | |
| 340 | − vma->vm_flags & VM_WRITE); | |
| 339 | + set_huge_pte_at(mm, addr, pte, entry); | |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | #ifdef CONFIG_MMU_NOTIFIER |
| @@ -4798,6 +4798,19 @@ static inline vm_fault_t wp_huge_pmd(struct vm_fault *vmf) · 4797 unmodified lines | ||
| 4798 | 4798 | |
| 4799 | 4799 | static vm_fault_t create_huge_pud(struct vm_fault *vmf) |
| 4800 | 4800 | { |
| 4801 | +#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \ | |
| 4802 | + defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) | |
| 4803 | + /* No support for anonymous transparent PUD pages yet */ | |
| 4804 | + if (vma_is_anonymous(vmf->vma)) | |
| 4805 | + return VM_FAULT_FALLBACK; | |
| 4806 | + if (vmf->vma->vm_ops->huge_fault) | |
| 4807 | + return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD); | |
| 4808 | +#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4809 | + return VM_FAULT_FALLBACK; | |
| 4810 | +} | |
| 4811 | + | |
| 4812 | +static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud) | |
| 4813 | +{ | |
| 4801 | 4814 | #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && \ |
| 4802 | 4815 | defined(CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD) |
| 4803 | 4816 | /* No support for anonymous transparent PUD pages yet */ |
| @@ -4812,19 +4825,7 @@ static vm_fault_t create_huge_pud(struct vm_fault *vmf) · 8 unmodified lines | ||
| 4812 | 4825 | split: |
| 4813 | 4826 | /* COW or write-notify not handled on PUD level: split pud.*/ |
| 4814 | 4827 | __split_huge_pud(vmf->vma, vmf->pud, vmf->address); |
| 4815 | −#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4816 | − return VM_FAULT_FALLBACK; | |
| 4817 | −} | |
| 4818 | − | |
| 4819 | −static vm_fault_t wp_huge_pud(struct vm_fault *vmf, pud_t orig_pud) | |
| 4820 | −{ | |
| 4821 | −#ifdef CONFIG_TRANSPARENT_HUGEPAGE | |
| 4822 | − /* No support for anonymous transparent PUD pages yet */ | |
| 4823 | − if (vma_is_anonymous(vmf->vma)) | |
| 4824 | − return VM_FAULT_FALLBACK; | |
| 4825 | − if (vmf->vma->vm_ops->huge_fault) | |
| 4826 | − return vmf->vma->vm_ops->huge_fault(vmf, PE_SIZE_PUD); | |
| 4827 | −#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | |
| 4828 | +#endif /* CONFIG_TRANSPARENT_HUGEPAGE && CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ | |
| 4828 | 4829 | return VM_FAULT_FALLBACK; |
| 4829 | 4830 | } |
| 4830 | 4831 | |
| @@ -1899,8 +1899,23 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, · 1898 unmodified lines | ||
| 1899 | 1899 | /* Unexpected PMD-mapped THP? */ |
| 1900 | 1900 | VM_BUG_ON_FOLIO(!pvmw.pte, folio); |
| 1901 | 1901 | |
| 1902 | − subpage = folio_page(folio, | |
| 1903 | − pte_pfn(*pvmw.pte) - folio_pfn(folio)); | |
| 1902 | + if (folio_is_zone_device(folio)) { | |
| 1903 | + /* | |
| 1904 | + * Our PTE is a non-present device exclusive entry and | |
| 1905 | + * calculating the subpage as for the common case would | |
| 1906 | + * result in an invalid pointer. | |
| 1907 | + * | |
| 1908 | + * Since only PAGE_SIZE pages can currently be | |
| 1909 | + * migrated, just set it to page. This will need to be | |
| 1910 | + * changed when hugepage migrations to device private | |
| 1911 | + * memory are supported. | |
| 1912 | + */ | |
| 1913 | + VM_BUG_ON_FOLIO(folio_nr_pages(folio) > 1, folio); | |
| 1914 | + subpage = &folio->page; | |
| 1915 | + } else { | |
| 1916 | + subpage = folio_page(folio, | |
| 1917 | + pte_pfn(*pvmw.pte) - folio_pfn(folio)); | |
| 1918 | + } | |
| 1904 | 1919 | address = pvmw.address; |
| 1905 | 1920 | anon_exclusive = folio_test_anon(folio) && |
| 1906 | 1921 | PageAnonExclusive(subpage); |
| @@ -1993,15 +2008,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, · 86 unmodified lines | ||
| 1993 | 2008 | /* |
| 1994 | 2009 | * No need to invalidate here it will synchronize on |
| 1995 | 2010 | * against the special swap migration pte. |
| 1996 | − * | |
| 1997 | − * The assignment to subpage above was computed from a | |
| 1998 | − * swap PTE which results in an invalid pointer. | |
| 1999 | − * Since only PAGE_SIZE pages can currently be | |
| 2000 | − * migrated, just set it to page. This will need to be | |
| 2001 | − * changed when hugepage migrations to device private | |
| 2002 | − * memory are supported. | |
| 2003 | 2011 | */ |
| 2004 | − subpage = &folio->page; | |
| 2005 | 2012 | } else if (PageHWPoison(subpage)) { |
| 2006 | 2013 | pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); |
| 2007 | 2014 | if (folio_test_hugetlb(folio)) { |
| @@ -78,6 +78,14 @@ static int __split_vmemmap_huge_pmd(pmd_t *pmd, unsigned long start) · 77 unmodified lines | ||
| 78 | 78 | |
| 79 | 79 | spin_lock(&init_mm.page_table_lock); |
| 80 | 80 | if (likely(pmd_leaf(*pmd))) { |
| 81 | + /* | |
| 82 | + * Higher order allocations from buddy allocator must be able to | |
| 83 | + * be treated as indepdenent small pages (as they can be freed | |
| 84 | + * individually). | |
| 85 | + */ | |
| 86 | + if (!PageReserved(page)) | |
| 87 | + split_page(page, get_order(PMD_SIZE)); | |
| 88 | + | |
| 81 | 89 | /* Make pte visible before pmd. See comment in pmd_install(). */ |
| 82 | 90 | smp_wmb(); |
| 83 | 91 | pmd_populate_kernel(&init_mm, pmd, pgtable); |
| @@ -246,7 +246,10 @@ static int mcontinue_atomic_pte(struct mm_struct *dst_mm, · 245 unmodified lines | ||
| 246 | 246 | struct page *page; |
| 247 | 247 | int ret; |
| 248 | 248 | |
| 249 | − ret = shmem_getpage(inode, pgoff, &page, SGP_READ); | |
| 249 | + ret = shmem_getpage(inode, pgoff, &page, SGP_NOALLOC); | |
| 250 | + /* Our caller expects us to return -EFAULT if we failed to find page. */ | |
| 251 | + if (ret == -ENOENT) | |
| 252 | + ret = -EFAULT; | |
| 250 | 253 | if (ret) |
| 251 | 254 | goto out; |
| 252 | 255 | if (!page) { |