Skip to content

Commit be8301e

Browse files
hegdevasantgregkh
authored andcommitted
iommu/amd: Improve page fault error reporting
commit 996d120 upstream. If IOMMU domain for device group is not setup properly then we may hit IOMMU page fault. Current page fault handler assumes that domain is always setup and it will hit NULL pointer derefence (see below sample log). Lets check whether domain is setup or not and log appropriate message. Sample log: ---------- amdgpu 0000:00:01.0: amdgpu: SE 1, SH per SE 1, CU per SH 8, active_cu_number 6 BUG: kernel NULL pointer dereference, address: 0000000000000058 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI CPU: 2 PID: 56 Comm: irq/24-AMD-Vi Not tainted 6.2.0-rc2+ #89 Hardware name: xxx RIP: 0010:report_iommu_fault+0x11/0x90 [...] Call Trace: <TASK> amd_iommu_int_thread+0x60c/0x760 ? __pfx_irq_thread_fn+0x10/0x10 irq_thread_fn+0x1f/0x60 irq_thread+0xea/0x1a0 ? preempt_count_add+0x6a/0xa0 ? __pfx_irq_thread_dtor+0x10/0x10 ? __pfx_irq_thread+0x10/0x10 kthread+0xe9/0x110 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x2c/0x50 </TASK> Reported-by: Matt Fagnani <[email protected]> Suggested-by: Joerg Roedel <[email protected]> Signed-off-by: Vasant Hegde <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216865 Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] [joro: Edit commit message] Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2ae19ac commit be8301e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,15 @@ static void amd_iommu_report_page_fault(struct amd_iommu *iommu,
558558
* prevent logging it.
559559
*/
560560
if (IS_IOMMU_MEM_TRANSACTION(flags)) {
561+
/* Device not attached to domain properly */
562+
if (dev_data->domain == NULL) {
563+
pr_err_ratelimited("Event logged [Device not attached to domain properly]\n");
564+
pr_err_ratelimited(" device=%04x:%02x:%02x.%x domain=0x%04x\n",
565+
iommu->pci_seg->id, PCI_BUS_NUM(devid), PCI_SLOT(devid),
566+
PCI_FUNC(devid), domain_id);
567+
goto out;
568+
}
569+
561570
if (!report_iommu_fault(&dev_data->domain->domain,
562571
&pdev->dev, address,
563572
IS_WRITE_REQUEST(flags) ?

0 commit comments

Comments
 (0)