[RFC PATCH] crypto: flush poison data
LABBE Corentin
clabbe at baylibre.com
Tue Jul 5 10:56:11 PDT 2022
Le Tue, Jul 05, 2022 at 06:42:13PM +0200, Christoph Hellwig a écrit :
> On Tue, Jul 05, 2022 at 10:21:13AM +0200, LABBE Corentin wrote:
> >
> > I just copied what did drivers/crypto/xilinx/zynqmp-sha.c.
> > I tried to do flush_dcache_range() but it seems to not be implemented on riscV.
>
> That driver is broken and should no have been merged in that form.
>
> > And flush_dcache_page(virt_to_page(addr), len) produce a kernel panic.
>
> And that's good so. Drivers have no business doing their own cache
> flushing. That is the job of the dma-mapping implementation, so I'd
> suggest to look for problems there.
I am sorry but this code is not in driver but in crypto API code.
It seems that I didnt explain well the problem.
The crypto API run a number of crypto operations against every driver that register crypto algos.
For each buffer given to the tested driver, crypto API setup a poison buffer contigous to this buffer.
The goal is to detect if driver do bad thing outside of buffer it got.
So the tested driver dont know existence of this poison buffer and so cannot not handle it.
My problem is that a dma_sync on the data buffer corrupt the poison buffer as collateral dommage.
Probably because the sync operate on a larger region than the requested dma_sync length.
So I try to flush poison data in the cryptoAPI.
Any hint on how to do it properly is welcome.
More information about the linux-riscv
mailing list