direct-io.hg

changeset 12425:5c5af79e7272

[IA64] IA64 counter part of the change 12204:e6fdb32b786c of xen-unstable.hg

Remove xc_ia64_get_pfn_list() from setup_guest() in xc_linux_build.c,
use xc_domain_populate_physmap() and xc_domain_translate_gpfn_list().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author awilliam@xenbuild.aw
date Fri Nov 10 11:14:32 2006 -0700 (2006-11-10)
parents 93d7d0025408
children 8533c59c5b40
files tools/libxc/xc_linux_build.c xen/arch/ia64/xen/dom0_ops.c xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/domain.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Fri Nov 10 11:14:26 2006 -0700
     1.2 +++ b/tools/libxc/xc_linux_build.c	Fri Nov 10 11:14:32 2006 -0700
     1.3 @@ -496,6 +496,26 @@ static int setup_guest(int xc_handle,
     1.4      if ( rc != 0 )
     1.5          goto error_out;
     1.6  
     1.7 +    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
     1.8 +    {
     1.9 +        PERROR("Could not allocate memory");
    1.10 +        goto error_out;
    1.11 +    }
    1.12 +    for ( i = 0; i < nr_pages; i++ )
    1.13 +        page_array[i] = i;
    1.14 +    if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages,
    1.15 +                                           0, 0, page_array) )
    1.16 +    {
    1.17 +        PERROR("Could not allocate memory for PV guest.\n");
    1.18 +        goto error_out;
    1.19 +    }
    1.20 +    if ( xc_domain_translate_gpfn_list(xc_handle, dom, nr_pages,
    1.21 +                                       page_array, page_array) )
    1.22 +    {
    1.23 +        PERROR("Could not translate addresses of PV guest.\n");
    1.24 +        goto error_out;
    1.25 +    }
    1.26 +
    1.27      dsi.v_start    = round_pgdown(dsi.v_start);
    1.28      vinitrd_start  = round_pgup(dsi.v_end);
    1.29      start_info_mpa = (nr_pages - 3) << PAGE_SHIFT;
    1.30 @@ -511,23 +531,10 @@ static int setup_guest(int xc_handle,
    1.31      if ( xc_domctl(xc_handle, &domctl) )
    1.32          goto error_out;
    1.33  
    1.34 -    if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
    1.35 -    {
    1.36 -        PERROR("Could not allocate memory");
    1.37 -        goto error_out;
    1.38 -    }
    1.39 -
    1.40      start_page = dsi.v_start >> PAGE_SHIFT;
    1.41 -    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
    1.42 -                              start_page, nr_pages) != nr_pages )
    1.43 -    {
    1.44 -        PERROR("Could not get the page frame list");
    1.45 -        goto error_out;
    1.46 -    }
    1.47 -
    1.48      /* in order to get initrd->len, we need to load initrd image at first */
    1.49      if ( load_initrd(xc_handle, dom, initrd,
    1.50 -                     vinitrd_start - dsi.v_start, page_array) )
    1.51 +                     vinitrd_start - dsi.v_start, page_array + start_page) )
    1.52          goto error_out;
    1.53  
    1.54      vinitrd_end    = vinitrd_start + initrd->len;
    1.55 @@ -535,18 +542,9 @@ static int setup_guest(int xc_handle,
    1.56      pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT;
    1.57      if ( pgnr > nr_pages )
    1.58      {
    1.59 -        free(page_array);
    1.60 -        if ( (page_array = malloc(pgnr * sizeof(xen_pfn_t))) == NULL )
    1.61 -        {
    1.62 -            PERROR("Could not reallocate memory");
    1.63 -            goto error_out;
    1.64 -        }
    1.65 -        if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
    1.66 -                                  start_page, pgnr) != pgnr )
    1.67 -        {
    1.68 -                PERROR("Could not get the page frame list");
    1.69 -                goto error_out;
    1.70 -        }
    1.71 +        PERROR("too small memory is specified. "
    1.72 +               "At least %ld kb is necessary.\n",
    1.73 +               pgnr << (PAGE_SHIFT - 10));
    1.74      }
    1.75  
    1.76      IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
    1.77 @@ -558,31 +556,21 @@ static int setup_guest(int xc_handle,
    1.78             _p(dsi.v_start),     _p(v_end));
    1.79      IPRINTF(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
    1.80  
    1.81 -    (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
    1.82 -                           &dsi);
    1.83 +    (load_funcs.loadimage)(image, image_size, xc_handle, dom,
    1.84 +                           page_array + start_page, &dsi);
    1.85  
    1.86 -    /* Now need to retrieve machine pfn for system pages:
    1.87 -     *  start_info/store/console
    1.88 -     */
    1.89 -    pgnr = 3;
    1.90 -    if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array,
    1.91 -                              nr_pages - 3, pgnr) != pgnr )
    1.92 -    {
    1.93 -        PERROR("Could not get page frame for xenstore");
    1.94 -        goto error_out;
    1.95 -    }
    1.96 -
    1.97 -    *store_mfn = page_array[1];
    1.98 -    *console_mfn = page_array[2];
    1.99 +    *store_mfn = page_array[nr_pages - 2];
   1.100 +    *console_mfn = page_array[nr_pages - 1];
   1.101      IPRINTF("start_info: 0x%lx at 0x%lx, "
   1.102             "store_mfn: 0x%lx at 0x%lx, "
   1.103             "console_mfn: 0x%lx at 0x%lx\n",
   1.104 -           page_array[0], nr_pages - 3,
   1.105 +           page_array[nr_pages - 3], nr_pages - 3,
   1.106             *store_mfn,    nr_pages - 2,
   1.107             *console_mfn,  nr_pages - 1);
   1.108  
   1.109      start_info = xc_map_foreign_range(
   1.110 -        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[0]);
   1.111 +        xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   1.112 +        page_array[nr_pages - 3]);
   1.113      memset(start_info, 0, sizeof(*start_info));
   1.114      rc = xc_version(xc_handle, XENVER_version, NULL);
   1.115      sprintf(start_info->magic, "xen-%i.%i-ia64", rc >> 16, rc & (0xFFFF));
     2.1 --- a/xen/arch/ia64/xen/dom0_ops.c	Fri Nov 10 11:14:26 2006 -0700
     2.2 +++ b/xen/arch/ia64/xen/dom0_ops.c	Fri Nov 10 11:14:32 2006 -0700
     2.3 @@ -24,7 +24,6 @@
     2.4  #include <xen/errno.h>
     2.5  #include <xen/nodemask.h>
     2.6  
     2.7 -void build_physmap_table(struct domain *d);
     2.8  #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
     2.9  
    2.10  extern unsigned long total_pages;
    2.11 @@ -117,7 +116,6 @@ long arch_do_domctl(xen_domctl_t *op, XE
    2.12                  vmx_setup_platform(d);
    2.13              }
    2.14              else {
    2.15 -                build_physmap_table(d);
    2.16                  dom_fw_setup(d, ds->bp, ds->maxmem);
    2.17                  if (ds->xsi_va)
    2.18                      d->arch.shared_info_va = ds->xsi_va;
     3.1 --- a/xen/arch/ia64/xen/dom_fw.c	Fri Nov 10 11:14:26 2006 -0700
     3.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Fri Nov 10 11:14:32 2006 -0700
     3.3 @@ -55,9 +55,9 @@ extern unsigned long running_on_sim;
     3.4  		tables->func_ptrs[pfn++] = 0;                     	\
     3.5  	} while (0)
     3.6  
     3.7 -// allocate a page for fw
     3.8 -// build_physmap_table() which is called by new_thread()
     3.9 -// does for domU.
    3.10 +/* allocate a page for fw
    3.11 + * guest_setup() @ libxc/xc_linux_build.c does for domU
    3.12 + */
    3.13  static inline void
    3.14  assign_new_domain_page_if_dom0(struct domain *d, unsigned long mpaddr)
    3.15  {
    3.16 @@ -634,9 +634,10 @@ complete_dom0_memmap(struct domain *d,
    3.17  	sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
    3.18  	     efi_mdt_cmp, NULL);
    3.19  
    3.20 -	// dom0 doesn't need build_physmap_table()
    3.21 -	// see arch_set_info_guest()
    3.22 -	// instead we allocate pages manually.
    3.23 +	/* setup_guest() @ libxc/xc_linux_build() arranges memory for domU.
    3.24 +	 * however no one arranges memory for dom0,
    3.25 +	 * instead we allocate pages manually.
    3.26 +	 */
    3.27  	for (i = 0; i < num_mds; i++) {
    3.28  		md = &tables->efi_memmap[i];
    3.29  		if (md->phys_addr > maxmem)
     4.1 --- a/xen/arch/ia64/xen/domain.c	Fri Nov 10 11:14:26 2006 -0700
     4.2 +++ b/xen/arch/ia64/xen/domain.c	Fri Nov 10 11:14:32 2006 -0700
     4.3 @@ -628,21 +628,6 @@ void domain_relinquish_resources(struct 
     4.4  	    xfree(d->arch.sal_data);
     4.5  }
     4.6  
     4.7 -void build_physmap_table(struct domain *d)
     4.8 -{
     4.9 -	struct list_head *list_ent = d->page_list.next;
    4.10 -	unsigned long mfn, i = 0;
    4.11 -
    4.12 -	while(list_ent != &d->page_list) {
    4.13 -	    mfn = page_to_mfn(list_entry(
    4.14 -		list_ent, struct page_info, list));
    4.15 -	    assign_domain_page(d, i << PAGE_SHIFT, mfn << PAGE_SHIFT);
    4.16 -
    4.17 -	    i++;
    4.18 -	    list_ent = mfn_to_page(mfn)->list.next;
    4.19 -	}
    4.20 -}
    4.21 -
    4.22  unsigned long
    4.23  domain_set_shared_info_va (unsigned long va)
    4.24  {