All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi Kumar Bandi <ravib@amazon.com>
To: "Bjorn Helgaas" <bhelgaas@google.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Dan Williams" <djbw@kernel.org>
Cc: David Hildenbrand <david@kernel.org>,
	Ravi Kumar Bandi <ravib@amazon.com>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] resource: export iomem_get_mapping() for loadable modules
Date: Mon, 11 May 2026 06:56:37 +0000	[thread overview]
Message-ID: <20260511065637.40739-1-ravib@amazon.com> (raw)

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@amazon.com>
---
 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,
-- 
2.47.3


             reply	other threads:[~2026-05-11  6:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  6:56 Ravi Kumar Bandi [this message]
2026-05-11  7:14 ` [PATCH] resource: export iomem_get_mapping() for loadable modules David Hildenbrand (Arm)
2026-05-11  7:17   ` Christoph Hellwig
2026-05-11 16:16     ` Ravi Kumar Bandi
2026-05-12  7:10       ` David Hildenbrand (Arm)
2026-05-12  7:31         ` Ravi Kumar Bandi
2026-05-12  7:22       ` Christoph Hellwig
2026-05-12  7:50         ` Ravi Kumar Bandi
2026-05-13 18:45           ` Dan Williams (nvidia)
2026-05-14 15:54             ` Ravi Kumar Bandi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260511065637.40739-1-ravib@amazon.com \
    --to=ravib@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=david@kernel.org \
    --cc=djbw@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.