]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64/mm: Check the requested PFN range during memory removal
authorRichard Cheng <icheng@nvidia.com>
Tue, 21 Jul 2026 10:00:26 +0000 (18:00 +0800)
committerWill Deacon <will@kernel.org>
Tue, 21 Jul 2026 15:21:11 +0000 (15:21 +0000)
prevent_memory_remove_notifier() advances pfn while scanning the requested
range for early memory. When the loop completes, pfn is at or beyond
end_pfn. Passing it to can_unmap_without_split() therefore checks a range
after the one being offlined.

Consequently, a valid request can be rejected based on the following
range, while a request that would split a leaf mapping can be accepted if
the shifted range can be unmapped without a split. This was observed with
CXL DAX memory, where the final memory block was incorrectly allowed to
be offlined.

Pass arg->start_pfn into can_unmap_without_split() so it checks the
requested range.

Fixes: 95a58852b0e5 ("arm64/mm: Reject memory removal that splits a kernel leaf mapping")
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/mm/mmu.c

index a25d8beacc8310d0dd08dfa0d43633bf0eb1b3dd..18a8b0d3714ee5c8f8ffa2efd5042e87e6648631 100644 (file)
@@ -2194,7 +2194,7 @@ static int prevent_memory_remove_notifier(struct notifier_block *nb,
                }
        }
 
-       if (!can_unmap_without_split(pfn, arg->nr_pages))
+       if (!can_unmap_without_split(arg->start_pfn, arg->nr_pages))
                return NOTIFY_BAD;
 
        return NOTIFY_OK;