From: Christoph Hellwig <hch@lst.de>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Shawn Anastasio <shawn@anastas.io>,
Catalin Marinas <catalin.marinas@arm.com>,
linuxppc-dev@lists.ozlabs.org,
Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Michael Ellerman <mpe@ellerman.id.au>,
Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_*
Date: Wed, 7 Aug 2019 08:14:02 +0200 [thread overview]
Message-ID: <20190807061402.GE6627@lst.de> (raw)
In-Reply-To: <20190806164503.GD1330@shell.armlinux.org.uk>
On Tue, Aug 06, 2019 at 05:45:03PM +0100, Russell King - ARM Linux admin wrote:
> We could have used a different approach, making all IO writes contain
> a "drain write buffer" instruction, and map DMA memory as "buffered",
> but as there were no Linux barriers defined to order memory accesses
> to DMA memory (so, for example, ring buffers can be updated in the
> correct order) back in those days, using the uncached/unbuffered mode
> was the sanest and most reliable solution.
Absolutely makes sense so far.
> > > The other really weird things is that in arm32
> > > pgprot_dmacoherent incudes the L_PTE_XN bit, which from my understanding
> > > is the no-execture bit, but pgprot_writecombine does not. This seems to
> > > not very unintentional. So minus that the whole DMA_ATTR_WRITE_COMBІNE
> > > seems to be about flagging old arm specific drivers as having the proper
> > > barriers in places and otherwise is a no-op.
> >
> > I think it only matters for Armv7 CPUs, but yes, we should probably be
> > setting L_PTE_XN for both of these memory types.
>
> Conventionally, pgprot_writecombine() has only been used to change
> the memory type and not the permissions. Since writecombine memory
> is still capable of being executed, I don't see any reason to set XN
> for it.
>
> If the user wishes to mmap() using PROT_READ|PROT_EXEC, then is there
> really a reason for writecombine to set XN overriding the user?
>
> That said, pgprot_writecombine() is mostly used for framebuffers, which
> arguably shouldn't be executable anyway - but who'd want to mmap() the
> framebuffer with PROT_EXEC?
Well, I was mostly taking about DMA_ATTR_WRITE_COMBINE, which really
should include the NX bit even if pgprot_writecombine doesn't, right?
> > > - make DMA_ATTR_WRITE_COMBINE a no-op and schedule it for removal,
> > > thus removing the last instances of arch_dma_mmap_pgprot
> >
> > All sounds good to me, although I suppose 32-bit Arm platforms without
> > CONFIG_ARM_DMA_MEM_BUFFERABLE may run into issues if DMA_ATTR_WRITE_COMBINE
> > disappears. Only one way to find out...
>
> Looking at the results of grep, I think only OMAP2+ and Exynos may be
> affected.
As you mentioned later we also have the dma_alloc_wc wrapper, and a
single instance of dma_alloc_writecombine.
Exynos looks like purely ARM v7 from Kconfig, so it shouldn't even be
affected.
> However, removing writecombine support from the DMA API is going to
> have a huge impact for framebuffers on earlier ARMs - that's where we
> do expect framebuffers to be mapped "uncached/buffered" for performance
> reasons and not "uncached/unbuffered". It's quite literally the
> difference between console scrolling being usable and totally unusable.
>
> Given what I've said above, switching to using buffered mode for normal
> DMA mappings is data-corrupting risky - as in your filesystem could get
> fried. I don't think we should play fast and loose with people's data
> by randomly changing that "because we'd like to", and I don't see that
> screwing the console is really an option either.
Oh well. If we can't make dma_alloc_wc generally safe I fear we'll
have to keep it, but maybe literally limit it to the pre ARM v6
platforms. While pretty much all callers seems platform specific,
there actually are a decent number that can only work on ARM v7 or
arm64.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Shawn Anastasio <shawn@anastas.io>,
Catalin Marinas <catalin.marinas@arm.com>,
linuxppc-dev@lists.ozlabs.org,
Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_*
Date: Wed, 7 Aug 2019 08:14:02 +0200 [thread overview]
Message-ID: <20190807061402.GE6627@lst.de> (raw)
In-Reply-To: <20190806164503.GD1330@shell.armlinux.org.uk>
On Tue, Aug 06, 2019 at 05:45:03PM +0100, Russell King - ARM Linux admin wrote:
> We could have used a different approach, making all IO writes contain
> a "drain write buffer" instruction, and map DMA memory as "buffered",
> but as there were no Linux barriers defined to order memory accesses
> to DMA memory (so, for example, ring buffers can be updated in the
> correct order) back in those days, using the uncached/unbuffered mode
> was the sanest and most reliable solution.
Absolutely makes sense so far.
> > > The other really weird things is that in arm32
> > > pgprot_dmacoherent incudes the L_PTE_XN bit, which from my understanding
> > > is the no-execture bit, but pgprot_writecombine does not. This seems to
> > > not very unintentional. So minus that the whole DMA_ATTR_WRITE_COMBІNE
> > > seems to be about flagging old arm specific drivers as having the proper
> > > barriers in places and otherwise is a no-op.
> >
> > I think it only matters for Armv7 CPUs, but yes, we should probably be
> > setting L_PTE_XN for both of these memory types.
>
> Conventionally, pgprot_writecombine() has only been used to change
> the memory type and not the permissions. Since writecombine memory
> is still capable of being executed, I don't see any reason to set XN
> for it.
>
> If the user wishes to mmap() using PROT_READ|PROT_EXEC, then is there
> really a reason for writecombine to set XN overriding the user?
>
> That said, pgprot_writecombine() is mostly used for framebuffers, which
> arguably shouldn't be executable anyway - but who'd want to mmap() the
> framebuffer with PROT_EXEC?
Well, I was mostly taking about DMA_ATTR_WRITE_COMBINE, which really
should include the NX bit even if pgprot_writecombine doesn't, right?
> > > - make DMA_ATTR_WRITE_COMBINE a no-op and schedule it for removal,
> > > thus removing the last instances of arch_dma_mmap_pgprot
> >
> > All sounds good to me, although I suppose 32-bit Arm platforms without
> > CONFIG_ARM_DMA_MEM_BUFFERABLE may run into issues if DMA_ATTR_WRITE_COMBINE
> > disappears. Only one way to find out...
>
> Looking at the results of grep, I think only OMAP2+ and Exynos may be
> affected.
As you mentioned later we also have the dma_alloc_wc wrapper, and a
single instance of dma_alloc_writecombine.
Exynos looks like purely ARM v7 from Kconfig, so it shouldn't even be
affected.
> However, removing writecombine support from the DMA API is going to
> have a huge impact for framebuffers on earlier ARMs - that's where we
> do expect framebuffers to be mapped "uncached/buffered" for performance
> reasons and not "uncached/unbuffered". It's quite literally the
> difference between console scrolling being usable and totally unusable.
>
> Given what I've said above, switching to using buffered mode for normal
> DMA mappings is data-corrupting risky - as in your filesystem could get
> fried. I don't think we should play fast and loose with people's data
> by randomly changing that "because we'd like to", and I don't see that
> screwing the console is really an option either.
Oh well. If we can't make dma_alloc_wc generally safe I fear we'll
have to keep it, but maybe literally limit it to the pre ARM v6
platforms. While pretty much all callers seems platform specific,
there actually are a decent number that can only work on ARM v7 or
arm64.
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Shawn Anastasio <shawn@anastas.io>,
Catalin Marinas <catalin.marinas@arm.com>,
linuxppc-dev@lists.ozlabs.org,
Robin Murphy <robin.murphy@arm.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
Michael Ellerman <mpe@ellerman.id.au>,
Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_*
Date: Wed, 7 Aug 2019 08:14:02 +0200 [thread overview]
Message-ID: <20190807061402.GE6627@lst.de> (raw)
In-Reply-To: <20190806164503.GD1330@shell.armlinux.org.uk>
On Tue, Aug 06, 2019 at 05:45:03PM +0100, Russell King - ARM Linux admin wrote:
> We could have used a different approach, making all IO writes contain
> a "drain write buffer" instruction, and map DMA memory as "buffered",
> but as there were no Linux barriers defined to order memory accesses
> to DMA memory (so, for example, ring buffers can be updated in the
> correct order) back in those days, using the uncached/unbuffered mode
> was the sanest and most reliable solution.
Absolutely makes sense so far.
> > > The other really weird things is that in arm32
> > > pgprot_dmacoherent incudes the L_PTE_XN bit, which from my understanding
> > > is the no-execture bit, but pgprot_writecombine does not. This seems to
> > > not very unintentional. So minus that the whole DMA_ATTR_WRITE_COMBІNE
> > > seems to be about flagging old arm specific drivers as having the proper
> > > barriers in places and otherwise is a no-op.
> >
> > I think it only matters for Armv7 CPUs, but yes, we should probably be
> > setting L_PTE_XN for both of these memory types.
>
> Conventionally, pgprot_writecombine() has only been used to change
> the memory type and not the permissions. Since writecombine memory
> is still capable of being executed, I don't see any reason to set XN
> for it.
>
> If the user wishes to mmap() using PROT_READ|PROT_EXEC, then is there
> really a reason for writecombine to set XN overriding the user?
>
> That said, pgprot_writecombine() is mostly used for framebuffers, which
> arguably shouldn't be executable anyway - but who'd want to mmap() the
> framebuffer with PROT_EXEC?
Well, I was mostly taking about DMA_ATTR_WRITE_COMBINE, which really
should include the NX bit even if pgprot_writecombine doesn't, right?
> > > - make DMA_ATTR_WRITE_COMBINE a no-op and schedule it for removal,
> > > thus removing the last instances of arch_dma_mmap_pgprot
> >
> > All sounds good to me, although I suppose 32-bit Arm platforms without
> > CONFIG_ARM_DMA_MEM_BUFFERABLE may run into issues if DMA_ATTR_WRITE_COMBINE
> > disappears. Only one way to find out...
>
> Looking at the results of grep, I think only OMAP2+ and Exynos may be
> affected.
As you mentioned later we also have the dma_alloc_wc wrapper, and a
single instance of dma_alloc_writecombine.
Exynos looks like purely ARM v7 from Kconfig, so it shouldn't even be
affected.
> However, removing writecombine support from the DMA API is going to
> have a huge impact for framebuffers on earlier ARMs - that's where we
> do expect framebuffers to be mapped "uncached/buffered" for performance
> reasons and not "uncached/unbuffered". It's quite literally the
> difference between console scrolling being usable and totally unusable.
>
> Given what I've said above, switching to using buffered mode for normal
> DMA mappings is data-corrupting risky - as in your filesystem could get
> fried. I don't think we should play fast and loose with people's data
> by randomly changing that "because we'd like to", and I don't see that
> screwing the console is really an option either.
Oh well. If we can't make dma_alloc_wc generally safe I fear we'll
have to keep it, but maybe literally limit it to the pre ARM v6
platforms. While pretty much all callers seems platform specific,
there actually are a decent number that can only work on ARM v7 or
arm64.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Cc: Will Deacon <will@kernel.org>, Christoph Hellwig <hch@lst.de>,
iommu@lists.linux-foundation.org,
Shawn Anastasio <shawn@anastas.io>,
Michael Ellerman <mpe@ellerman.id.au>,
Catalin Marinas <catalin.marinas@arm.com>,
Robin Murphy <robin.murphy@arm.com>,
linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma-mapping: fix page attributes for dma_mmap_*
Date: Wed, 7 Aug 2019 08:14:02 +0200 [thread overview]
Message-ID: <20190807061402.GE6627@lst.de> (raw)
In-Reply-To: <20190806164503.GD1330@shell.armlinux.org.uk>
On Tue, Aug 06, 2019 at 05:45:03PM +0100, Russell King - ARM Linux admin wrote:
> We could have used a different approach, making all IO writes contain
> a "drain write buffer" instruction, and map DMA memory as "buffered",
> but as there were no Linux barriers defined to order memory accesses
> to DMA memory (so, for example, ring buffers can be updated in the
> correct order) back in those days, using the uncached/unbuffered mode
> was the sanest and most reliable solution.
Absolutely makes sense so far.
> > > The other really weird things is that in arm32
> > > pgprot_dmacoherent incudes the L_PTE_XN bit, which from my understanding
> > > is the no-execture bit, but pgprot_writecombine does not. This seems to
> > > not very unintentional. So minus that the whole DMA_ATTR_WRITE_COMBІNE
> > > seems to be about flagging old arm specific drivers as having the proper
> > > barriers in places and otherwise is a no-op.
> >
> > I think it only matters for Armv7 CPUs, but yes, we should probably be
> > setting L_PTE_XN for both of these memory types.
>
> Conventionally, pgprot_writecombine() has only been used to change
> the memory type and not the permissions. Since writecombine memory
> is still capable of being executed, I don't see any reason to set XN
> for it.
>
> If the user wishes to mmap() using PROT_READ|PROT_EXEC, then is there
> really a reason for writecombine to set XN overriding the user?
>
> That said, pgprot_writecombine() is mostly used for framebuffers, which
> arguably shouldn't be executable anyway - but who'd want to mmap() the
> framebuffer with PROT_EXEC?
Well, I was mostly taking about DMA_ATTR_WRITE_COMBINE, which really
should include the NX bit even if pgprot_writecombine doesn't, right?
> > > - make DMA_ATTR_WRITE_COMBINE a no-op and schedule it for removal,
> > > thus removing the last instances of arch_dma_mmap_pgprot
> >
> > All sounds good to me, although I suppose 32-bit Arm platforms without
> > CONFIG_ARM_DMA_MEM_BUFFERABLE may run into issues if DMA_ATTR_WRITE_COMBINE
> > disappears. Only one way to find out...
>
> Looking at the results of grep, I think only OMAP2+ and Exynos may be
> affected.
As you mentioned later we also have the dma_alloc_wc wrapper, and a
single instance of dma_alloc_writecombine.
Exynos looks like purely ARM v7 from Kconfig, so it shouldn't even be
affected.
> However, removing writecombine support from the DMA API is going to
> have a huge impact for framebuffers on earlier ARMs - that's where we
> do expect framebuffers to be mapped "uncached/buffered" for performance
> reasons and not "uncached/unbuffered". It's quite literally the
> difference between console scrolling being usable and totally unusable.
>
> Given what I've said above, switching to using buffered mode for normal
> DMA mappings is data-corrupting risky - as in your filesystem could get
> fried. I don't think we should play fast and loose with people's data
> by randomly changing that "because we'd like to", and I don't see that
> screwing the console is really an option either.
Oh well. If we can't make dma_alloc_wc generally safe I fear we'll
have to keep it, but maybe literally limit it to the pre ARM v6
platforms. While pretty much all callers seems platform specific,
there actually are a decent number that can only work on ARM v7 or
arm64.
next prev parent reply other threads:[~2019-08-07 6:14 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 14:21 fix default dma_mmap_* pgprot Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 14:21 ` [PATCH] dma-mapping: fix page attributes for dma_mmap_* Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 14:21 ` Christoph Hellwig
2019-08-01 16:23 ` Will Deacon
2019-08-01 16:23 ` Will Deacon
2019-08-01 16:23 ` Will Deacon
2019-08-01 16:23 ` Will Deacon
2019-08-01 16:34 ` Christoph Hellwig
2019-08-01 16:34 ` Christoph Hellwig
2019-08-01 16:34 ` Christoph Hellwig
2019-08-01 16:34 ` Christoph Hellwig
2019-08-01 16:44 ` Will Deacon
2019-08-01 16:44 ` Will Deacon
2019-08-01 16:44 ` Will Deacon
2019-08-01 16:44 ` Will Deacon
2019-08-02 8:14 ` Christoph Hellwig
2019-08-02 8:14 ` Christoph Hellwig
2019-08-02 8:14 ` Christoph Hellwig
2019-08-02 8:14 ` Christoph Hellwig
2019-08-02 10:38 ` Will Deacon
2019-08-02 10:38 ` Will Deacon
2019-08-02 10:38 ` Will Deacon
2019-08-02 10:38 ` Will Deacon
2019-08-03 6:48 ` Christoph Hellwig
2019-08-03 6:48 ` Christoph Hellwig
2019-08-03 6:48 ` Christoph Hellwig
2019-08-03 6:48 ` Christoph Hellwig
2019-08-06 16:08 ` Will Deacon
2019-08-06 16:08 ` Will Deacon
2019-08-06 16:08 ` Will Deacon
2019-08-06 16:08 ` Will Deacon
2019-08-06 16:45 ` Russell King - ARM Linux admin
2019-08-06 16:45 ` Russell King - ARM Linux admin
2019-08-06 16:45 ` Russell King - ARM Linux admin
2019-08-06 16:45 ` Russell King - ARM Linux admin
2019-08-06 16:48 ` Russell King - ARM Linux admin
2019-08-06 16:48 ` Russell King - ARM Linux admin
2019-08-06 16:48 ` Russell King - ARM Linux admin
2019-08-06 16:48 ` Russell King - ARM Linux admin
2019-08-07 6:14 ` Christoph Hellwig [this message]
2019-08-07 6:14 ` Christoph Hellwig
2019-08-07 6:14 ` Christoph Hellwig
2019-08-07 6:14 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190807061402.GE6627@lst.de \
--to=hch@lst.de \
--cc=catalin.marinas@arm.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=robin.murphy@arm.com \
--cc=shawn@anastas.io \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.