lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 27 Jan 2021 19:31:17 +0000
From:   Robin Murphy <robin.murphy@....com>
To:     Rob Herring <robh+dt@...nel.org>, Yong Wu <yong.wu@...iatek.com>
Cc:     devicetree@...r.kernel.org,
        Nicolas Boichat <drinkcat@...omium.org>,
        srv_heupstream <srv_heupstream@...iatek.com>,
        Will Deacon <will@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Krzysztof Kozlowski <krzk@...nel.org>,
        Paul Kocialkowski <paul.kocialkowski@...tlin.com>,
        Tomasz Figa <tfiga@...gle.com>,
        Linux IOMMU <iommu@...ts.linux-foundation.org>,
        "moderated list:ARM/Mediatek SoC support" 
        <linux-mediatek@...ts.infradead.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v2] of/device: Update dma_range_map only when dev has
 valid dma-ranges

On 2021-01-27 19:07, Rob Herring wrote:
> On Tue, Jan 19, 2021 at 4:52 AM Yong Wu <yong.wu@...iatek.com> wrote:
>>
>> The commit e0d072782c73 ("dma-mapping: introduce DMA range map,
>> supplanting dma_pfn_offset") always update dma_range_map even though it was
>> already set, like in the sunxi_mbus driver. the issue is reported at [1].
>> This patch avoid this(Updating it only when dev has valid dma-ranges).
> 
> only when dev *doesn't* have valid dma-ranges?

I believe the intent is to mean when a valid "dma-ranges" property is 
specified in DT. The implementation allows DT to take precedence even if 
platform code *has* already installed a dma_range_map, although we 
shouldn't expect that to ever happen (except perhaps in the wild early 
days of platform bringup).

Robin.

>> Meanwhile, dma_range_map contains the devices' dma_ranges information,
>> This patch moves dma_range_map before of_iommu_configure. The iommu
>> driver may need to know the dma_address requirements of its iommu
>> consumer devices.
>>
>> [1] https://lore.kernel.org/linux-arm-kernel/5c7946f3-b56e-da00-a750-be097c7ceb32@arm.com/
>>
>> CC: Rob Herring <robh+dt@...nel.org>
>> CC: Frank Rowand <frowand.list@...il.com>
>> Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset"),
>> Suggested-by: Robin Murphy <robin.murphy@....com>
>> Signed-off-by: Yong Wu <yong.wu@...iatek.com>
>> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@...tlin.com>
>> Reviewed-by: Rob Herring <robh@...nel.org>
>> ---
>>   drivers/of/device.c | 10 +++++++---
>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/of/device.c b/drivers/of/device.c
>> index aedfaaafd3e7..1122daa8e273 100644
>> --- a/drivers/of/device.c
>> +++ b/drivers/of/device.c
>> @@ -162,9 +162,11 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
>>          mask = DMA_BIT_MASK(ilog2(end) + 1);
>>          dev->coherent_dma_mask &= mask;
>>          *dev->dma_mask &= mask;
>> -       /* ...but only set bus limit if we found valid dma-ranges earlier */
>> -       if (!ret)
>> +       /* ...but only set bus limit and range map if we found valid dma-ranges earlier */
>> +       if (!ret) {
>>                  dev->bus_dma_limit = end;
>> +               dev->dma_range_map = map;
>> +       }
>>
>>          coherent = of_dma_is_coherent(np);
>>          dev_dbg(dev, "device is%sdma coherent\n",
>> @@ -172,6 +174,9 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
>>
>>          iommu = of_iommu_configure(dev, np, id);
>>          if (PTR_ERR(iommu) == -EPROBE_DEFER) {
>> +               /* Don't touch range map if it wasn't set from a valid dma-ranges */
>> +               if (!ret)
>> +                       dev->dma_range_map = NULL;
>>                  kfree(map);
>>                  return -EPROBE_DEFER;
>>          }
>> @@ -181,7 +186,6 @@ int of_dma_configure_id(struct device *dev, struct device_node *np,
>>
>>          arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
>>
>> -       dev->dma_range_map = map;
>>          return 0;
>>   }
>>   EXPORT_SYMBOL_GPL(of_dma_configure_id);
>> --
>> 2.18.0
>>
> _______________________________________________
> iommu mailing list
> iommu@...ts.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ