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: <8ff02f5a-fa66-4403-b193-a18c23879e0d@sirena.org.uk>
Date: Wed, 26 Mar 2025 16:20:22 +0000
From: Mark Brown <broonie@...nel.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Petr Tesarik <ptesarik@...e.com>,
	Grant Likely <grant.likely@...retlab.ca>,
	linux-kernel@...r.kernel.org, linux-spi@...r.kernel.org
Subject: Re: [PATCH] spi: Ensure memory used for spi_write_then_read() is DMA
 safe

On Fri, Mar 21, 2025 at 08:42:12PM +0100, Arnd Bergmann wrote:
> On Fri, Mar 21, 2025, at 15:45, Mark Brown wrote:

> > Hrm, right.  I think that usage is reasonable so we probably should
> > allow it rather than forcing things to do an allocation for a transfer
> > that ends up being PIOed anyway almost all the time, OTOH the same API
> > is also used for large transfers like firmware downloads where we don't
> > want to trigger a spurious copy.  Having different requirements at
> > different times would be miserable though so I think we need to just
> > accept any buffer and then figure it out inside the API, but I've not
> > fully thought that through yet.

> My feeling so far is that we want the default regmap interface
> to just take any buffer (stack, misaligned, vmalloc, kmap) and
> leave it up to the underlying bus to make sure this works in
> a sensible way.

Definitely for regmap, I was thinking about the implementation of that -
it feels like something other places will want to do.

> Using dma_alloc_noncoherent() should make the implementation
> much nicer than GFP_DMA in the past, so we could add a bus
> specific helper for SPI that checks if the controller actually
> wants to do DMA and whether the buffer is problematic at all,
> and then decides to either allocate a bounce buffer and
> fill the sg table with the correct DMA address, map the
> existing buffer, or pass it without mapping depending on
> what the device needs.

That query feels a lot like spi_optimize_message().  Which should
possibly then just do the bouncing if it's needed.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ