Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1708259

Re: [PATCH] Introduce dmam_zalloc_coherent()

From Marek Szyprowski <m.szyprowski@samsung.com>
Newsgroups linux.kernel
Subject Re: [PATCH] Introduce dmam_zalloc_coherent()
Date 2017-08-10 09:00 +0200
Message-ID <ucPBL-1Uy-5@gated-at.bofh.it> (permalink)
References <uc8Q9-5YJ-3@gated-at.bofh.it> <ucPBL-1Uy-7@gated-at.bofh.it> <ucznk-7Gt-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Christoph,

On 2017-08-09 15:37, Christoph Hellwig wrote:
> On Tue, Aug 08, 2017 at 11:15:35AM +0200, Michael Moese wrote:
>> All memory allocation functions have a pendant for allocating zeroed
>> memory, but dmam_alloc_coherent does not have such a pendant.
>> However, it is easier to read dmam_zalloc_coherent than passing an extra
>> flag or, even worse, see memset() after the allocation.
>> This patch adds an inline function dmam_zalloc_coherent(), exactly like
>> the implementation of dma_zalloc_coherent().
> I'm a bit worried about the __GFP_ZERO as we have lots of non-kmalloc
> implementations of these.  But on the other hand we already implement
> dma_zalloc_coherent the same way, which means we'd already buggy.
>
> So I plan to apply this for 4.14, but I also plan to spend some time
> to implement all the existin alloc ops to make sure it's going to work
> fine.

Frankly, since introducing dma_mmap_coherent, dma_alloc_coherent already
clears allocated buffers to avoid potential information leak to userspace.
There are even drivers that rely on such behavior, see
http://lists.infradead.org/pipermail/linux-arm-kernel/2015-April/338804.html

Maybe it would make sense to properly document it and then convert
dma_zalloc* to standard dma_alloc_* calls?

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] Introduce dmam_zalloc_coherent() Michael Moese <michael.moese@men.de> - 2017-08-08 11:20 +0200
  Re: [PATCH] Introduce dmam_zalloc_coherent() Christoph Hellwig <hch@lst.de> - 2017-08-09 15:40 +0200
    Re: [PATCH] Introduce dmam_zalloc_coherent() Marek Szyprowski <m.szyprowski@samsung.com> - 2017-08-10 09:00 +0200
  Re: [PATCH] Introduce dmam_zalloc_coherent() kbuild test robot <lkp@intel.com> - 2017-08-09 19:50 +0200

csiph-web