direct-io.hg

changeset 5530:fd4a89825472

bitkeeper revision 1.1713.2.17 (42b86c76S4xsXs1Za6J4vAne_33G_w)

Updated version to dom0_ops.c. After some discussion with Ian,
we decided to remove newly added hypercall and instead turn
to other means in user application level. Then rest stuff is
all IA64 specific without any touch to common code.

Signed-off-by Kevin Tian <Kevin.tian@intel.com>
author djm@kirby.fc.hp.com
date Tue Jun 21 19:37:26 2005 +0000 (2005-06-21)
parents 3cc88ea3498a
children e7981e581c6c 1aac5f19494f
files xen/arch/ia64/dom0_ops.c
line diff
     1.1 --- a/xen/arch/ia64/dom0_ops.c	Tue Jun 21 18:35:20 2005 +0000
     1.2 +++ b/xen/arch/ia64/dom0_ops.c	Tue Jun 21 19:37:26 2005 +0000
     1.3 @@ -27,6 +27,128 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
     1.4  
     1.5      switch ( op->cmd )
     1.6      {
     1.7 +    case DOM0_GETPAGEFRAMEINFO:
     1.8 +    {
     1.9 +        struct pfn_info *page;
    1.10 +        unsigned long pfn = op->u.getpageframeinfo.pfn;
    1.11 +        domid_t dom = op->u.getpageframeinfo.domain;
    1.12 +        struct domain *d;
    1.13 +
    1.14 +        ret = -EINVAL;
    1.15 +
    1.16 +        if ( unlikely(pfn >= max_page) || 
    1.17 +             unlikely((d = find_domain_by_id(dom)) == NULL) )
    1.18 +            break;
    1.19 +
    1.20 +        page = &frame_table[pfn];
    1.21 +
    1.22 +        if ( likely(get_page(page, d)) )
    1.23 +        {
    1.24 +            ret = 0;
    1.25 +
    1.26 +            op->u.getpageframeinfo.type = NOTAB;
    1.27 +
    1.28 +            if ( (page->u.inuse.type_info & PGT_count_mask) != 0 )
    1.29 +            {
    1.30 +                switch ( page->u.inuse.type_info & PGT_type_mask )
    1.31 +                {
    1.32 +		default:
    1.33 +		    panic("No such page type\n");
    1.34 +                    break;
    1.35 +                }
    1.36 +            }
    1.37 +            
    1.38 +            put_page(page);
    1.39 +        }
    1.40 +
    1.41 +        put_domain(d);
    1.42 +
    1.43 +        copy_to_user(u_dom0_op, op, sizeof(*op));
    1.44 +    }
    1.45 +    break;
    1.46 +
    1.47 +    case DOM0_GETPAGEFRAMEINFO2:
    1.48 +    {
    1.49 +#define GPF2_BATCH 128
    1.50 +        int n,j;
    1.51 +        int num = op->u.getpageframeinfo2.num;
    1.52 +        domid_t dom = op->u.getpageframeinfo2.domain;
    1.53 +        unsigned long *s_ptr = (unsigned long*) op->u.getpageframeinfo2.array;
    1.54 +        struct domain *d;
    1.55 +        unsigned long *l_arr;
    1.56 +        ret = -ESRCH;
    1.57 +
    1.58 +        if ( unlikely((d = find_domain_by_id(dom)) == NULL) )
    1.59 +            break;
    1.60 +
    1.61 +        if ( unlikely(num > 1024) )
    1.62 +        {
    1.63 +            ret = -E2BIG;
    1.64 +            break;
    1.65 +        }
    1.66 +
    1.67 +        l_arr = (unsigned long *)alloc_xenheap_page();
    1.68 + 
    1.69 +        ret = 0;
    1.70 +        for( n = 0; n < num; )
    1.71 +        {
    1.72 +            int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n);
    1.73 +
    1.74 +            if ( copy_from_user(l_arr, &s_ptr[n], k*sizeof(unsigned long)) )
    1.75 +            {
    1.76 +                ret = -EINVAL;
    1.77 +                break;
    1.78 +            }
    1.79 +     
    1.80 +            for( j = 0; j < k; j++ )
    1.81 +            {      
    1.82 +                struct pfn_info *page;
    1.83 +                unsigned long mfn = l_arr[j];
    1.84 +
    1.85 +                if ( unlikely(mfn >= max_page) )
    1.86 +                    goto e2_err;
    1.87 +
    1.88 +                page = &frame_table[mfn];
    1.89 +  
    1.90 +                if ( likely(get_page(page, d)) )
    1.91 +                {
    1.92 +                    unsigned long type = 0;
    1.93 +
    1.94 +                    switch( page->u.inuse.type_info & PGT_type_mask )
    1.95 +                    {
    1.96 +		    default:
    1.97 +			panic("No such page type\n");
    1.98 +			break;
    1.99 +                    }
   1.100 +
   1.101 +                    if ( page->u.inuse.type_info & PGT_pinned )
   1.102 +                        type |= LPINTAB;
   1.103 +                    l_arr[j] |= type;
   1.104 +                    put_page(page);
   1.105 +                }
   1.106 +                else
   1.107 +                {
   1.108 +                e2_err:
   1.109 +                    l_arr[j] |= XTAB;
   1.110 +                }
   1.111 +
   1.112 +            }
   1.113 +
   1.114 +            if ( copy_to_user(&s_ptr[n], l_arr, k*sizeof(unsigned long)) )
   1.115 +            {
   1.116 +                ret = -EINVAL;
   1.117 +                break;
   1.118 +            }
   1.119 +
   1.120 +            n += j;
   1.121 +        }
   1.122 +
   1.123 +        free_xenheap_page((unsigned long)l_arr);
   1.124 +
   1.125 +        put_domain(d);
   1.126 +    }
   1.127 +    break;
   1.128 +#ifndef CONFIG_VTI
   1.129      /*
   1.130       * NOTE: DOM0_GETMEMLIST has somewhat different semantics on IA64 -
   1.131       * it actually allocates and maps pages.
   1.132 @@ -70,7 +192,42 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
   1.133          }
   1.134      }
   1.135      break;
   1.136 +#else
   1.137 +    case DOM0_GETMEMLIST:
   1.138 +    {
   1.139 +	int i;
   1.140 +	struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
   1.141 +	unsigned long max_pfns = op->u.getmemlist.max_pfns;
   1.142 +	unsigned long pfn;
   1.143 +	unsigned long *buffer = op->u.getmemlist.buffer;
   1.144 +	struct list_head *list_ent;
   1.145  
   1.146 +	ret = -EINVAL;
   1.147 +	if (!d) {
   1.148 +	    ret = 0;
   1.149 +
   1.150 +	    spin_lock(&d->page_alloc_lock);
   1.151 +	    list_ent = d->page_list.next;
   1.152 +	    for (i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++) {
   1.153 +		pfn = list_entry(list_ent, struct pfn_info, list) -
   1.154 +		    frame_table;
   1.155 +		if (put_user(pfn, buffer)) {
   1.156 +		    ret = -EFAULT;
   1.157 +		    break;
   1.158 +		}
   1.159 +		buffer++;
   1.160 +		list_ent = frame_table[pfn].list.next;
   1.161 +	    }
   1.162 +	    spin_unlock(&d->page_alloc_lock);
   1.163 +
   1.164 +	    op->u.getmemlist.num_pfns = i;
   1.165 +	    copy_to_user(u_dom0_op, op, sizeof(*op));
   1.166 +
   1.167 +	    put_domain(d);
   1.168 +	}
   1.169 +    }
   1.170 +    break;
   1.171 +#endif // CONFIG_VTI
   1.172      default:
   1.173          ret = -ENOSYS;
   1.174