# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1275034080 -3600
# Node ID 69a8e9b6961fda8ee2f38019156323fee0caaf3d
# Parent 9ee5c292b1125bcd281629fc957bbe4c92545014
iommu: Map correct permissions in IOMMU on grant read-only map request.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
xen/common/grant_table.c | 33 ++++++++++++++++++++-------------
1 files changed, 20 insertions(+), 13 deletions(-)
diff -r 9ee5c292b112 -r 69a8e9b6961f xen/common/grant_table.c
--- a/xen/common/grant_table.c Fri May 28 08:48:50 2010 +0100
+++ b/xen/common/grant_table.c Fri May 28 09:08:00 2010 +0100
@@ -596,17 +596,20 @@ __gnttab_map_grant_ref(
goto undo_out;
}
- if ( (!is_hvm_domain(ld) && need_iommu(ld)) &&
- !(old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) &&
- (act_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) )
- {
- /* Shouldn't happen, because you can't use iommu in a HVM
- * domain. */
+ if ( !is_hvm_domain(ld) && need_iommu(ld) )
+ {
+ int err = 0;
+ /* Shouldn't happen, because you can't use iommu in a HVM domain. */
BUG_ON(paging_mode_translate(ld));
/* We're not translated, so we know that gmfns and mfns are
the same things, so the IOMMU entry is always 1-to-1. */
- if ( iommu_map_page(ld, frame, frame,
- IOMMUF_readable|IOMMUF_writable) )
+ if ( (act_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) &&
+ !(old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) )
+ err = iommu_map_page(ld, frame, frame,
+ IOMMUF_readable|IOMMUF_writable);
+ else if ( act_pin && !old_pin )
+ err = iommu_map_page(ld, frame, frame, IOMMUF_readable);
+ if ( err )
{
rc = GNTST_general_error;
goto undo_out;
@@ -780,12 +783,16 @@ __gnttab_unmap_common(
act->pin -= GNTPIN_hstw_inc;
}
- if ( (!is_hvm_domain(ld) && need_iommu(ld)) &&
- (old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) &&
- !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) )
- {
+ if ( !is_hvm_domain(ld) && need_iommu(ld) )
+ {
+ int err = 0;
BUG_ON(paging_mode_translate(ld));
- if ( iommu_unmap_page(ld, op->frame) )
+ if ( old_pin && !act->pin )
+ err = iommu_unmap_page(ld, op->frame);
+ else if ( (old_pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) &&
+ !(act->pin & (GNTPIN_hstw_mask|GNTPIN_devw_mask)) )
+ err = iommu_map_page(ld, op->frame, op->frame, IOMMUF_readable);
+ if ( err )
{
rc = GNTST_general_error;
goto unmap_out;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|