Linux IOMMU Development
 help / color / mirror / Atom feed
From: "Raj, Ashok" <ashok.raj-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: nick klingsman <nick.klingsman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: Intel-iommu: Possible memory corruption due to deferred iommu flush
Date: Thu, 16 Nov 2017 17:23:48 -0800	[thread overview]
Message-ID: <20171117012348.GA53764@otc-nc-03> (raw)
In-Reply-To: <CAGkh+Xd-mwYT75-sFWbjxKCOu5H0QhZFBKNELZxBytWpnORnZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hi Nick

On Fri, Nov 17, 2017 at 01:57:19AM +0200, nick klingsman wrote:
> 
> Oh - now I understand the confusion. Although the subject said 'deferred'
> I used the word 'Batched' in the email body. I meant 'deferred'. Not batching.
> If it was only batching, than it would make sens as 'Ashok' pointed out.
> 
> >
> >>
> >>>
> >>> 2. If WD is not needed, why do we do it ? Why do we effect IOMMU work
> >>> with unneeded actions (in the most critical fast path of map/unmap) ?

The purpose of WRITE_DRAIN is something like this.. 

If you had a buffer that DMA writes are still happening but the entity using
the buffer has been terminated. You are just looking to ensure that before you
reallocate the buffer to another entity that the old writes aren't still
happening.

When we do the dma_unmap() that would get rid of the mappings and an iotlb 
flush would ensure any future access the DMA would fail. WRITE_DRAIN ensures
any address already translated and DMA is in progress completes. 

In the batched mode when we delay performing the iotlb invalidations + 
write_drain, the I/O is completed and driver was notified earlier. As
part of tracking the I/O completion the driver would have read some mmio
on the device that would have caused all the outstanding writes from the
device written to memory. So the buffer in this case is all globally 
observable by the consumer.. so there is no stale state for that DMA that 
has properly completed. In these cases the WD is probaly not required, but 
we have the same path for all invalidations so its simple to do it for 
consistency.



Hope this helps.

Cheers,
Ashok

      parent reply	other threads:[~2017-11-17  1:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 10:20 Intel-iommu: Possible memory corruption due to deferred iommu flush nick klingsman
     [not found] ` <CAGkh+XfVC0Ki0T88qdKke4Hsp2nyAZewRupEOLTds+1i4eBQYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-16 22:52   ` Raj, Ashok
2017-11-16 23:54     ` nick klingsman
     [not found]       ` <CAGkh+XesX-yFnU_3q2=t6Zcju_zE3wN7EZoBswQnfc_cZ9qZxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-16 23:57         ` nick klingsman
     [not found]           ` <CAGkh+Xd-mwYT75-sFWbjxKCOu5H0QhZFBKNELZxBytWpnORnZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-11-17  1:23             ` Raj, Ashok [this message]

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=20171117012348.GA53764@otc-nc-03 \
    --to=ashok.raj-ral2jqcrhueavxtiumwx3w@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=nick.klingsman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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