ia64/xen-unstable

changeset 16372:37be0bb60518

Revert 16067:9f9f9b68cd08a03fc8cfad9f5ab702e50b6b6463.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Tue Nov 13 17:28:44 2007 +0000 (2007-11-13)
parents dfca1120813f
children 5e4d4934a5d7
files xen/common/grant_table.c
line diff
     1.1 --- a/xen/common/grant_table.c	Sun Nov 11 18:28:57 2007 +0000
     1.2 +++ b/xen/common/grant_table.c	Tue Nov 13 17:28:44 2007 +0000
     1.3 @@ -198,7 +198,6 @@ static void
     1.4      int            handle;
     1.5      unsigned long  frame = 0;
     1.6      int            rc = GNTST_okay;
     1.7 -    int            is_iomem = 0;
     1.8      struct active_grant_entry *act;
     1.9      struct grant_mapping *mt;
    1.10      grant_entry_t *sha;
    1.11 @@ -329,55 +328,34 @@ static void
    1.12  
    1.13      spin_unlock(&rd->grant_table->lock);
    1.14  
    1.15 -    if ( op->flags & GNTMAP_host_map ) 
    1.16 +    if ( unlikely(!mfn_valid(frame)) ||
    1.17 +         unlikely(!((op->flags & GNTMAP_readonly) ?
    1.18 +                    get_page(mfn_to_page(frame), rd) :
    1.19 +                    get_page_and_type(mfn_to_page(frame), rd,
    1.20 +                                      PGT_writable_page))) )
    1.21      {
    1.22 -        /* Could be an iomem page for setting up permission */
    1.23 -        if ( is_iomem_page(frame) )
    1.24 +        if ( !rd->is_dying )
    1.25 +            gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n", frame);
    1.26 +        rc = GNTST_general_error;
    1.27 +        goto undo_out;
    1.28 +    }
    1.29 +        
    1.30 +    if ( op->flags & GNTMAP_host_map )
    1.31 +    {
    1.32 +        rc = create_grant_host_mapping(op->host_addr, frame, op->flags);
    1.33 +        if ( rc != GNTST_okay )
    1.34          {
    1.35 -            is_iomem = 1;
    1.36 -            if ( iomem_permit_access(ld, frame, frame) )
    1.37 -            {
    1.38 -                gdprintk(XENLOG_WARNING, 
    1.39 -                         "Could not permit access to grant frame "
    1.40 -                         "%lx as iomem\n", frame);
    1.41 -                rc = GNTST_general_error;
    1.42 -                goto undo_out;
    1.43 -            }
    1.44 -        }
    1.45 -    } 
    1.46 -
    1.47 -    if ( !is_iomem ) 
    1.48 -    {
    1.49 -        if ( unlikely(!mfn_valid(frame)) ||
    1.50 -             unlikely(!((op->flags & GNTMAP_readonly) ?
    1.51 -                        get_page(mfn_to_page(frame), rd) :
    1.52 -                        get_page_and_type(mfn_to_page(frame), rd,
    1.53 -                                          PGT_writable_page))))
    1.54 -        {
    1.55 -            if ( !rd->is_dying )
    1.56 -                gdprintk(XENLOG_WARNING,
    1.57 -                         "Could not pin grant frame %lx\n", frame);
    1.58 -            rc = GNTST_general_error;
    1.59 +            if ( !(op->flags & GNTMAP_readonly) )
    1.60 +                put_page_type(mfn_to_page(frame));
    1.61 +            put_page(mfn_to_page(frame));
    1.62              goto undo_out;
    1.63          }
    1.64 -        
    1.65 -        if ( op->flags & GNTMAP_host_map )
    1.66 +
    1.67 +        if ( op->flags & GNTMAP_device_map )
    1.68          {
    1.69 -            rc = create_grant_host_mapping(op->host_addr, frame, op->flags);
    1.70 -            if ( rc != GNTST_okay )
    1.71 -            {
    1.72 -                if ( !(op->flags & GNTMAP_readonly) )
    1.73 -                    put_page_type(mfn_to_page(frame));
    1.74 -                put_page(mfn_to_page(frame));
    1.75 -                goto undo_out;
    1.76 -            }
    1.77 -
    1.78 -            if ( op->flags & GNTMAP_device_map )
    1.79 -            {
    1.80 -                (void)get_page(mfn_to_page(frame), rd);
    1.81 -                if ( !(op->flags & GNTMAP_readonly) )
    1.82 -                    get_page_type(mfn_to_page(frame), PGT_writable_page);
    1.83 -            }
    1.84 +            (void)get_page(mfn_to_page(frame), rd);
    1.85 +            if ( !(op->flags & GNTMAP_readonly) )
    1.86 +                get_page_type(mfn_to_page(frame), PGT_writable_page);
    1.87          }
    1.88      }
    1.89  
    1.90 @@ -518,21 +496,12 @@ static void
    1.91          }
    1.92      }
    1.93  
    1.94 -    if ( op->flags & GNTMAP_host_map )
    1.95 +    if ( (op->host_addr != 0) && (op->flags & GNTMAP_host_map) )
    1.96      {
    1.97 -        if ( (op->host_addr != 0) )
    1.98 -        {
    1.99 -            if ( (rc = replace_grant_host_mapping(op->host_addr,
   1.100 -                                                  op->frame, op->new_addr, 
   1.101 -                                                  op->flags)) < 0 )
   1.102 -                goto unmap_out;
   1.103 -        }
   1.104 -        else if ( is_iomem_page(op->frame) &&
   1.105 -                  iomem_access_permitted(ld, op->frame, op->frame) )
   1.106 -        {
   1.107 -            if ( (rc = iomem_deny_access(ld, op->frame, op->frame)) < 0 )
   1.108 -                goto unmap_out;
   1.109 -        }
   1.110 +        if ( (rc = replace_grant_host_mapping(op->host_addr,
   1.111 +                                              op->frame, op->new_addr, 
   1.112 +                                              op->flags)) < 0 )
   1.113 +            goto unmap_out;
   1.114  
   1.115          ASSERT(act->pin & (GNTPIN_hstw_mask | GNTPIN_hstr_mask));
   1.116          op->map->flags &= ~GNTMAP_host_map;
   1.117 @@ -540,7 +509,7 @@ static void
   1.118              act->pin -= GNTPIN_hstr_inc;
   1.119          else
   1.120              act->pin -= GNTPIN_hstw_inc;
   1.121 -    } 
   1.122 +    }
   1.123  
   1.124      /* If just unmapped a writable mapping, mark as dirtied */
   1.125      if ( !(op->flags & GNTMAP_readonly) )
   1.126 @@ -1592,7 +1561,6 @@ gnttab_release_mappings(
   1.127      struct domain        *rd;
   1.128      struct active_grant_entry *act;
   1.129      struct grant_entry   *sha;
   1.130 -    int rc;
   1.131  
   1.132      BUG_ON(!d->is_dying);
   1.133  
   1.134 @@ -1650,12 +1618,7 @@ gnttab_release_mappings(
   1.135              {
   1.136                  BUG_ON(!(act->pin & GNTPIN_hstw_mask));
   1.137                  act->pin -= GNTPIN_hstw_inc;
   1.138 -
   1.139 -                if ( is_iomem_page(act->frame) &&
   1.140 -                     iomem_access_permitted(rd, act->frame, act->frame) )
   1.141 -                    rc = iomem_deny_access(rd, act->frame, act->frame);
   1.142 -                else 
   1.143 -                    gnttab_release_put_page_and_type(mfn_to_page(act->frame));
   1.144 +                gnttab_release_put_page_and_type(mfn_to_page(act->frame));
   1.145              }
   1.146  
   1.147              if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 )