Skip to content

Commit f7403ab

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/io-pgtable: Abstract iommu_iotlb_gather access
Previously io-pgtable merely passed the iommu_iotlb_gather pointer through to helpers, but now it has grown its own direct dereference. This turns out to break the build for !IOMMU_API configs where the structure only has a dummy definition. It will probably also crash drivers who don't use the gather mechanism and simply pass in NULL. Wrap this dereference in a suitable helper which can both be stubbed out for !IOMMU_API and encapsulate a NULL check otherwise. Fixes: 7a7c5ba ("iommu: Indicate queued flushes via gather data") Reported-by: kernel test robot <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/83672ee76f6405c82845a55c148fa836f56fbbc1.1629465282.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 452e69b commit f7403ab

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

drivers/iommu/io-pgtable-arm-v7s.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ static size_t __arm_v7s_unmap(struct arm_v7s_io_pgtable *data,
700700
ARM_V7S_BLOCK_SIZE(lvl + 1));
701701
ptep = iopte_deref(pte[i], lvl, data);
702702
__arm_v7s_free_table(ptep, lvl + 1, data);
703-
} else if (!gather->queued) {
703+
} else if (!iommu_iotlb_gather_queued(gather)) {
704704
io_pgtable_tlb_add_page(iop, gather, iova, blk_size);
705705
}
706706
iova += blk_size;

drivers/iommu/io-pgtable-arm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
638638
io_pgtable_tlb_flush_walk(iop, iova + i * size, size,
639639
ARM_LPAE_GRANULE(data));
640640
__arm_lpae_free_pgtable(data, lvl + 1, iopte_deref(pte, data));
641-
} else if (!gather->queued) {
641+
} else if (!iommu_iotlb_gather_queued(gather)) {
642642
io_pgtable_tlb_add_page(iop, gather, iova + i * size, size);
643643
}
644644

include/linux/iommu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,
548548
gather->start = start;
549549
}
550550

551+
static inline bool iommu_iotlb_gather_queued(struct iommu_iotlb_gather *gather)
552+
{
553+
return gather && gather->queued;
554+
}
555+
551556
/* PCI device grouping function */
552557
extern struct iommu_group *pci_device_group(struct device *dev);
553558
/* Generic device grouping function */
@@ -896,6 +901,11 @@ static inline void iommu_iotlb_gather_add_page(struct iommu_domain *domain,
896901
{
897902
}
898903

904+
static inline bool iommu_iotlb_gather_queued(struct iommu_iotlb_gather *gather)
905+
{
906+
return false;
907+
}
908+
899909
static inline void iommu_device_unregister(struct iommu_device *iommu)
900910
{
901911
}

0 commit comments

Comments
 (0)