dma_zalloc_coherent broken with 57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7
Hi,
commit 57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7 broke usage of dma allocations specifying __GFP_ZERO by silently removing that flag.
Why should "the memory returned [] always be zeroed."?
Regards,
Sebastian
Hi Sebastian,
Quoted 2 lines · Sebastian Ott
commit
57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7broke usage of dma allocations specifying__GFP_ZEROby silently removing that flag.
How did it break? The flag is now always added.
Quoted 1 line
Why should "the memory returned [] always be zeroed."?
To avoid leaking information.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hello Geert,
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines · Sebastian Ott
commit
57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7broke usage of dma allocations specifying__GFP_ZEROby silently removing that flag.How did it break? The flag is now always added.
+ flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM | __GFP_ZERO);
I read that as a removal. But maybe I need more coffee..
Sebastian
Hi Sebastian,
Quoted 11 lines · Sebastian Ott
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines · Sebastian Ott
commit
57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7broke usage of dma allocations specifying__GFP_ZEROby silently removing that flag.How did it break? The flag is now always added.
+ flag &= ~(__GFP_DMA |
__GFP_DMA32|__GFP_HIGHMEM|__GFP_ZERO);I read that as a removal. But maybe I need more coffee..
Sorry, you're right.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 6 lines · Sebastian Ott
Hi,
commit
57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7broke usage of dma allocations specifying__GFP_ZEROby silently removing that flag.Why should "the memory returned [] always be zeroed."?
Because that is what the current implementations do - we always zero the memory returned from dma_map_ops.alloc().
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Sebastian Ott
Hi,
commit
57bf5a8963f80fb3828c46c3e3a5b2dd790e09a7broke usage of dma allocations specifying__GFP_ZEROby silently removing that flag.Why should "the memory returned [] always be zeroed."?
Because that is what the current implementations do - we always zero the memory returned from
dma_map_ops.alloc().
What do you mean by current implementations? Arch specific code? At least on s390 we don't do that. dma-mapping.h doesn't do it either.
Sebastian
Quoted 2 lines · Sebastian Ott
What do you mean by current implementations? Arch specific code? At least on s390 we don't do that.
dma-mapping.hdoesn't do it either.
The arch implementations should do it. Seems like s390 and potentially a few others don't. I'm a little slow due to a cast on one arm, but I'll do an audit and will fix up anything I'll find.
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Sebastian Ott
What do you mean by current implementations? Arch specific code? At least on s390 we don't do that.
dma-mapping.hdoesn't do it either.The arch implementations should do it. Seems like s390 and potentially a few others don't. I'm a little slow due to a cast on one arm, but I'll do an audit and will fix up anything I'll find.
What was wrong with the old behavior (let the caller decide - the same as with memory allocations)? We have interfaces like dma_zalloc_coherent, which explicitely set __GFP_ZERO. We have callers of dma_alloc followed by a manually memset..
Sebastian
Quoted 2 lines · Sebastian Ott
What was wrong with the old behavior (let the caller decide - the same as with memory allocations)?
The old behavior on most (all?) mainstream architectures is that we always zero the return value. On x86/i386 this goes back to at least Linux 2.4. So common drivers simply expect this to happen.