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]
Message-ID: <e6bd415a-201a-b3e3-48f0-beeff91f3b7a@huawei.com>
Date:   Sun, 20 Nov 2022 10:58:40 +0800
From:   Nanyong Sun <sunnanyong@...wei.com>
To:     Robin Murphy <robin.murphy@....com>,
        Ard Biesheuvel <ardb@...nel.org>
CC:     <will@...nel.org>, <catalin.marinas@....com>,
        <sstabellini@...nel.org>, <jgross@...e.com>,
        <oleksandr_tyshchenko@...m.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <wangkefeng.wang@...wei.com>,
        <linux@...linux.org.uk>
Subject: Re: [RFC PATCH] arm64: mm: Add invalidate back in
 arch_sync_dma_for_device when FROM_DEVICE

On 2022/11/17 18:23, Robin Murphy wrote:

> On 2022-11-17 08:24, Ard Biesheuvel wrote:
>> On Thu, 17 Nov 2022 at 07:33, Nanyong Sun <sunnanyong@...wei.com> wrote:
>>>
>>> The commit c50f11c6196f ("arm64: mm: Don't invalidate FROM_DEVICE
>>> buffers at start of DMA transfer") replaces invalidate with clean
>>> when DMA_FROM_DEVICE, this changes the behavior of functions like
>>> dma_map_single() and dma_sync_single_for_device(*, *, *, 
>>> DMA_FROM_DEVICE),
>>> then it may make some drivers works unwell because the implementation
>>> of these DMA APIs lose the original cache invalidation.
>>>
>>> Situation 1:
>> ...
>>> Situation 2:
>>> After backporting the above commit, we find a network card driver go
>>> wrong with cache inconsistency when doing DMA transfer: CPU got the
>>> stale data in cache when reading DMA data received from device.
>>
>> I suppose this means those drivers may lack dma_sync_single_for_cpu()
>> calls after the inbound transfers complete, and are instead relying on
>> the cache invalidation performed before the transfer to make the DMA'd
>> data visible to the CPU.
>
> It also commonly goes wrong the other way round when the drivers are 
> correct but DT/ACPI failed to indicate a coherent device as such. If 
> writes from the device actually snoop, they hit the still-present 
> cache line, which then gets invalidated by unmap/sync_for_cpu and the 
> new data is lost.
>
> Robin.
>
> .
Is it acceptable?  Does the coherent device MUST run with coherent 
identifier? At least they can run with no wrong before.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ