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]
Date:	Mon, 29 Jun 2015 11:37:37 +0100
From:	Catalin Marinas <catalin.marinas@....com>
To:	Lorenzo Nava <lorenx4@...il.com>
Cc:	linux-arm-kernel@...ts.infradead.org,
	Russell King - ARM Linux <linux@....linux.org.uk>,
	linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>
Subject: Re: [RFC PATCH v3] arm DMA: Fix allocation from CMA for coherent DMA

On Sun, Jun 28, 2015 at 10:14:43PM +0200, Lorenzo Nava wrote:
> On Fri, Jun 26, 2015 at 6:25 PM, Catalin Marinas
> <catalin.marinas@....com> wrote:
> > On Thu, Jun 18, 2015 at 11:44:22PM +0200, Lorenzo Nava wrote:
> >> @@ -680,9 +694,14 @@ void *arm_dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
> >>  static void *arm_coherent_dma_alloc(struct device *dev, size_t size,
> >>       dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs)
> >>  {
> >> -     pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL);
> >> +     pgprot_t prot;
> >>       void *memory;
> >>
> >> +     if (attrs == NULL)
> >> +              prot  = PAGE_KERNEL;
> >> +     else
> >> +              prot  = __get_dma_pgprot(attrs, PAGE_KERNEL);
> >> +
> >>       if (dma_alloc_from_coherent(dev, size, handle, &memory))
> >>               return memory;
> >
> > I still think this is the wrong way to fix. It doesn't address the
> > coherent dma mmap operation. I already replied on the previous version
> > that we should rather have an extra argument "coherent" to
> > __get_dma_pgprot().
>
> I avoided touching the __get_dma_pgprot() function because it affects
> a lot of different functions.
> If you think that the implementation you suggested in previous reply
> was ok and doesn't introduce problems on the other functions using the
> __get_dma_pgprot(), for me it's of course ok as well.

I forgot about the arm_dma_mmap fix here:

https://lkml.org/lkml/2015/5/7/512

So we either fix both cases by changing __get_dma_pgprot() or just go
for Mike's and your patches as above. It's up to Russell.

At some point, we could do with some more clean-up in the dma-mapping.c.
For example, both __alloc_simple_buffer() and __alloc_from_contiguous()
end up calling __dma_clear_buffer() even when not necessary (cacheable
mapping). Not too bad though as this is only done when setting up the
buffer.

> Do you see any code that maybe need a double check: I'm thinking, for
> example, at the function arm_iommu_alloc_attrs() and
> arm_iommu_mmap_attrs()?

I think this has bigger problems. The code seems to only be right for
non-cacheable mappings. For cacheable/coherent iommu mappings, I don't
see any use of the IOMMU_CACHE attribute (should it be returned by
__dma_direction_to_prot?).

-- 
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ