From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH RFC 1/2] gnttab: add IOMMU entries for grant mappings on auto-translated guests
Date: Fri, 4 Apr 2014 16:37:33 +0200 [thread overview]
Message-ID: <1396622254-13069-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1396622254-13069-1-git-send-email-roger.pau@citrix.com>
When using grant mappings with auto-translated guests (PVH, HVM), Xen
was not updating the IOMMU entries for the domain. This patch adds the
necessary bits in order to properly update the IOMMU when doing grant
maps/unmap on auto-translated guests.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Mukesh Rathor <mukesh.rathor@oracle.com>
Cc: Keir Fraser <keir@xen.org>
Cc: Jan Beulich <jbeulich@suse.com>
---
xen/common/grant_table.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 107b000..665f34b 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -749,6 +749,22 @@ __gnttab_map_grant_ref(
goto undo_out;
}
}
+ else if ( need_iommu(ld) )
+ {
+ int err;
+
+ BUG_ON(!paging_mode_translate(ld));
+ err = iommu_map_page(ld, op->host_addr >> PAGE_SHIFT, frame,
+ op->flags & GNTMAP_readonly ?
+ IOMMUF_readable :
+ IOMMUF_readable|IOMMUF_writable);
+ if ( err )
+ {
+ double_gt_unlock(lgt, rgt);
+ rc = GNTST_general_error;
+ goto undo_out;
+ }
+ }
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, op->dom);
@@ -947,6 +963,18 @@ __gnttab_unmap_common(
goto unmap_out;
}
}
+ else if ( need_iommu(ld) )
+ {
+ int err;
+
+ BUG_ON(!paging_mode_translate(ld));
+ err = iommu_unmap_page(ld, op->host_addr >> PAGE_SHIFT);
+ if ( err )
+ {
+ rc = GNTST_general_error;
+ goto unmap_out;
+ }
+ }
/* If just unmapped a writable mapping, mark as dirtied */
if ( !(op->flags & GNTMAP_readonly) )
--
1.7.7.5 (Apple Git-26)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2014-04-04 14:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-04 14:37 [PATCH RFC 0/2] Fix grant map/unmap with auto-translated guests Roger Pau Monne
2014-04-04 14:37 ` Roger Pau Monne [this message]
2014-04-04 15:35 ` [PATCH RFC 1/2] gnttab: add IOMMU entries for grant mappings on " Jan Beulich
2014-04-07 11:51 ` Roger Pau Monné
2014-04-07 12:04 ` Jan Beulich
2014-04-07 14:40 ` Roger Pau Monné
2014-04-07 15:18 ` Jan Beulich
2014-04-07 15:28 ` Andres Lagar-Cavilla
2014-04-04 14:37 ` [PATCH RFC 2/2] xen: expose that grant table mappings update the IOMMU Roger Pau Monne
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=1396622254-13069-2-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xenproject.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).