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 14:52:26 -0800	[thread overview]
Message-ID: <20171116225226.GA53404@otc-nc-03> (raw)
In-Reply-To: <CAGkh+XfVC0Ki0T88qdKke4Hsp2nyAZewRupEOLTds+1i4eBQYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Thu, Nov 16, 2017 at 12:20:47PM +0200, nick klingsman wrote:
> * Note: Please 'CC'/Reply my email as I'm not subscribed to the list yet.
> 
> Hi,
> 
> During __iommu_flush_iotlb() we set the WD (WriteDrain) bit if the
> iommu supports cap_write_drain(). This part of the logic exists from
> day one of the code and later even added to QI logic.
> 
> Back than, when we dma_unmap_xxx() we 'synchronically' did the
> iommu_flush() and within it the the Write-Drain logic.
> 
> However, today, we do a batch-flush  which means that all/most calls
> to dma_unmap() don't perform the Write-Drain.
> 
> Questions:
> 
> 1. If WD is a must, how come the batch-flush doesn't cause any memory
> corruption ? For example:
>    a. dma_map_page(100, from_device)
>    b. Device writes data to device
>    c. dma_unmap_page() -> batched and not sync-flushed
>    d. Possible BUG ? Data read before the write is drained can be stale ?

__iommu_flush_iotlb() will do DMA_TLB_WRITE_DRAIN.. so that's actually 
done even in the batched more.

> 
> 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) ?
> 
> 
> Thanks,
> Nick
> _______________________________________________
> iommu mailing list
> iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linuxfoundation.org/mailman/listinfo/iommu

  parent reply	other threads:[~2017-11-16 22:52 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 [this message]
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

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=20171116225226.GA53404@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