Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] iommu/rockchip: >4 GiB reserved regions silently alias in rk_iommu_map() --
commit a62eae58527cef7e91d832e94bf0e1249fddc4d9 Author: Francesco Saverio Pavone <[email protected]> iommu/rockchip: Report the reserved regions from the devicetree This commit wires of_iommu_get_resv_regions() into rk_iommu_ops so that devicetree reserved-memory regions listed in iommu-addresses are reported for Rockchip IOMMUs. > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > index 1fa3110b142ad..757532a86975c 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c [ ... ] > @@ -1204,6 +1205,7 @@ static const struct iommu_ops rk_iommu_ops = { > .probe_device = rk_iommu_probe_device, > .release_device = rk_iommu_release_device, > .device_group = generic_single_device_group, > + .get_resv_regions = of_iommu_get_resv_regions, [Severity: Medium] Can a devicetree reserved region at or above 4 GiB silently alias into the low 32-bit IOVA space here? iommu_create_device_direct_mappings() passes the 64-bit addresses from of_iommu_get_resv_regions() straight to rk_iommu_iova_to_phys() and rk_iommu_map() without checking domain->geometry.aperture_end. Because rk_iova_dte_index() masks the IOVA with 0xffc00000 and casts to u32, bits 63:32 are silently discarded. On a 64-bit board with >4 GiB RAM, a reserved region at or above 4 GiB installs PTEs at the wrapped low 32-bit IOVA and returns 0 instead of failing. Meanwhile, iova_reserve_iommu_regions() reserves the >4 GiB PFN range, leaving the aliased low IOVAs unreserved. Later DMA allocations in that range fail with -EADDRINUSE, and DMA to unallocated low IOVAs (including IOVA 0 for a 4 GiB-aligned region) silently hits the reserved memory. A Rockchip get_resv_regions wrapper could filter out regions above DMA_BIT_MASK(32), alongside bounds checks in rk_iommu_map(), rk_iommu_unmap(), and rk_iommu_iova_to_phys() for the IOVA aperture and physical address width. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
