Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64/mm: drop HAVE_ARCH_PFN_VALID

CONFIG_SPARSEMEM_VMEMMAP is now the only available memory model on arm64
platforms and free_unused_memmap() would just return without creating any
holes in the memmap mapping. There is no need for any special handling in
pfn_valid() and HAVE_ARCH_PFN_VALID can just be dropped. This also moves
the pfn upper bits sanity check into generic pfn_valid().

[rppt: rebased on v5.15-rc3]

Link: https://lkml.kernel.org/r/1621947349-25421-1-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Mike Rapoport <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Link: https://lore.kernel.org/r/20210930013039.11260-3-rppt@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Anshuman Khandual and committed by
Will Deacon
3de360c3 a9c38c5d

-39
-1
arch/arm64/Kconfig
··· 154 154 select HAVE_ARCH_KGDB 155 155 select HAVE_ARCH_MMAP_RND_BITS 156 156 select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT 157 - select HAVE_ARCH_PFN_VALID 158 157 select HAVE_ARCH_PREL32_RELOCATIONS 159 158 select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET 160 159 select HAVE_ARCH_SECCOMP_FILTER
-1
arch/arm64/include/asm/page.h
··· 41 41 42 42 typedef struct page *pgtable_t; 43 43 44 - int pfn_valid(unsigned long pfn); 45 44 int pfn_is_map_memory(unsigned long pfn); 46 45 47 46 #include <asm/memory.h>
-37
arch/arm64/mm/init.c
··· 160 160 free_area_init(max_zone_pfns); 161 161 } 162 162 163 - int pfn_valid(unsigned long pfn) 164 - { 165 - phys_addr_t addr = PFN_PHYS(pfn); 166 - struct mem_section *ms; 167 - 168 - /* 169 - * Ensure the upper PAGE_SHIFT bits are clear in the 170 - * pfn. Else it might lead to false positives when 171 - * some of the upper bits are set, but the lower bits 172 - * match a valid pfn. 173 - */ 174 - if (PHYS_PFN(addr) != pfn) 175 - return 0; 176 - 177 - if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS) 178 - return 0; 179 - 180 - ms = __pfn_to_section(pfn); 181 - if (!valid_section(ms)) 182 - return 0; 183 - 184 - /* 185 - * ZONE_DEVICE memory does not have the memblock entries. 186 - * memblock_is_map_memory() check for ZONE_DEVICE based 187 - * addresses will always fail. Even the normal hotplugged 188 - * memory will never have MEMBLOCK_NOMAP flag set in their 189 - * memblock entries. Skip memblock search for all non early 190 - * memory sections covering all of hotplug memory including 191 - * both normal and ZONE_DEVICE based. 192 - */ 193 - if (!early_section(ms)) 194 - return pfn_section_valid(ms, pfn); 195 - 196 - return memblock_is_memory(addr); 197 - } 198 - EXPORT_SYMBOL(pfn_valid); 199 - 200 163 int pfn_is_map_memory(unsigned long pfn) 201 164 { 202 165 phys_addr_t addr = PFN_PHYS(pfn);