linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hch@infradead.org (Christoph Hellwig)
To: linux-arm-kernel@lists.infradead.org
Subject: noveau vs arm dma ops
Date: Thu, 26 Apr 2018 02:13:10 -0700	[thread overview]
Message-ID: <20180426091310.GB18811@infradead.org> (raw)
In-Reply-To: <20180425225443.GQ16141@n2100.armlinux.org.uk>

On Wed, Apr 25, 2018 at 11:54:43PM +0100, Russell King - ARM Linux wrote:
> 
> if the memory was previously dirty (iow, CPU has written), you need to
> flush the dirty cache lines _before_ the GPU writes happen, but you
> don't know whether the CPU has speculatively prefetched, so you need
> to flush any prefetched cache lines before reading from the cacheable
> memory _after_ the GPU has finished writing.
> 
> Also note that "flush" there can be "clean the cache", "clean and
> invalidate the cache" or "invalidate the cache" as appropriate - some
> CPUs are able to perform those three operations, and the appropriate
> one depends on not only where in the above sequence it's being used,
> but also on what the operations are.

Agreed on all these counts.

> If we can agree a set of interfaces that allows _proper_ use of these
> facilities, one which can be used appropriately, then there shouldn't
> be a problem.  The DMA API does that via it's ideas about who owns a
> particular buffer (because of the above problem) and that's something
> which would need to be carried over to such a cache flushing API (it
> should be pretty obvious that having a GPU read or write memory while
> the cache for that memory is being cleaned will lead to unexpected
> results.)

I've been trying to come up with such an interface, for now only for
internal use in a generic set of noncoherent ops.  The API is basically
a variant of the existing dma_sync_single_to_device/cpu calls:

http://git.infradead.org/users/hch/misc.git/commitdiff/044dae5f94509288f4655de2f22cb0bea85778af

Review welcome!

> The next issue, which I've brought up before, is that exposing cache
> flushing to userspace on architectures where it isn't already exposed
> comes.  As has been shown by Google Project Zero, this risks exposing
> those architectures to Spectre and Meltdown exploits where they weren't
> at such a risk before.  (I've pretty much shown here that you _do_
> need to control which cache lines get flushed to make these exploits
> work, and flushing the cache by reading lots of data in liu of having
> the ability to explicitly flush bits of cache makes it very difficult
> to impossible for them to work.)

Extending dma coherence to userspace is going to be the next major
nightmare indeed.  I'm not sure how much of that actually still is
going on in the graphics world, but we'll need a coherent (pun intended)
plan how to deal with it.

  reply	other threads:[~2018-04-26  9:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <f1100bd6-dd98-55a9-a92f-1cad919f235f@amd.com>
     [not found] ` <20180420124625.GA31078@infradead.org>
     [not found]   ` <20180420152111.GR31310@phenom.ffwll.local>
     [not found]     ` <20180424184847.GA3247@infradead.org>
     [not found]       ` <CAKMK7uFL68pu+-9LODTgz+GQYvxpnXOGhxfz9zorJ_JKsPVw2g@mail.gmail.com>
     [not found]         ` <20180425054855.GA17038@infradead.org>
     [not found]           ` <CAKMK7uEFitkNQrD6cLX5Txe11XhVO=LC4YKJXH=VNdq+CY=DjQ@mail.gmail.com>
     [not found]             ` <CAKMK7uFx=KB1vup=WhPCyfUFairKQcRR4BEd7aXaX1Pj-vj3Cw@mail.gmail.com>
     [not found]               ` <20180425064335.GB28100@infradead.org>
     [not found]                 ` <20180425074151.GA2271@ulmo>
2018-04-25  8:54                   ` noveau vs arm dma ops Christoph Hellwig
2018-04-25  9:25                     ` Russell King - ARM Linux
2018-04-25 10:04                     ` Daniel Vetter
2018-04-25 15:33                       ` Christoph Hellwig
2018-04-25 21:35                         ` Daniel Vetter
2018-04-25 23:26                           ` Russell King - ARM Linux
2018-04-26  9:17                             ` Daniel Vetter
2018-04-26  9:09                           ` Christoph Hellwig
2018-04-26  9:45                             ` Daniel Vetter
2018-04-26 11:12                             ` Russell King - ARM Linux
2018-04-25 22:54                         ` Russell King - ARM Linux
2018-04-26  9:13                           ` Christoph Hellwig [this message]
2018-04-26  9:20                           ` [Linaro-mm-sig] " Daniel Vetter
2018-04-26  9:24                             ` Christoph Hellwig
2018-04-26  9:39                               ` Daniel Vetter

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=20180426091310.GB18811@infradead.org \
    --to=hch@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).