[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171001080449.GB11843@lst.de>
Date: Sun, 1 Oct 2017 10:04:49 +0200
From: Christoph Hellwig <hch@....de>
To: Robin Murphy <robin.murphy@....com>
Cc: miles.chen@...iatek.com, Christoph Hellwig <hch@....de>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Andrew Morton <akpm@...ux-foundation.org>,
wsd_upstream@...iatek.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, iommu@...ts.linux-foundation.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v3] dma-debug: fix incorrect pfn calculation
On Wed, Sep 27, 2017 at 11:23:52AM +0100, Robin Murphy wrote:
> > I found that debug_dma_alloc_coherent() and debug_dma_free_coherent()
> > assume that dma_alloc_coherent() always returns a linear address.
> > However it's possible that dma_alloc_coherent() returns a non-linear
> > address. In this case, page_to_pfn(virt_to_page(virt)) will return an
> > incorrect pfn. If the pfn is valid and mapped as a COW page,
> > we will hit the warning when doing wp_page_copy().
Hmm, can the debug code assume anything? Right now you're just patching
it from supporting linear and vmalloc. But what about other
potential mapping types?
> > + entry->pfn = is_vmalloc_addr(virt) ? vmalloc_to_pfn(virt) :
> > + page_to_pfn(virt_to_page(virt));
Please use normal if/else conditionsals:
if (is_vmalloc_addr(virt))
entry->pfn = vmalloc_to_pfn(virt);
else
entry->pfn = page_to_pfn(virt_to_page(virt));
> > + .pfn = is_vmalloc_addr(virt) ? vmalloc_to_pfn(virt) :
> > + page_to_pfn(virt_to_page(virt)),
Same here.
Powered by blists - more mailing lists