From: Joerg Roedel <joro@8bytes.org>
To: iommu@lists.linux-foundation.org
Cc: David Woodhouse <dwmw2@infradead.org>,
zhen-hual@hp.com, bhe@redhat.com, linux-kernel@vger.kernel.org,
Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 2/4] iommu/vt-d: Don't consider copied context entries as present
Date: Thu, 11 Jun 2015 15:47:41 +0200 [thread overview]
Message-ID: <1434030463-942-3-git-send-email-joro@8bytes.org> (raw)
In-Reply-To: <1434030463-942-1-git-send-email-joro@8bytes.org>
From: Joerg Roedel <jroedel@suse.de>
Hide the copied context entries from the IOMMU driver by
considering them as non-present. This is implemented by
setting the first AVL bit (bit 67) in the context entry to
one. If this bit is set, the context_present() function
returns false.
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
drivers/iommu/intel-iommu.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index b0fd5f2..f50d065 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -234,11 +234,21 @@ struct context_entry {
u64 hi;
};
-static inline bool context_present(struct context_entry *context)
+static inline bool __context_present(struct context_entry *context)
{
return (context->lo & 1);
}
+static inline bool context_copied(struct context_entry *context)
+{
+ return (((context->hi >> 3) & 0xfULL) == 1);
+}
+
+static inline bool context_present(struct context_entry *context)
+{
+ return __context_present(context) && !context_copied(context);
+}
+
static inline int context_fault_enable(struct context_entry *c)
{
return((c->lo >> 1) & 0x1);
@@ -269,6 +279,11 @@ static inline void context_set_present(struct context_entry *context)
context->lo |= 1;
}
+static inline void context_set_copied(struct context_entry *context)
+{
+ context->hi |= 1ULL << 3;
+}
+
static inline void context_set_fault_enable(struct context_entry *context)
{
context->lo &= (((u64)-1) << 2) | 1;
@@ -1919,6 +1934,9 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
}
}
+ /* First clear any left-overs, like a copied context entry */
+ context_clear_entry(context);
+
context_set_domain_id(context, id);
if (translation != CONTEXT_TT_PASS_THROUGH) {
@@ -4911,13 +4929,15 @@ static int copy_one_context_table(struct intel_iommu *iommu,
memcpy_fromio(&ce, &ctxt_tbl_old[devfn],
sizeof(struct context_entry));
- if (!context_present(&ce))
+ if (!__context_present(&ce))
continue;
did = context_domain_id(&ce);
if (did >=0 && did < cap_ndoms(iommu->cap))
set_bit(did, iommu->domain_ids);
+ context_set_copied(&ce);
+
ctxt_tbl[devfn] = ce;
}
--
1.9.1
next prev parent reply other threads:[~2015-06-11 13:48 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-11 13:47 [PATCH 0/4] More cleanups and fixes for Intel VT-d Joerg Roedel
2015-06-11 13:47 ` [PATCH 1/4] iommu/vt-d: Remove iommu_attach_domain_with_id() Joerg Roedel
2015-06-11 13:47 ` Joerg Roedel [this message]
2015-06-11 14:07 ` [PATCH 2/4] iommu/vt-d: Don't consider copied context entries as present David Woodhouse
2015-06-11 14:12 ` Joerg Roedel
2015-06-11 14:19 ` David Woodhouse
2015-06-11 14:25 ` Joerg Roedel
2015-06-11 14:44 ` David Woodhouse
2015-06-11 15:12 ` David Woodhouse
2015-06-11 14:51 ` Joerg Roedel
2015-06-11 13:47 ` [PATCH 3/4] iommu/vt-d: Remove unmap_device_dma() Joerg Roedel
2015-06-11 13:47 ` [PATCH 4/4] iommu/vt-d: Make sure si_domain is allocated for kdump kernel Joerg Roedel
2015-06-11 15:54 ` [PATCH 0/4] More cleanups and fixes for Intel VT-d David Woodhouse
2015-06-12 7:31 ` Joerg Roedel
2015-06-12 20:29 ` Joerg Roedel
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=1434030463-942-3-git-send-email-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=bhe@redhat.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=zhen-hual@hp.com \
/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