From nobody Sun Dec 14 05:56:53 2025 Received: from SN4PR2101CU001.outbound.protection.outlook.com (mail-southcentralusazon11012037.outbound.protection.outlook.com [40.93.195.37]) (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 EF22D2417F2; Sat, 13 Dec 2025 04:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.195.37 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601249; cv=fail; b=MEn+hBZrln2rhkEZv3RyqVdkcPAYMTBKuTNW8ljVe9ygOWqDFQRqNXE0TiAHRHooztsH0EP2NN8sIl9VW/M0sb0He/ljqno5yWttsQeAfHkOTA32340idNSl3qBj/WQd7nlaDHNGv9A3w/lE0JMHW9y0b1OKzRl3rOlr0D09YBg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601249; c=relaxed/simple; bh=AJgjcP63ISl0KHHqVjj0h9QWCCsCVbwE3I/zAF/uftc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p44FKU0Po8D5S6WJcba3kiHySoF0V1FxpICySaKp5ondkGhWbjO3gcAv5bU0/iMS7VF8M1ZIpnKaJXZcTiHMzFLOtwaUjVkE5J8zPWL+cUs7qr2x3UIkwWMsWq/OjkCaIS8PC3AJCv8tUMA6+r6selzgcoYQcRLUUQ77TMvUhHo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=PUgdCyD0; arc=fail smtp.client-ip=40.93.195.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="PUgdCyD0" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EAwK7+86AXczGG1rs3WR5OVTMBm4ckbTIzp37qAFeJereK2oj3wSp5CvjkmPg5u85Hdt9Kb0LpWX8ob/6PzCtHEzn/0i1DdPZZoUK8U1S+Vp9/OBIzMwYym7dDnspKzgfvf3ihwmENOn8C11kw/n0hGmSRYYZ89tAL0fzo/mIRXEW3wnZtN3SookYoYI/9YaE19uiYYctexgPOQJWsECkYYnFKpcVtDHrCnyZE0WcSC4WALxQsL3nARUBYuB1NYC7IPFdj/5JR7Eb5Itn7m4LqsbxKg369XGd1uzHIFiJCgu6Aizf/ChlOXQn23lM5zUqoTtCS057rJUH9XYLlcWsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FXwRJw/kXuFWvbzfbPcGe2EuO+zSv0mwjKJKiQmd5IE=; b=AqTU53gXAMB8EpLbIGlmCSwLAgOgziV0K4TSIs6WJ05hJIkUwTmCCizS4irVvtUXqfylHDhmjxGKvorbOrxA6aynTg8EHHU54cfmHATPKNy2M/+eUGq43u/Q00ZhxT5KIX5ru5V+ra+XSW4YLNYhj5LWq3vMKtpoNw1WL6y3vTONa1zPwq6wpTNs5mhvFjiHYskakHHgJ56A1TQdpoSM9amhEUAVo5xzzV6e1xGtghe/B2DHY7qxv5dTCOfzutor2kvD4To2A000a46UgNDMkJD6pGaZAuqhXmcwMmX8ze2/wiixcCQHPi2aXyjOiDNxZ9oiod7LxM+9N37FQobkLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FXwRJw/kXuFWvbzfbPcGe2EuO+zSv0mwjKJKiQmd5IE=; b=PUgdCyD0i/74jiHQHBr/mCdT6q+7/xwCExb/mLgQ4OdSswijwTsK9GZ5ElWCikHfH8JiSMBxYmdYpdMgDWOKe1UX7ZkdiHImcy8EUDa/tH5bbWcw9R4pSQPCvPzi3Fa5FwcG4pASXMl1c711mmN4NNp+71Mb21OcG5+JVCZ64a2xQ08GdFuMmucwv7RK8hlRUWTQ3Sw2pRiIoCKrPzKuDxcOLRZE5l04rJGlnq2nfsJyhEU9mUUFvi81SKTWtkRSlK+cw64F9FoeLqPEVzWrUlEx84YyfhuBlFH/tiez7b5PbTWPou4UzRw4Rxlrr3z7QwkSS8ZDTfVvNnYRp7Y9sQ== Received: from BN9PR03CA0326.namprd03.prod.outlook.com (2603:10b6:408:112::31) by BL1PR12MB5802.namprd12.prod.outlook.com (2603:10b6:208:392::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.9; Sat, 13 Dec 2025 04:47:21 +0000 Received: from BN1PEPF0000467F.namprd03.prod.outlook.com (2603:10b6:408:112:cafe::6a) by BN9PR03CA0326.outlook.office365.com (2603:10b6:408:112::31) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.11 via Frontend Transport; Sat, 13 Dec 2025 04:47:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN1PEPF0000467F.mail.protection.outlook.com (10.167.243.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Sat, 13 Dec 2025 04:47:21 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:10 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:09 -0800 Received: from localhost.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Fri, 12 Dec 2025 20:47:09 -0800 From: To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v2 1/3] mm: fixup pfnmap memory failure handling to use pgoff Date: Sat, 13 Dec 2025 04:47:06 +0000 Message-ID: <20251213044708.3610-2-ankita@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251213044708.3610-1-ankita@nvidia.com> References: <20251213044708.3610-1-ankita@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF0000467F:EE_|BL1PR12MB5802:EE_ X-MS-Office365-Filtering-Correlation-Id: 3908fa4d-1d36-4d37-376f-08de3a02b3ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?kREk4zXAURHQUOqOC3AZTAXlAAAZE1H84CNVjGz6Vdyw4cuRVuBLWsX5T0GS?= =?us-ascii?Q?bNQrtjmP8qw3gRQmfwudhp41y8P6ZxbTO3H4IOq2dYY0yZB3HLRanenRZU41?= =?us-ascii?Q?e6rvEMYcI6CbXMWh/mQbimdbFSxRBKpHQB/UEbJRUrl9OuM0e0TXY7C5B4y1?= =?us-ascii?Q?zY1JPIyrx+KkuTI4eXTTISHVZOSBRCuAp3Mi2w8C67bBdE7LW/rfqThsqKW3?= =?us-ascii?Q?4gr1tUUCSXG8HtSsIlV5zwFYkLgstfXjowFWonAstJfZ/E+APjPkXcgtm/Jg?= =?us-ascii?Q?/WInhZjvGpHo/K7hBvedLYqPqOh5muBH5Zeq1v7V39F69fHTaewHpLXxVWhH?= =?us-ascii?Q?+u4w0xy4Qx8DDibxSt1S6ZomhM2eLOOUKsWd8aKDbbIUXfvIEJjODqz1E4jS?= =?us-ascii?Q?LuwZvKld1eTuU4vp6+UFAzKRebg5F21ZaLPdYDxHXljLSDTk+PnhSjAjplF1?= =?us-ascii?Q?h32wqWj1VTtQR2UcFdZ1tz3PCR4xRgV7FpAixBJAQ/UEAXo41G7TTaxewHbx?= =?us-ascii?Q?lnc9GF45lgjjZdxBwgbBO7dqXqJC2hNs+zo99aaq8pAd06hZ8YGRM+4+eDr1?= =?us-ascii?Q?6bfhFQevoOTRF3jld8XOWM9sWKW/xKXOhTuW8DzMw4jCRvVZmcj97wwDHMYF?= =?us-ascii?Q?KggWwzMBeIyC0TQMRjgEQEKK53QNNuf58gZGfUplDe1uGDOD1aaO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skkDAQX7bxAqj?= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2025 04:47:21.0067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3908fa4d-1d36-4d37-376f-08de3a02b3ab X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF0000467F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5802 Content-Type: text/plain; charset="utf-8" From: Ankit Agrawal The memory failure handling implementation for the PFNMAP memory with no struct pages is faulty. The VA of the mapping is determined based on the the PFN. It should instead be based on the file mapping offset. At the occurrence of poison, the memory_failure_pfn is triggered on the poisoned PFN. Introduce a callback function that allows mm to translate the PFN to the corresponding file page offset. The kernel module using the registration API must implement the callback function and provide the translation. The translated value is then used to determine the VA information and sending the SIGBUS to the usermode process mapped to the poisoned PFN. The callback is also useful for the driver to be notified of the poisoned PFN, which may then track it. Fixes: 2ec41967189c ("mm: handle poisoning of pfn without struct pages") Suggested-by: Jason Gunthorpe Signed-off-by: Ankit Agrawal --- include/linux/memory-failure.h | 2 ++ mm/memory-failure.c | 29 ++++++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/include/linux/memory-failure.h b/include/linux/memory-failure.h index bc326503d2d2..7b5e11cf905f 100644 --- a/include/linux/memory-failure.h +++ b/include/linux/memory-failure.h @@ -9,6 +9,8 @@ struct pfn_address_space; struct pfn_address_space { struct interval_tree_node node; struct address_space *mapping; + int (*pfn_to_vma_pgoff)(struct vm_area_struct *vma, + unsigned long pfn, pgoff_t *pgoff); }; =20 int register_pfn_address_space(struct pfn_address_space *pfn_space); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index fbc5a01260c8..c80c2907da33 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2161,6 +2161,9 @@ int register_pfn_address_space(struct pfn_address_spa= ce *pfn_space) { guard(mutex)(&pfn_space_lock); =20 + if (!pfn_space->pfn_to_vma_pgoff) + return -EINVAL; + if (interval_tree_iter_first(&pfn_space_itree, pfn_space->node.start, pfn_space->node.last)) @@ -2183,10 +2186,10 @@ void unregister_pfn_address_space(struct pfn_addres= s_space *pfn_space) } EXPORT_SYMBOL_GPL(unregister_pfn_address_space); =20 -static void add_to_kill_pfn(struct task_struct *tsk, - struct vm_area_struct *vma, - struct list_head *to_kill, - unsigned long pfn) +static void add_to_kill_pgoff(struct task_struct *tsk, + struct vm_area_struct *vma, + struct list_head *to_kill, + pgoff_t pgoff) { struct to_kill *tk; =20 @@ -2197,12 +2200,12 @@ static void add_to_kill_pfn(struct task_struct *tsk, } =20 /* Check for pgoff not backed by struct page */ - tk->addr =3D vma_address(vma, pfn, 1); + tk->addr =3D vma_address(vma, pgoff, 1); tk->size_shift =3D PAGE_SHIFT; =20 if (tk->addr =3D=3D -EFAULT) pr_info("Unable to find address %lx in %s\n", - pfn, tsk->comm); + pgoff, tsk->comm); =20 get_task_struct(tsk); tk->tsk =3D tsk; @@ -2212,11 +2215,12 @@ static void add_to_kill_pfn(struct task_struct *tsk, /* * Collect processes when the error hit a PFN not backed by struct page. */ -static void collect_procs_pfn(struct address_space *mapping, +static void collect_procs_pfn(struct pfn_address_space *pfn_space, unsigned long pfn, struct list_head *to_kill) { struct vm_area_struct *vma; struct task_struct *tsk; + struct address_space *mapping =3D pfn_space->mapping; =20 i_mmap_lock_read(mapping); rcu_read_lock(); @@ -2226,9 +2230,12 @@ static void collect_procs_pfn(struct address_space *= mapping, t =3D task_early_kill(tsk, true); if (!t) continue; - vma_interval_tree_foreach(vma, &mapping->i_mmap, pfn, pfn) { - if (vma->vm_mm =3D=3D t->mm) - add_to_kill_pfn(t, vma, to_kill, pfn); + vma_interval_tree_foreach(vma, &mapping->i_mmap, 0, ULONG_MAX) { + pgoff_t pgoff; + + if (vma->vm_mm =3D=3D t->mm && + !pfn_space->pfn_to_vma_pgoff(vma, pfn, &pgoff)) + add_to_kill_pgoff(t, vma, to_kill, pgoff); } } rcu_read_unlock(); @@ -2264,7 +2271,7 @@ static int memory_failure_pfn(unsigned long pfn, int = flags) struct pfn_address_space *pfn_space =3D container_of(node, struct pfn_address_space, node); =20 - collect_procs_pfn(pfn_space->mapping, pfn, &tokill); + collect_procs_pfn(pfn_space, pfn, &tokill); =20 mf_handled =3D true; } --=20 2.34.1 From nobody Sun Dec 14 05:56:53 2025 Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012000.outbound.protection.outlook.com [40.107.209.0]) (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 C48D8287263; Sat, 13 Dec 2025 04:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.209.0 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601251; cv=fail; b=JsjlGpyVQ4iXaWpZM0FeFSdr2O9q5B774IHXNQUSKwStcRNXKfEHPDUG4nf48W/JTAkJApyAzUnOKnZ5yyWlHCd17eXEKZvrB29AuEyd2PCxR5VT/QOxYnUUec4n7sGBcV9MBvJ2MvecgW9FzKBaqa5L7NnUjlR0wPvGLqWq/go= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601251; c=relaxed/simple; bh=OykvN3WVot5YOHuMxy9/W6f3FTTD8MGg/f7XDgP/H3M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Zli0gl00HIV1B/ApDJ23mTxiJEVzgPk0oiGb9FePn597ZNYtg3XglsZwFxgt/CpHvgoZWWfcCKj0jR4Vi3Oj56KWG4nId91zavXDQvlmPnO3IgpqndWuNoHd/XlLHtcZDmXLIb7nV3GYh1uijSvYllpQjQYe9ePPoZHPfxBdLVE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=nhbKvPhY; arc=fail smtp.client-ip=40.107.209.0 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="nhbKvPhY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IMwECVDoKIbOm+ZnaqQYIT8Wlc2Wz+c+I0+C/aCiCyvtydaMzxDZBcMQdAx70IATTu/syMquJpmh2tO2RzAylW8ZpJjSwjikBqw1j+3IJglpmKoVwx56TbGKKXdGrKsCwUtsOsjd5AQViHZoZEy3n50QpZfpW8t9n6BxuY3NZ3jGgcYA1ner93MAiXesQxQMT1I70PqUurpmuscwWgKjXmifOD8cxbdD3f8/JDXmDE+mbUI942Rl1y/tsAcgkZyv2JINMHKYkREBMms4xXZP/hMSOFdH7Vfh0d76nZkuaHeXQNJXaDbwnBI1wxgM6AkmUpnCyouQQI9UL2iqXdQfQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P+9X97v8oLGLYonIialThNeDaSCMrIwHdgiUJqYKE3k=; b=EMn2rdquEdXwhPojWVn5hcL8ra4l+xRTE8BHjbq+lwIendrmsE6/EXckDuNsXFQRLwz3N2CfFnWU+7/nQCIi+zXpIp9nZ1IDfQtnwA4NlnpkfZqLLGNdIpCK8IO5jKPsPdZ95WVpAKMUhpDRXZkWzP4BMslY3TrJE6N/15b0t0OJSUCI5Ad2smLr7PA5976O7HxvUB9ioCBk9PXN+RzFZ1Sp0nvnEwjdtlOArLzUHIhTyny0QCukWuTEQ9sCVIZkDD1mbdaEgj6xMfvZhx8UzGYqNiNg44Oj8Xip0/XT7ArDCIJvX7QzBorVwWfWeTa0JQ81+tKJ9Kj75z6GtlRcEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P+9X97v8oLGLYonIialThNeDaSCMrIwHdgiUJqYKE3k=; b=nhbKvPhY3zZbmancTciemnBMGBAza5c7pKc0j6eifTa2WP8qU8naikMHyhtpd18m5Sfao2w7ewX+8acr/wJttUcGCa34bDu9skMM4VabRRi7f8fcxRlLNGbLlAx+LK03BM3Qq6e+cN4yYYO5AeM5xdUsfVp1Fb4DnjINLXCNiixlizKrrI7LDHeLZ0ZEmtlgTJcyUZoXrKsUL5h41cLLIISIf2oCo6WOvwF1BResx1evifK0O8sxI9fKwrpDE0glNGevHfaYd0mGZTnilKr4pyDn+Hg0niskKQ55ll1XsiyKwFOc7Q+khXwF87a8Av6KJSi78j8cj7PNvfJ9AzxGOA== Received: from SJ2PR07CA0001.namprd07.prod.outlook.com (2603:10b6:a03:505::11) by MN2PR12MB4270.namprd12.prod.outlook.com (2603:10b6:208:1d9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.12; Sat, 13 Dec 2025 04:47:19 +0000 Received: from CO1PEPF000066E9.namprd05.prod.outlook.com (2603:10b6:a03:505:cafe::3b) by SJ2PR07CA0001.outlook.office365.com (2603:10b6:a03:505::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.11 via Frontend Transport; Sat, 13 Dec 2025 04:47:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CO1PEPF000066E9.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Sat, 13 Dec 2025 04:47:19 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:10 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:09 -0800 Received: from localhost.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Fri, 12 Dec 2025 20:47:09 -0800 From: To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v2 2/3] mm: add stubs for PFNMAP memory failure registration functions Date: Sat, 13 Dec 2025 04:47:07 +0000 Message-ID: <20251213044708.3610-3-ankita@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251213044708.3610-1-ankita@nvidia.com> References: <20251213044708.3610-1-ankita@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E9:EE_|MN2PR12MB4270:EE_ X-MS-Office365-Filtering-Correlation-Id: f9f51cf5-446f-48c9-4437-08de3a02b2ab X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|1800799024|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?48KvNHV7ZU/jNiiuZMtW8FpeAXWbAg+8x4TqSVncfpjMVn/bay7eqXL+oDBL?= =?us-ascii?Q?LvGdr76BCU3GrIzXOwBVEOq92WHLVo78xK/IaCnPkLEzXTLyXGsxlHXueuK+?= =?us-ascii?Q?08TYA5AuYEUync70SR6oQQHp0E2MGtCCoakxq4atov7I9RfNQgLYqeJAlcEZ?= =?us-ascii?Q?UqgP4yQtY+UwKPqhioYOSEyze6Rx/jiI6S567ziB1YRcThKwnw7R48abXHha?= =?us-ascii?Q?iclcwYk8syoboEW3fgQ2j2G/6LCI7nh0P1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us-ascii?Q?/vgjOvBWtOa0X40Q5LIcGGXfc5uJ9vfTqkAIplHEbHhkIWknBmMk9jKny3Vf?= =?us-ascii?Q?2uJvZo05uYJhjd0tP03ZXFcmCiGp1w4TqxrcXhSmKqQSuA0z9r/irU8Z/RFF?= =?us-ascii?Q?cJ+vyLEb+3mH+NcxMgykYmIxQ31vMEp0OWRfW5ANHvev3+bWNjiukX6SR8sK?= =?us-ascii?Q?JVawmFfyDJ/HxKTpSGbIEmWbbM5e0MEoNuN8JbmsuKVn5BqdxHLv2hUwVdRM?= =?us-ascii?Q?1Qbp6UMiB2lBJeAtOTnlswQ4zS3IW/MNcoUXb3OaLCj9YeK3skkPNCzRaSGA?= =?us-ascii?Q?IUoCvYLZGKxdN+Z70bz0O5pmw6BEO8uHTB4xzX62teJr4l2EyMHJoZzhuoXQ?= =?us-ascii?Q?TSQ04T6gzMNsjd5jtKdGbZqztiTj4ZECJuugyGNANS/+HYkuQNqckxT8ODtJ?= =?us-ascii?Q?nuM6sJw5RACJkgiQ1JW7/vdTV0cGUniK6+oSi/Pv?= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(1800799024)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2025 04:47:19.4222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9f51cf5-446f-48c9-4437-08de3a02b2ab X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066E9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4270 Content-Type: text/plain; charset="utf-8" From: Ankit Agrawal Add stubs to address CONFIG_MEMORY_FAILURE disabled. Suggested-by: Alex Williamson Signed-off-by: Ankit Agrawal --- include/linux/memory-failure.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/memory-failure.h b/include/linux/memory-failure.h index 7b5e11cf905f..d333dcdbeae7 100644 --- a/include/linux/memory-failure.h +++ b/include/linux/memory-failure.h @@ -4,8 +4,6 @@ =20 #include =20 -struct pfn_address_space; - struct pfn_address_space { struct interval_tree_node node; struct address_space *mapping; @@ -13,7 +11,18 @@ struct pfn_address_space { unsigned long pfn, pgoff_t *pgoff); }; =20 +#ifdef CONFIG_MEMORY_FAILURE int register_pfn_address_space(struct pfn_address_space *pfn_space); void unregister_pfn_address_space(struct pfn_address_space *pfn_space); +#else +static inline int register_pfn_address_space(struct pfn_address_space *pfn= _space) +{ + return -EOPNOTSUPP; +} + +static inline void unregister_pfn_address_space(struct pfn_address_space *= pfn_space) +{ +} +#endif /* CONFIG_MEMORY_FAILURE */ =20 #endif /* _LINUX_MEMORY_FAILURE_H */ --=20 2.34.1 From nobody Sun Dec 14 05:56:53 2025 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010026.outbound.protection.outlook.com [52.101.85.26]) (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 8664317BB21; Sat, 13 Dec 2025 04:47:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601246; cv=fail; b=TfLokQvDtjTLWoiUfynXEA+/aU4jmgzIpxvIFB2uUGDfvzRW/kFVc3LWO9zq3W14ulamXFM9ZZXiUUyAH2tNwkrV9tt0qHlON1whQUPlXtfDLQ/hgFOyb3h4LzWiUurY0YzB1eCOY5qx8uUSH2MCfRPrar8JT2sQSXaVf/+1Nq4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765601246; c=relaxed/simple; bh=en6rjw56LDmnBshFY5QE3P3MrnvtT75OSGpR8kTHyjg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MiplZjUbDbWmc1fEmfrBd/v1+shEIxdJ/IsR3aMbgGd4q0kMZtHMD1Bwxrx9SDBJ2DuKm6IwSHaD5mBD5RrMib/EP8aMOEECPGBf9pwdSuwEazIaeE/hnEZ/CPTC57vG9PlQs+HqHjJ0TVAmGQJPxljNoT/7LNNHemRuAjeSQn8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=M9NeLO/O; arc=fail smtp.client-ip=52.101.85.26 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="M9NeLO/O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m7kZE6We4pnxuVu1ut0rY7hKuzlRKPFZ0ZL1k92+gAMLF6BqPInMiqBPZWn5q6wurXYwhhj/y34O77F56EkvDdAD5s5WZdGDspQqxYYwij6PKw9pNb/1nYAYTK1Vv0oo8EcAbnYma7WTXhdnR233lthSM1sapIRoY8b362Dymwo5WGCjoZZU5GSNKgWiklAyyomQUeSf7Uo65ZA2HqOihUWoCU55W/afJZ2yIYVKB+3BvWYuhkkJWTMx+V1laxj1OZpKQ8cFq9HP51RgbzfhYLZmsH6z029uWSfEaIa7mC57Qzau1H98IGnCX7ltWK+6dmL9jiGvzEANMHtE3pFwOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DiiObMMz0NWFcx9kG4xVH/DYubG8CNjsU8JCIhLQafU=; b=iv2PmzRjNwXVHQZ2ss4o5mrEbAf6VJLvnWJC+fNS3WDVcOd8I/hYsGxcwvuG5EHneuXKt2Jj1sIbqa+9enm59QNrS871t+kMAUwg1T+HT+OGkr5DUCjGblqkanJZQ1FVYsZcP7VZoRih7IsU2BFIr0Sl48+CYT3dxghapgcsCbdOrtlLENArXbJ1lIHTjzHD+nJRlgWQ+pkZ2t6OTgg6omoRj0NggdOw6cuOSbpwhibQ+jIQucOzhXKmtqnuesoEeCxRNRzo+DCs49FWn9CoXSBKu4oZLpiMaDJZHc2yaCOv2pduJWjxWFCSvnlJbPLMELlzc8ZUPC02Y/RJmUx/rA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DiiObMMz0NWFcx9kG4xVH/DYubG8CNjsU8JCIhLQafU=; b=M9NeLO/OB0Sqge7TM607c8yUyb/T7mwzHKLg3ePWw3Uq3NzTGlx12O44iZ+OS266VVvBTyjd91Xl0q1NoUcbKN1WXh7lTGvUNNuDNE5S+rB/zTSIHaKqgm/fJv9vVsbW7tkRLPOImjvI60fVhOTfESit/EklZNrnZdPrPdzuHlPgTyVfMejCUKuy1rAG1utG3YWmtFsWlmpEcoZb0J/OZ5tANSi6+5P/SlaJ+GrsN2xVassJGJ6lHxPwosquBWq2BxCiUXEyOEPwjpCpc7XTjfXSf16ZCwGCjOTVs4q+JjgQPWGDGIeqBRWo5oBswsEQwInugstPvXkUz0znuPgukA== Received: from BN9P220CA0011.NAMP220.PROD.OUTLOOK.COM (2603:10b6:408:13e::16) by DS7PR12MB6310.namprd12.prod.outlook.com (2603:10b6:8:95::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.12; Sat, 13 Dec 2025 04:47:20 +0000 Received: from BN1PEPF00004685.namprd03.prod.outlook.com (2603:10b6:408:13e:cafe::bc) by BN9P220CA0011.outlook.office365.com (2603:10b6:408:13e::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9412.11 via Frontend Transport; Sat, 13 Dec 2025 04:47:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by BN1PEPF00004685.mail.protection.outlook.com (10.167.243.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9412.4 via Frontend Transport; Sat, 13 Dec 2025 04:47:20 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:10 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 12 Dec 2025 20:47:10 -0800 Received: from localhost.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Fri, 12 Dec 2025 20:47:10 -0800 From: To: , , , , , , , , , CC: , , , , , , , Subject: [PATCH v2 3/3] vfio/nvgrace-gpu: register device memory for poison handling Date: Sat, 13 Dec 2025 04:47:08 +0000 Message-ID: <20251213044708.3610-4-ankita@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251213044708.3610-1-ankita@nvidia.com> References: <20251213044708.3610-1-ankita@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00004685:EE_|DS7PR12MB6310:EE_ X-MS-Office365-Filtering-Correlation-Id: 084ed4c3-398e-47c4-aebd-08de3a02b33a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|36860700013|82310400026|13003099007|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sj3AJT2qC2dYPyAHmwCSp3h/SgRGzkN5TLtphMRN0kkibXUFFJSpshzLHGc9?= =?us-ascii?Q?Rrs1DCKORnhxiyjRu8lClDOaznr0ZdMKIanbSaZRULkDoXjvjDcUvxoff4jW?= =?us-ascii?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iagovfWijtKoRWeZ8KNBDIlfT?= =?us-ascii?Q?Fl/xCnCAiFDsjXeNznTJTATXbiFfwv4Rhws/64VJ94fX0Kvwc3ABwaK9ScBC?= =?us-ascii?Q?JyC2b12pumKuwuiqdFhhBZTKB7jH7VVHGJbAxuCcQYzJ5Y4WE+e0/luTnDcH?= =?us-ascii?Q?wEeRCr2V1QU4CnjIYH+PlwSgUq23DzgTSF07pb9T1ZUcSnZ5qVhK5aHBuA46?= =?us-ascii?Q?9KTX09sMel09R9L7bOVGlWr8MFfb+WdZnDBn4sZzfSgiFmhOW5WmfEIpdzex?= =?us-ascii?Q?alzfOqI+3hT8meHbM6FUNdq3uxig3xOeQn4TbSn4pGxFDDX0fHJ9p+6wHqSS?= =?us-ascii?Q?HP+JE5uVfLIefHdwCymjdp6A9oKZvoyb4uiwsCG+NDJTwxuVEVsziLFLwqfs?= =?us-ascii?Q?gDHp1hTv2UWg9tMrU6rIGQf+kUo6aejJyMbF0HSzkui/zn/wJQmYuCi3FSO8?= =?us-ascii?Q?dV169L/WX3cQ0cELDg03ovsXpfOu+UYwuqfB3iJtpeS651BAD3EZbnE+v+Sd?= =?us-ascii?Q?dOXFKvsZbHq5UZwOuP+xhE5ZLUeSbOztZaIArTsOrbi7ege8JapWK9SBCUJM?= =?us-ascii?Q?NeJoEjrOmeU0mYTHNvYkL2pkTxxsuORwG3iTRrLu?= X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(1800799024)(36860700013)(82310400026)(13003099007)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2025 04:47:20.2820 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 084ed4c3-398e-47c4-aebd-08de3a02b33a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00004685.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6310 Content-Type: text/plain; charset="utf-8" From: Ankit Agrawal The nvgrace-gpu module [1] maps the device memory to the user VA (Qemu) without adding the memory to the kernel. The device memory pages are PFNMAP and not backed by struct page. The module can thus utilize the MM's PFNMAP memory_failure mechanism that handles ECC/poison on regions with no struct pages. The kernel MM code exposes register/unregister APIs allowing modules to register the device memory for memory_failure handling. Make nvgrace-gpu register the GPU memory with the MM on open. The module registers its memory region, the address_space with the kernel MM for ECC handling and implements a callback function to convert the PFN to the file page offset. The callback functions checks if the PFN belongs to the device memory region and is also contained in the VMA range, an error is returned otherwise. Link: https://lore.kernel.org/all/20240220115055.23546-1-ankita@nvidia.com/= [1] Suggested-by: Alex Williamson Suggested-by: Jason Gunthorpe Signed-off-by: Ankit Agrawal Reviewed-by: Alex Williamson --- drivers/vfio/pci/nvgrace-gpu/main.c | 116 +++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c b/drivers/vfio/pci/nvgrace= -gpu/main.c index 84d142a47ec6..91b4a3a135cf 100644 --- a/drivers/vfio/pci/nvgrace-gpu/main.c +++ b/drivers/vfio/pci/nvgrace-gpu/main.c @@ -9,6 +9,7 @@ #include #include #include +#include =20 /* * The device memory usable to the workloads running in the VM is cached @@ -49,6 +50,7 @@ struct mem_region { void *memaddr; void __iomem *ioaddr; }; /* Base virtual address of the region */ + struct pfn_address_space pfn_address_space; }; =20 struct nvgrace_gpu_pci_core_device { @@ -88,6 +90,83 @@ nvgrace_gpu_memregion(int index, return NULL; } =20 +static int pfn_memregion_offset(struct nvgrace_gpu_pci_core_device *nvdev, + unsigned int index, + unsigned long pfn, + pgoff_t *pfn_offset_in_region) +{ + struct mem_region *region; + unsigned long start_pfn, num_pages; + + region =3D nvgrace_gpu_memregion(index, nvdev); + if (!region) + return -EINVAL; + + start_pfn =3D PHYS_PFN(region->memphys); + num_pages =3D region->memlength >> PAGE_SHIFT; + + if (pfn < start_pfn || pfn >=3D start_pfn + num_pages) + return -EFAULT; + + *pfn_offset_in_region =3D pfn - start_pfn; + + return 0; +} + +static inline +struct nvgrace_gpu_pci_core_device *vma_to_nvdev(struct vm_area_struct *vm= a); + +static int nvgrace_gpu_pfn_to_vma_pgoff(struct vm_area_struct *vma, + unsigned long pfn, + pgoff_t *pgoff) +{ + struct nvgrace_gpu_pci_core_device *nvdev; + unsigned int index =3D + vma->vm_pgoff >> (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT); + pgoff_t vma_offset_in_region =3D vma->vm_pgoff & + ((1U << (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT)) - 1); + pgoff_t pfn_offset_in_region; + int ret; + + nvdev =3D vma_to_nvdev(vma); + if (!nvdev) + return -ENOENT; + + ret =3D pfn_memregion_offset(nvdev, index, pfn, &pfn_offset_in_region); + if (ret) + return ret; + + /* Ensure PFN is not before VMA's start within the region */ + if (pfn_offset_in_region < vma_offset_in_region) + return -EFAULT; + + /* Calculate offset from VMA start */ + *pgoff =3D vma->vm_pgoff + + (pfn_offset_in_region - vma_offset_in_region); + + return 0; +} + +static int +nvgrace_gpu_vfio_pci_register_pfn_range(struct vfio_device *core_vdev, + struct mem_region *region) +{ + int ret; + unsigned long pfn, nr_pages; + + pfn =3D PHYS_PFN(region->memphys); + nr_pages =3D region->memlength >> PAGE_SHIFT; + + region->pfn_address_space.node.start =3D pfn; + region->pfn_address_space.node.last =3D pfn + nr_pages - 1; + region->pfn_address_space.mapping =3D core_vdev->inode->i_mapping; + region->pfn_address_space.pfn_to_vma_pgoff =3D nvgrace_gpu_pfn_to_vma_pgo= ff; + + ret =3D register_pfn_address_space(®ion->pfn_address_space); + + return ret; +} + static int nvgrace_gpu_open_device(struct vfio_device *core_vdev) { struct vfio_pci_core_device *vdev =3D @@ -114,14 +193,28 @@ static int nvgrace_gpu_open_device(struct vfio_device= *core_vdev) * memory mapping. */ ret =3D vfio_pci_core_setup_barmap(vdev, 0); - if (ret) { - vfio_pci_core_disable(vdev); - return ret; + if (ret) + goto error_exit; + + if (nvdev->resmem.memlength) { + ret =3D nvgrace_gpu_vfio_pci_register_pfn_range(core_vdev, &nvdev->resme= m); + if (ret && ret !=3D -EOPNOTSUPP) + goto error_exit; } =20 - vfio_pci_core_finish_enable(vdev); + ret =3D nvgrace_gpu_vfio_pci_register_pfn_range(core_vdev, &nvdev->usemem= ); + if (ret && ret !=3D -EOPNOTSUPP) + goto register_mem_failed; =20 + vfio_pci_core_finish_enable(vdev); return 0; + +register_mem_failed: + if (nvdev->resmem.memlength) + unregister_pfn_address_space(&nvdev->resmem.pfn_address_space); +error_exit: + vfio_pci_core_disable(vdev); + return ret; } =20 static void nvgrace_gpu_close_device(struct vfio_device *core_vdev) @@ -130,6 +223,11 @@ static void nvgrace_gpu_close_device(struct vfio_devic= e *core_vdev) container_of(core_vdev, struct nvgrace_gpu_pci_core_device, core_device.vdev); =20 + if (nvdev->resmem.memlength) + unregister_pfn_address_space(&nvdev->resmem.pfn_address_space); + + unregister_pfn_address_space(&nvdev->usemem.pfn_address_space); + /* Unmap the mapping to the device memory cached region */ if (nvdev->usemem.memaddr) { memunmap(nvdev->usemem.memaddr); @@ -247,6 +345,16 @@ static const struct vm_operations_struct nvgrace_gpu_v= fio_pci_mmap_ops =3D { #endif }; =20 +static inline +struct nvgrace_gpu_pci_core_device *vma_to_nvdev(struct vm_area_struct *vm= a) +{ + /* Check if this VMA belongs to us */ + if (vma->vm_ops !=3D &nvgrace_gpu_vfio_pci_mmap_ops) + return NULL; + + return vma->vm_private_data; +} + static int nvgrace_gpu_mmap(struct vfio_device *core_vdev, struct vm_area_struct *vma) { --=20 2.34.1