Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 62bdcef8 authored by Chintan Pandya's avatar Chintan Pandya
Browse files

iommu: msm: Verify page table corruption when page fault happens



Page faults often leads to doubt of either page table corruption
in DDR or the malfunctioning of the IOMMU. To rule out that, we
can walk through the page tables and get actual translation with
the faulty VA. If physical address from the page table is expected,
we can doubt IOMMU malfunctioning, or otherwise, page table
corruption.

Change-Id: Icef69e7a50ce3110fc83ca75b4a984057336b5bb
Signed-off-by: default avatarChintan Pandya <cpandya@codeaurora.org>
parent 74145190
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -1299,6 +1299,9 @@ irqreturn_t msm_iommu_fault_handler_v2(int irq, void *dev_id)
	unsigned int fsr;
	int ret;

	phys_addr_t pagetable_phys;
	u64 faulty_iova = 0;

	mutex_lock(&msm_iommu_lock);

	BUG_ON(!pdev);
@@ -1333,11 +1336,14 @@ irqreturn_t msm_iommu_fault_handler_v2(int irq, void *dev_id)
		if (!ctx_drvdata->attached_domain) {
			pr_err("Bad domain in interrupt handler\n");
			ret = -ENOSYS;
		} else
		} else {
			faulty_iova =
				GET_FAR(drvdata->cb_base, ctx_drvdata->num);
			ret = report_iommu_fault(ctx_drvdata->attached_domain,
				&ctx_drvdata->pdev->dev,
				GET_FAR(drvdata->cb_base, ctx_drvdata->num), 0);
				faulty_iova, 0);

		}
		if (ret == -ENOSYS) {
			pr_err("Unexpected IOMMU page fault!\n");
			pr_err("name = %s\n", drvdata->name);
@@ -1346,6 +1352,14 @@ irqreturn_t msm_iommu_fault_handler_v2(int irq, void *dev_id)
			pr_err("Interesting registers:\n");
			__print_ctx_regs(drvdata->cb_base,
					ctx_drvdata->num, fsr);

			if (ctx_drvdata->attached_domain) {
				pagetable_phys = msm_iommu_iova_to_phys_soft(
					ctx_drvdata->attached_domain,
					faulty_iova);
				pr_err("Page table in DDR shows PA = %x\n",
					(unsigned int) pagetable_phys);
			}
		}

		if (ret != -EBUSY)