ia64/xen-unstable

changeset 12796:d901f2fe8c25

[IA64] Fix Vti

Use new foreign page mapping interface

Signed-off-by: Xu Anthony <Anthony.xu@intel.com>
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
author awilliam@xenbuild2.aw
date Wed Dec 06 02:34:46 2006 -0700 (2006-12-06)
parents 85b9711cb895
children 4f1a3ae07dbc
files tools/ioemu/vl.c tools/libxc/ia64/xc_ia64_hvm_build.c
line diff
     1.1 --- a/tools/ioemu/vl.c	Tue Dec 05 13:42:37 2006 -0700
     1.2 +++ b/tools/ioemu/vl.c	Wed Dec 06 02:34:46 2006 -0700
     1.3 @@ -6378,6 +6378,10 @@ int main(int argc, char **argv)
     1.4      }
     1.5  
     1.6  #if defined (__ia64__)
     1.7 +    /* ram_size passed from xend has added on GFW memory,
     1.8 +       so we must subtract it here */
     1.9 +    ram_size -= 16 * MEM_M;
    1.10 +
    1.11      if (ram_size > MMIO_START)
    1.12          ram_size += 1 * MEM_G; /* skip 3G-4G MMIO, LEGACY_IO_SPACE etc. */
    1.13  #endif
    1.14 @@ -6443,36 +6447,24 @@ int main(int argc, char **argv)
    1.15      free(page_array);
    1.16  
    1.17  #elif defined(__ia64__)
    1.18 -  
    1.19 -    if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
    1.20 -                             IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
    1.21 -        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
    1.22 -        exit(-1);
    1.23 -    }
    1.24  
    1.25      shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
    1.26                                         PROT_READ|PROT_WRITE,
    1.27 -                                       page_array[0]);
    1.28 -
    1.29 -    fprintf(logfile, "shared page at pfn:%lx, mfn: %016lx\n",
    1.30 -            IO_PAGE_START >> PAGE_SHIFT, page_array[0]);
    1.31 +                                       IO_PAGE_START >> PAGE_SHIFT);
    1.32  
    1.33      buffered_io_page =xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
    1.34                                         PROT_READ|PROT_WRITE,
    1.35 -                                       page_array[2]);
    1.36 -    fprintf(logfile, "Buffered IO page at pfn:%lx, mfn: %016lx\n",
    1.37 -            BUFFER_IO_PAGE_START >> PAGE_SHIFT, page_array[2]);
    1.38 -
    1.39 -    if (xc_ia64_get_pfn_list(xc_handle, domid,
    1.40 -                             page_array, 0, nr_pages) != nr_pages) {
    1.41 -        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
    1.42 -        exit(-1);
    1.43 -    }
    1.44 -
    1.45 +                                       BUFFER_IO_PAGE_START >> PAGE_SHIFT);
    1.46 +
    1.47 +    for (i = 0; i < tmp_nr_pages; i++)
    1.48 +        page_array[i] = i;
    1.49 +	
    1.50 +    /* VTI will not use memory between 3G~4G, so we just pass a legal pfn
    1.51 +       to make QEMU map continuous virtual memory space */
    1.52      if (ram_size > MMIO_START) {	
    1.53          for (i = 0 ; i < (MEM_G >> PAGE_SHIFT); i++)
    1.54              page_array[(MMIO_START >> PAGE_SHIFT) + i] =
    1.55 -                page_array[(IO_PAGE_START >> PAGE_SHIFT) + 1];
    1.56 +                (STORE_PAGE_START >> PAGE_SHIFT); 
    1.57      }
    1.58  
    1.59      phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
     2.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c	Tue Dec 05 13:42:37 2006 -0700
     2.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c	Wed Dec 06 02:34:46 2006 -0700
     2.3 @@ -13,32 +13,15 @@ xc_ia64_copy_to_domain_pages(int xc_hand
     2.4                               unsigned long dst_pfn, int nr_pages)
     2.5  {
     2.6      // N.B. gva should be page aligned
     2.7 -
     2.8 -    xen_pfn_t *page_array = NULL;
     2.9      int i;
    2.10  
    2.11 -    page_array = malloc(nr_pages * sizeof(xen_pfn_t));
    2.12 -    if (page_array == NULL) {
    2.13 -        PERROR("Could not allocate memory");
    2.14 -        goto error_out;
    2.15 -    }
    2.16 -    if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
    2.17 -                             dst_pfn, nr_pages) != nr_pages) {
    2.18 -        PERROR("Could not get the page frame list");
    2.19 -        goto error_out;
    2.20 +    for (i = 0; i < nr_pages; i++) {
    2.21 +        if (xc_copy_to_domain_page(xc_handle, domid, dst_pfn + i,
    2.22 +                                   src_page + (i << PAGE_SHIFT)))
    2.23 +            return -1;
    2.24      }
    2.25  
    2.26 -    for (i = 0; i < nr_pages; i++) {
    2.27 -        if (xc_copy_to_domain_page(xc_handle, domid, page_array[i],
    2.28 -                                   src_page + (i << PAGE_SHIFT)))
    2.29 -            goto error_out;
    2.30 -    }
    2.31 -    free(page_array);
    2.32      return 0;
    2.33 -
    2.34 -error_out:
    2.35 -    free(page_array);
    2.36 -    return -1;
    2.37  }
    2.38  
    2.39  int 
    2.40 @@ -657,7 +640,7 @@ setup_guest(int xc_handle, uint32_t dom,
    2.41      rc = xc_domain_memory_populate_physmap(xc_handle, dom, 3,
    2.42                                             0, 0, &pfn_list[nr_pages - 3]);
    2.43      if (rc != 0) {
    2.44 -        PERROR("Could not allocate GFW memory for Vti guest.\n");
    2.45 +        PERROR("Could not allocate IO page or store page or buffer io page.\n");
    2.46          goto error_out;
    2.47      }
    2.48