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: <20120105.162930.604365154868332443.hdoyu@nvidia.com>
Date:	Thu, 5 Jan 2012 15:29:30 +0100
From:	Hiroshi Doyu <hdoyu@...dia.com>
To:	"linux@....linux.org.uk" <linux@....linux.org.uk>
CC:	"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
	"linaro-mm-sig-bounces@...ts.linaro.org" 
	<linaro-mm-sig-bounces@...ts.linaro.org>,
	"iommu@...ts.linux-foundation.org" <iommu@...ts.linux-foundation.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-arm-kernel@...ts.infradead.org" 
	<linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH v3 0/2] ARM: IOMMU: tegra: Add iommu_ops for GART/SMMU
 driver

Hi Russell,

From: Russell King - ARM Linux <linux@....linux.org.uk>
Subject: Re: [PATCH v3 0/2] ARM: IOMMU: tegra: Add iommu_ops for GART/SMMU driver
Date: Thu, 5 Jan 2012 13:53:26 +0100
Message-ID: <20120105125326.GT11810@...00.arm.linux.org.uk>

> On Thu, Jan 05, 2012 at 09:17:18AM +0200, Hiroshi Doyu wrote:
> > Just for DMA mapping test from MPU side, the following one is used.
>
> This patch is buggy.
>
> > +static void dmaapi_test_map_page(struct device *dev)
> > +{
> > +	struct page *page;
> > +	dma_addr_t dma_addr;
> > +	void *cpu_addr;
> > +
> > +	page = alloc_page(GFP_KERNEL);
> > +	BUG_ON(!page);
> > +
> > +	dma_addr = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_TO_DEVICE);
> > +	BUG_ON(!dma_addr);
> > +
> > +	cpu_addr = kmap(page);
> > +	BUG_ON(!cpu_addr);
> > +	memset(cpu_addr, 0xa5, PAGE_SIZE);
> > +	kunmap(cpu_addr);
>
> The DMA API works like this:
>
> - The CPU owns the page or buffer and can access it.
> - You map the page or buffer.
> - The device owns the page or buffer; the CPU must explicitly access it.
> - You unmap the page or buffer.
> - The CPU again owns the page/buffer and can access it.
>
> Please respect the DMA API rules.

Right, I do.

> So.  Once dma_map_page() has returned, you must not kmap() or otherwise
> access the data contained in that page until after you have unmapped it.

Ok, the above function order should be as below?

  page = alloc_page(GFP_KERNEL);
      cpu_addr = kmap(page);
      memset(cpu_addr, 0xa5, PAGE_SIZE);
  	dma_addr = dma_map_page(dev, page, 0, PAGE_SIZE, DMA_TO_DEVICE);
  	    < expect GPU does something >
  	dma_unmap_page(dev, dma_addr, PAGE_SIZE, DMA_TO_DEVICE);
      < CPU can access data here again>
      kunmap(cpu_addr);
  __free_page(page);
--
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