ppc32 copy_to_user dcbt fixup
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Bryan Rittmeyer
copy_tofrom_userandcopy_pageuse dcbt to prefetch source data [1]. Since at least 2.4.17, these functions have been prefetching beyond the end of the source buffer, leading to two problems:1. Subtly broken software cache coherency. If the area following src was invalidate_dcache_range'd prior to submitting for DMA, an out-of-bounds dcbt from
copy_to_userof a separate slab object may read in the area before DMA completion. When the DMA does complete, data will not be loaded from RAM because stale data is already in cache. Thus you get a corrupt network packet, bogus audio capture, etc.
[snip]
I am no expert on the ppc arch, but in my humble opinion it seems strange to invalidate the dcache *before* the memory-writing DMA-transaction. The obvious solution is to invalidate the dcache *after* DMA completion. It seems hard to guarantee that nobody will touch the memory area in question during the DMA.
Just some clue-less comments from a linux-kernel lurker.
Regards,
Danjel
Quoted 3 lines · Danjel McGougan
The obvious solution is to invalidate the dcache
*after* DMA completion. It seems hard to guarantee that nobody will touch the memory area in question during the DMA.
You need to invalidate prior to submitting for DMA. Otherwise if the region is dirty the CPU may write back after DMA has begun, causing a data corrupting race.
Invalidating before _and_ after is expensive; better to fix the misreads.
-Bryan