Merge 5.19-rc3 into staging-next
[linux-2.6-microblaze.git] / mm / memremap.c
index af02236..b870a65 100644 (file)
@@ -214,7 +214,7 @@ static int pagemap_range(struct dev_pagemap *pgmap, struct mhp_params *params,
 
        if (!mhp_range_allowed(range->start, range_len(range), !is_private)) {
                error = -EINVAL;
-               goto err_pfn_remap;
+               goto err_kasan;
        }
 
        mem_hotplug_begin();
@@ -287,6 +287,7 @@ void *memremap_pages(struct dev_pagemap *pgmap, int nid)
 {
        struct mhp_params params = {
                .altmap = pgmap_altmap(pgmap),
+               .pgmap = pgmap,
                .pgprot = PAGE_KERNEL,
        };
        const int nr_range = pgmap->nr_range;
@@ -458,6 +459,15 @@ void free_zone_device_page(struct page *page)
 
        mem_cgroup_uncharge(page_folio(page));
 
+       /*
+        * Note: we don't expect anonymous compound pages yet. Once supported
+        * and we could PTE-map them similar to THP, we'd have to clear
+        * PG_anon_exclusive on all tail pages.
+        */
+       VM_BUG_ON_PAGE(PageAnon(page) && PageCompound(page), page);
+       if (PageAnon(page))
+               __ClearPageAnonExclusive(page);
+
        /*
         * When a device managed page is freed, the page->mapping field
         * may still contain a (stale) mapping value. For example, the