arm64: retry dropping HAVE_ARCH_PFN_VALID
Subsystems (2)
cover arm64: retry dropping HAVE_ARCH_PFN_VALID
From: Mike Rapoport <[email protected]>
Hi,
This is a new attempt to drop HAVE_ARCH_PFN_VALID on arm64 and start using the generic implementation of pfn_valid().
The first patch removes the check for pfn_valid() in dma_map_resource() which is required to avoid false positives when there is memory map for MMIO.
Anshuman Khandual (1):
arm64/mm: drop HAVE_ARCH_PFN_VALID
Mike Rapoport (1):
dma-mapping: remove bogus test for pfn_valid from dma_map_resource
arch/arm64/Kconfig | 1 - arch/arm64/include/asm/page.h | 1 - arch/arm64/mm/init.c | 37 ----------------------------------- kernel/dma/mapping.c | 4 ---- 4 files changed, 43 deletions(-)
base-commit: 5816b3e6577eaa676ceb00a848f0fd65fe2adc29
Signature · 1 line
2.28.0
PATCH 1/2 dma-mapping: remove bogus test for pfn_valid from dma_map_resource
From: Mike Rapoport <[email protected]>
dma_map_resource() uses pfn_valid() to ensure the range is not RAM. However, pfn_valid() only checks for availability of the memory map for a PFN but it does not ensure that the PFN is actually backed by RAM.
As dma_map_resource() is the only method in DMA mapping APIs that has this check, simply drop the pfn_valid() test from dma_map_resource().
--- kernel/dma/mapping.c | 4 ---- 1 file changed, 4 deletions(-)
kernel/dma/mapping.c +0 -4
@@ -296,10 +296,6 @@ dma_addr_t dma_map_resource(struct device *dev, phys_addr_t phys_addr,if (WARN_ON_ONCE (!dev->dma_mask))return DMA_MAPPING_ERROR ; -/* Don't allow RAM to be mapped */ -if (WARN_ON_ONCE (pfn_valid (PHYS_PFN (phys_addr)))) -return DMA_MAPPING_ERROR ; -if (dma_map_direct (dev, ops)) addr =dma_direct_map_resource (dev, phys_addr, size, dir, attrs);else if (ops->map_resource)
Signature · 1 line
2.28.0
Re: [PATCH 1/2] dma-mapping: remove bogus test for pfn_valid from dma_map_resource
Quoted 11 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
dma_map_resource()usespfn_valid()to ensure the range is not RAM. However,pfn_valid()only checks for availability of the memory map for a PFN but it does not ensure that the PFN is actually backed by RAM.As
dma_map_resource()is the only method in DMA mapping APIs that has this check, simply drop thepfn_valid()test fromdma_map_resource().
We'll lose a bit of a sanity check with this, but given the problems it caused:
Re: [PATCH 1/2] dma-mapping: remove bogus test for pfn_valid from dma_map_resource
In reply to Mike RapoportQuoted 6 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
dma_map_resource()usespfn_valid()to ensure the range is not RAM. However,pfn_valid()only checks for availability of the memory map for a PFN but it does not ensure that the PFN is actually backed by RAM.
Quoted 6 lines
As
dma_map_resource()is the only method in DMA mapping APIs that has this check, simply drop thepfn_valid()test fromdma_map_resource().Signed-off-by Mike Rapoport <[email protected]>---
Signature · 3 lines
Thanks, David / dhildenb
PATCH 2/2 arm64/mm: drop HAVE_ARCH_PFN_VALID
In reply to Mike RapoportFrom: Anshuman Khandual <[email protected]>
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]
--- arch/arm64/Kconfig | 1 - arch/arm64/include/asm/page.h | 1 - arch/arm64/mm/init.c | 37 ----------------------------------- 3 files changed, 39 deletions(-)
arch/arm64/Kconfig +0 -1
@@ -154,7 +154,6 @@ config ARM64 select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT - select HAVE_ARCH_PFN_VALID select HAVE_ARCH_PREL32_RELOCATIONS select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET select HAVE_ARCH_SECCOMP_FILTER
arch/arm64/include/asm/page.h +0 -1
@@ -41,7 +41,6 @@ void tag_clear_highpage(struct page *to);typedef struct page *pgtable_t ; -int pfn_valid (unsigned long pfn);int pfn_is_map_memory (unsigned long pfn);#include <asm/memory.h>
arch/arm64/mm/init.c +0 -37
@@ -160,43 +160,6 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)free_area_init (max_zone_pfns); } -int pfn_valid (unsigned long pfn) -{ -phys_addr_t addr =PFN_PHYS (pfn); -struct mem_section *ms; - -/* -* Ensure the upper PAGE_SHIFT bits are clear in the -* pfn. Else it might lead to false positives when -* some of the upper bits are set, but the lower bits -* match a valid pfn. -*/ -if (PHYS_PFN (addr) != pfn) -return 0 ; - -if (pfn_to_section_nr (pfn) >=NR_MEM_SECTIONS ) -return 0 ; - - ms =__pfn_to_section (pfn); -if (!valid_section (ms)) -return 0 ; - -/* -* ZONE_DEVICE memory does not have the memblock entries. -* memblock_is_map_memory() check for ZONE_DEVICE based -* addresses will always fail. Even the normal hotplugged -* memory will never have MEMBLOCK_NOMAP flag set in their -* memblock entries. Skip memblock search for all non early -* memory sections covering all of hotplug memory including -* both normal and ZONE_DEVICE based. -*/ -if (!early_section (ms)) -return pfn_section_valid (ms, pfn); - -return memblock_is_memory (addr); -} -EXPORT_SYMBOL (pfn_valid); -int pfn_is_map_memory (unsigned long pfn) {phys_addr_t addr =PFN_PHYS (pfn);
Signature · 1 line
2.28.0
Quoted 8 lines · Mike Rapoport
From: Mike Rapoport <[email protected]>
Hi,
This is a new attempt to drop
HAVE_ARCH_PFN_VALIDon arm64 and start using the generic implementation ofpfn_valid().[...]
Applied to arm64 (for-next/pfn-valid), thanks!
[1/2] dma-mapping: remove bogus test for pfn_valid from dma_map_resource
https://git.kernel.org/arm64/c/a9c38c5d267c [2/2] arm64/mm: drop HAVE_ARCH_PFN_VALID https://git.kernel.org/arm64/c/3de360c3fdb3
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev