mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: dwmw2@infradead.org, iommu@lists.linux-foundation.org,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	chrisw@sous-sol.org, ddutile@redhat.com
Subject: Re: [PATCH] intel-iommu: Default to non-coherent for domains unattached to iommus
Date: Fri, 11 Nov 2011 16:17:05 -0800	[thread overview]
Message-ID: <20111112001705.GM14486@sequoia.sous-sol.org> (raw)
In-Reply-To: <20111111224849.9756.13368.stgit@bling.home>

* Alex Williamson (alex.williamson@redhat.com) wrote:
> domain_update_iommu_coherency() currently default to setting domains
> as coherent when the domain is not attached to any iommus.  This
> allows for a window in domain_context_mapping_one() where such a
> domain can update context entries non-coherenty, and only after
> update the domain capability to clear iommu_coherency.
> 
> This can be seen using KVM device assignment on VT-d systems that
> do not support coherency in the ecap register.  When a device is
> added to a guest, a domain is created (iommu_coherency = 0), the
> device is attached, and ranges are mapped.  If we then hot unplug
> the device, the coherency is updated and set to the default (1)
> since no iommus are attached to the domain.  A subsequenct attach
> of a device makes use of the same dmar domain (now marked coherent)
> updates context entries with cohrency enabled, and only disables
> coherency as the last step in the process.

Specifically, in domain_context_mapping_one():

  context_set_translation_type(context, translation);
  context_set_fault_enable(context);
  context_set_present(context);
  domain_flush_cache(domain, context, sizeof(*context));  <-- noop

This does not update context entry, leaving IOMMU w/ a non-present
context entry, and therefore subsequent DMA generates DMAR faults:

DMAR:[DMA Read] Request device [08:10.0] fault addr 37298000
DMAR:[fault reason 02] Present bit in context entry is clear
 
> To fix this, switch domain_update_iommu_coherency() to use the
> safer, non-coherent default for domains not attached to iommus.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> Tested-by: Donald Dutile <ddutile@redhat.com>
> Acked-by: Donald Dutile <ddutile@redhat.com>

Acked-by: Chris Wright <chrisw@sous-sol.org>

thanks,
-chris

  reply	other threads:[~2011-11-12  0:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-11 22:49 Alex Williamson
2011-11-12  0:17 ` Chris Wright [this message]
2011-11-12  0:37 ` David Woodhouse
2011-11-12  0:45   ` Chris Wright
2011-11-12  0:47     ` Chris Wright
2011-11-12  0:51     ` David Woodhouse
2011-11-12  0:58       ` Chris Wright
2011-11-12  1:03         ` David Woodhouse
2011-11-12  0:46   ` Roland Dreier
2011-11-12  0:51     ` Chris Wright
2011-11-12  0:55       ` David Woodhouse
2011-11-12  1:08         ` Chris Wright
2011-11-12  1:20           ` David Woodhouse
2011-11-15  7:12             ` cody
2011-11-15  4:54               ` Chris Wright
2011-11-15  5:55                 ` Kai Huang
2011-11-12  1:30           ` Roland Dreier

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=20111112001705.GM14486@sequoia.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=alex.williamson@redhat.com \
    --cc=ddutile@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®