Re: [PATCH] resource: export iomem_get_mapping() for loadable modules
From: David Hildenbrand (Arm)
Date: Mon May 11 2026 - 03:14:14 EST
On 5/11/26 08:56, Ravi Kumar Bandi wrote:
> Loadable PCIe driver modules that handle surprise removal or link-down
> events need to zap userspace mappings of PCI BAR resources to deliver
> SIGBUS on next access, rather than leaving stale mappings to a dead
> device.
>
> The correct way to do this is via unmap_mapping_range() on the iomem
> address space, which is already exported via EXPORT_SYMBOL.
> However, iomem_get_mapping() which returns the iomem address space
> is not exported, making it impossible to use unmap_mapping_range()
> correctly from a loadable module without resorting to workarounds
> such as walking all process VMAs or opening /dev/mem.
>
> Export iomem_get_mapping() via EXPORT_SYMBOL_GPL to complete the
> existing exported API and allow loadable modules to properly zap
> PCI BAR mappings on device removal.
>
> Signed-off-by: Ravi Kumar Bandi <ravib@xxxxxxxxxx>
> ---
> kernel/resource.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/kernel/resource.c b/kernel/resource.c
> index d02a53fb95d8..8801e390fe2e 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1311,6 +1311,7 @@ struct address_space *iomem_get_mapping(void)
> */
> return smp_load_acquire(&iomem_inode)->i_mapping;
> }
> +EXPORT_SYMBOL_GPL(iomem_get_mapping);
>
> static int __request_region_locked(struct resource *res, struct resource *parent,
> resource_size_t start, resource_size_t n,
Which in-tree driver wants to make use of this?
--
Cheers,
David