direct-io.hg

changeset 11530:7877e25e2b23

[HVM] getmemlist hypercall returns pages in strict
physmap order.
From: Ke Yu <ke.yu@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Sep 19 11:01:05 2006 +0100 (2006-09-19)
parents 6374af16a8a3
children 7c6aaa106f15
files xen/arch/x86/domctl.c
line diff
     1.1 --- a/xen/arch/x86/domctl.c	Tue Sep 19 10:50:10 2006 +0100
     1.2 +++ b/xen/arch/x86/domctl.c	Tue Sep 19 11:01:05 2006 +0100
     1.3 @@ -22,6 +22,7 @@
     1.4  #include <asm/hvm/hvm.h>
     1.5  #include <asm/hvm/support.h>
     1.6  #include <asm/processor.h>
     1.7 +#include <public/hvm/e820.h>
     1.8  
     1.9  long arch_do_domctl(
    1.10      struct xen_domctl *domctl,
    1.11 @@ -213,7 +214,7 @@ long arch_do_domctl(
    1.12          int i;
    1.13          struct domain *d = find_domain_by_id(domctl->domain);
    1.14          unsigned long max_pfns = domctl->u.getmemlist.max_pfns;
    1.15 -        unsigned long mfn;
    1.16 +        unsigned long mfn, gmfn;
    1.17          struct list_head *list_ent;
    1.18  
    1.19          ret = -EINVAL;
    1.20 @@ -222,19 +223,48 @@ long arch_do_domctl(
    1.21              ret = 0;
    1.22  
    1.23              spin_lock(&d->page_alloc_lock);
    1.24 -            list_ent = d->page_list.next;
    1.25 -            for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
    1.26 +
    1.27 +            if ( hvm_guest(d->vcpu[0]) && shadow_mode_translate(d) )
    1.28              {
    1.29 -                mfn = page_to_mfn(list_entry(
    1.30 -                    list_ent, struct page_info, list));
    1.31 -                if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
    1.32 -                                          i, &mfn, 1) )
    1.33 +                /* HVM domain: scan P2M to get guaranteed physmap order. */
    1.34 +                for ( i = 0, gmfn = 0;
    1.35 +                      (i < max_pfns) && (i < d->tot_pages); 
    1.36 +                      i++, gmfn++ )
    1.37                  {
    1.38 -                    ret = -EFAULT;
    1.39 -                    break;
    1.40 +                    if ( unlikely(i == (HVM_BELOW_4G_MMIO_START>>PAGE_SHIFT)) )
    1.41 +                    {
    1.42 +                        /* skip MMIO range */
    1.43 +                        gmfn += HVM_BELOW_4G_MMIO_LENGTH >> PAGE_SHIFT;
    1.44 +                    }
    1.45 +                    mfn = gmfn_to_mfn(d, gmfn);
    1.46 +                    if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
    1.47 +                                              i, &mfn, 1) )
    1.48 +                    {
    1.49 +                        ret = -EFAULT;
    1.50 +                        break;
    1.51 +                    }
    1.52                  }
    1.53 -                list_ent = mfn_to_page(mfn)->list.next;
    1.54              }
    1.55 +            else 
    1.56 +            {        
    1.57 +                /* Other guests: return in order of ownership list. */
    1.58 +                list_ent = d->page_list.next;
    1.59 +                for ( i = 0;
    1.60 +                      (i < max_pfns) && (list_ent != &d->page_list);
    1.61 +                      i++ )
    1.62 +                {
    1.63 +                    mfn = page_to_mfn(list_entry(
    1.64 +                        list_ent, struct page_info, list));
    1.65 +                    if ( copy_to_guest_offset(domctl->u.getmemlist.buffer,
    1.66 +                                              i, &mfn, 1) )
    1.67 +                    {
    1.68 +                        ret = -EFAULT;
    1.69 +                        break;
    1.70 +                    }
    1.71 +                    list_ent = mfn_to_page(mfn)->list.next;
    1.72 +                }
    1.73 +            }
    1.74 +            
    1.75              spin_unlock(&d->page_alloc_lock);
    1.76  
    1.77              domctl->u.getmemlist.num_pfns = i;