From e67a5db8362d196a83e17a71598f1a39a6c853d1 Mon Sep 17 00:00:00 2001 From: leoliu-oc Date: Wed, 29 Oct 2025 14:52:59 +0800 Subject: [PATCH] anolis: iommu/vt-d: fix NULL pointer issue in acpi_rmrr_andd_probe ANBZ: #26811 When the dev->iommu was NULL for the RMRR ANDD device, the corresponding (&pci_device->dev)->iommu could be used instead. Signed-off-by: leoliu-oc --- drivers/iommu/dma-iommu.c | 6 ++++++ drivers/iommu/intel/iommu.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index d62f7c6f9a5d..1c6bf85a0dcf 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -553,6 +553,12 @@ int iova_reserve_domain_addr(struct iommu_domain *domain, dma_addr_t start, dma_ unsigned long lo, hi; + if (!iovad->granule) { + unsigned long order = __ffs(domain->pgsize_bitmap); + + iovad->granule = 1UL << order; + } + lo = iova_pfn(iovad, start); hi = iova_pfn(iovad, end); diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 88a4e5649207..2802654406b9 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -3031,6 +3031,10 @@ static inline int acpi_rmrr_andd_probe(struct device *dev) pr_info("dpoint-- cannot get acpi devie corresponding pci_device\n"); return -EINVAL; } + + if (!dev->iommu) + dev->iommu = (&pci_device->dev)->iommu; + ret = acpi_rmrr_device_create_direct_mappings(iommu_get_domain_for_dev(&pci_device->dev), dev); -- Gitee