From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com [50.112.246.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0D3292236FD for ; Mon, 11 May 2026 06:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=50.112.246.219 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778482612; cv=none; b=YmPXUDcK6tSnFsPFRFVhz5sLh/vTu1ZBzaGIYKuB/CKG2pQxYyV1NQpHxVoP+gf9kBofVwKhBiqx3fMDKbDav2VuC+pKaoXLkQdwTobI4JjZLuJazNS1Gvaq8a0OH6zdjkAYGTxEHJA7Bf8q6uLxAO6DKcsjrJuRdQ0zyOKtp8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778482612; c=relaxed/simple; bh=clKZqdiJD/BmJl5rcg13ZFZlD/kDbqh5C4V58qJm648=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bcPULFZwhy9m06XOHVzF8pMkA42HEeI0vSw3n1sY9CTEvCns4S1oZQLh5SB561ZejZSsw9kyu8MCLG1LnieYu+Q7TrOIeA6tZZ3larhxiShGno6YDXWWFzb6/t5CNPC1dr8EdrRaexupqO+gLhK1mpJ6WyDTTML/t7Gr9JzijOg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=m5ehmdKx; arc=none smtp.client-ip=50.112.246.219 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="m5ehmdKx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1778482611; x=1810018611; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ej7n2fwlQvnkezOdb5eOebqaoEEQlRJLzJN6s1U0kyo=; b=m5ehmdKxeEkycbOO2zm31eu3Q+pvt7AXy29Ae8kqOa0rXP8fNOr7xrG4 6GnM1s+0PgTmGypsXeEH8Ef6GQL151Q8PSymwj033rfri6wpJye2V0B3N dQDbsOjvleuqmz6oFpVT6BcmOWiKmztFyYtnUjkXLjwHhC3WCNkY+NMlL osyRcfu1IGLINwLaypBKZWaWK14Jz8Zpp1YG1a2dxC88Bzxj/2U2adO/S hW7NeQ00nVzlH9ZRmyHCZDnAub+xVIXzQ+d0lEpvAXkQf4XRWjeX4OSqC +rTvkchnGiqEWjT0NXv4oqHyR67I0IfnayS4ZlQLwGBK1CxNi8CX4FPsa Q==; X-CSE-ConnectionGUID: B8zaQmRXQdSuft4QRXbPPA== X-CSE-MsgGUID: k4DQZ9NNQ/+FjcJkq77Xcg== X-IronPort-AV: E=Sophos;i="6.23,228,1770595200"; d="scan'208";a="19143029" Received: from ip-10-5-0-115.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.0.115]) by internal-pdx-out-015.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2026 06:56:50 +0000 Received: from EX19MTAUWC001.ant.amazon.com [205.251.233.53:24995] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.24.221:2525] with esmtp (Farcaster) id 379775f2-0943-46aa-88b3-66f68e3066e8; Mon, 11 May 2026 06:56:50 +0000 (UTC) X-Farcaster-Flow-ID: 379775f2-0943-46aa-88b3-66f68e3066e8 Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWC001.ant.amazon.com (10.250.64.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Mon, 11 May 2026 06:56:49 +0000 Received: from dev-dsk-ravib-2a-f2262d1b.us-west-2.amazon.com (10.169.187.85) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Mon, 11 May 2026 06:56:49 +0000 From: Ravi Kumar Bandi To: Bjorn Helgaas , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Andrew Morton , Dan Williams CC: David Hildenbrand , Ravi Kumar Bandi , Subject: [PATCH] resource: export iomem_get_mapping() for loadable modules Date: Mon, 11 May 2026 06:56:37 +0000 Message-ID: <20260511065637.40739-1-ravib@amazon.com> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D039UWA004.ant.amazon.com (10.13.139.68) To EX19D001UWA001.ant.amazon.com (10.13.138.214) 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 --- 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