diff -r 08e2c03a47e0 xen/common/grant_table.c --- a/xen/common/grant_table.c Tue May 15 17:47:46 2007 +0100 +++ b/xen/common/grant_table.c Thu May 17 09:53:29 2007 +0100 @@ -195,7 +195,9 @@ __gnttab_map_grant_ref( led = current; ld = led->domain; - if ( unlikely((op->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0) ) + if ( unlikely((op->flags & (GNTMAP_device_map | + GNTMAP_host_map | + GNTMAP_iomem_map)) == 0) ) { gdprintk(XENLOG_INFO, "Bad flags in grant map op (%x).\n", op->flags); op->status = GNTST_bad_gntref; @@ -305,16 +307,36 @@ __gnttab_map_grant_ref( spin_unlock(&rd->grant_table->lock); - if ( unlikely(!mfn_valid(frame)) || - unlikely(!((op->flags & GNTMAP_readonly) ? - get_page(mfn_to_page(frame), rd) : - get_page_and_type(mfn_to_page(frame), rd, - PGT_writable_page))) ) - { - if ( !rd->is_dying ) - gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame); - rc = GNTST_general_error; - goto undo_out; + if ( op->flags & GNTMAP_iomem_map ) + { + if( op->dom == 0 && !mfn_valid(frame) ) { + /* Could be an iomem page for setting up permission */ + if ( iomem_permit_access(ld, frame, frame) != 0 ) { + gdprintk(XENLOG_WARNING, + "Could not permit access to grant frame %lx as iomem\n", + frame); + rc = GNTST_general_error; + goto undo_out; + } + } else { + gdprintk(XENLOG_WARNING, + "Invalid domain (%d) or frame (%lx) for iomem map\n", + op->dom, frame); + rc = GNTST_general_error; + goto undo_out; + } + } else { + if ( unlikely(!mfn_valid(frame)) || + unlikely(!((op->flags & GNTMAP_readonly) ? + get_page(mfn_to_page(frame), rd) : + get_page_and_type(mfn_to_page(frame), rd, + PGT_writable_page))) ) + { + if ( !rd->is_dying ) + gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame); + rc = GNTST_general_error; + goto undo_out; + } } if ( op->flags & GNTMAP_host_map ) @@ -494,8 +516,17 @@ __gnttab_unmap_grant_ref( put_page_and_type(mfn_to_page(frame)); } } - - if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 ) + + if ( flags & GNTMAP_iomem_map ) + { + map->flags &= ~GNTMAP_iomem_map; + + rc = iomem_deny_access(ld, frame, frame); + } + + if ( (map->flags & (GNTMAP_device_map | + GNTMAP_host_map | + GNTMAP_iomem_map)) == 0 ) { map->flags = 0; put_maptrack_handle(ld->grant_table, op->handle); @@ -1352,13 +1383,16 @@ gnttab_release_mappings( struct domain *rd; struct active_grant_entry *act; struct grant_entry *sha; + int rc; BUG_ON(!d->is_dying); for ( handle = 0; handle < gt->maptrack_limit; handle++ ) { map = &maptrack_entry(gt, handle); - if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) ) + if ( !(map->flags & (GNTMAP_device_map | + GNTMAP_host_map | + GNTMAP_iomem_map)) ) continue; ref = map->ref; @@ -1415,6 +1449,9 @@ gnttab_release_mappings( if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 ) gnttab_clear_flag(_GTF_writing, &sha->flags); } + + if( map->flags & GNTMAP_iomem_map ) + rc = iomem_deny_access(rd, act->frame, act->frame); if ( act->pin == 0 ) gnttab_clear_flag(_GTF_reading, &sha->flags); diff -r 08e2c03a47e0 xen/include/public/grant_table.h --- a/xen/include/public/grant_table.h Tue May 15 17:47:46 2007 +0100 +++ b/xen/include/public/grant_table.h Thu May 17 09:53:29 2007 +0100 @@ -358,6 +358,12 @@ DEFINE_XEN_GUEST_HANDLE(gnttab_query_siz #define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) /* + * Establish iomem permission + */ +#define _GNTMAP_iomem_map (5) +#define GNTMAP_iomem_map (1<<_GNTMAP_iomem_map) + +/* * Values for error status returns. All errors are -ve. */ #define GNTST_okay (0) /* Normal return. */