# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1163136392 -32400 # Node ID 13397c9919becfc33466206f8488d7ce55097100 # Parent 3f20ddf2949d67c5ac432ff87c6c5f46cbdbd1b2 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(). PATCHNAME: remove_xc_ia64_get_pfn_list Signed-off-by: Isaku Yamahata diff -r 3f20ddf2949d -r 13397c9919be tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Tue Nov 07 15:06:39 2006 +0900 +++ b/tools/libxc/xc_linux_build.c Fri Nov 10 14:26:32 2006 +0900 @@ -496,6 +496,26 @@ static int setup_guest(int xc_handle, if ( rc != 0 ) goto error_out; + if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL ) + { + PERROR("Could not allocate memory"); + goto error_out; + } + for ( i = 0; i < nr_pages; i++ ) + page_array[i] = i; + if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages, + 0, 0, page_array) ) + { + PERROR("Could not allocate memory for PV guest.\n"); + goto error_out; + } + if ( xc_domain_translate_gpfn_list(xc_handle, dom, nr_pages, + page_array, page_array) ) + { + PERROR("Could not translate addresses of PV guest.\n"); + goto error_out; + } + dsi.v_start = round_pgdown(dsi.v_start); vinitrd_start = round_pgup(dsi.v_end); start_info_mpa = (nr_pages - 3) << PAGE_SHIFT; @@ -511,23 +531,10 @@ static int setup_guest(int xc_handle, if ( xc_domctl(xc_handle, &domctl) ) goto error_out; - if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL ) - { - PERROR("Could not allocate memory"); - goto error_out; - } - start_page = dsi.v_start >> PAGE_SHIFT; - if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array, - start_page, nr_pages) != nr_pages ) - { - PERROR("Could not get the page frame list"); - goto error_out; - } - /* in order to get initrd->len, we need to load initrd image at first */ if ( load_initrd(xc_handle, dom, initrd, - vinitrd_start - dsi.v_start, page_array) ) + vinitrd_start - dsi.v_start, page_array + start_page) ) goto error_out; vinitrd_end = vinitrd_start + initrd->len; @@ -535,18 +542,9 @@ static int setup_guest(int xc_handle, pgnr = (v_end - dsi.v_start) >> PAGE_SHIFT; if ( pgnr > nr_pages ) { - free(page_array); - if ( (page_array = malloc(pgnr * sizeof(xen_pfn_t))) == NULL ) - { - PERROR("Could not reallocate memory"); - goto error_out; - } - if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array, - start_page, pgnr) != pgnr ) - { - PERROR("Could not get the page frame list"); - goto error_out; - } + PERROR("too small memory is specified. " + "At least %ld kb is necessary.\n", + pgnr << (PAGE_SHIFT - 10)); } IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" @@ -558,31 +556,21 @@ static int setup_guest(int xc_handle, _p(dsi.v_start), _p(v_end)); IPRINTF(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry)); - (load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array, - &dsi); - - /* Now need to retrieve machine pfn for system pages: - * start_info/store/console - */ - pgnr = 3; - if ( xc_ia64_get_pfn_list(xc_handle, dom, page_array, - nr_pages - 3, pgnr) != pgnr ) - { - PERROR("Could not get page frame for xenstore"); - goto error_out; - } - - *store_mfn = page_array[1]; - *console_mfn = page_array[2]; + (load_funcs.loadimage)(image, image_size, xc_handle, dom, + page_array + start_page, &dsi); + + *store_mfn = page_array[nr_pages - 2]; + *console_mfn = page_array[nr_pages - 1]; IPRINTF("start_info: 0x%lx at 0x%lx, " "store_mfn: 0x%lx at 0x%lx, " "console_mfn: 0x%lx at 0x%lx\n", - page_array[0], nr_pages - 3, + page_array[nr_pages - 3], nr_pages - 3, *store_mfn, nr_pages - 2, *console_mfn, nr_pages - 1); start_info = xc_map_foreign_range( - xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, page_array[0]); + xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, + page_array[nr_pages - 3]); memset(start_info, 0, sizeof(*start_info)); rc = xc_version(xc_handle, XENVER_version, NULL); sprintf(start_info->magic, "xen-%i.%i-ia64", rc >> 16, rc & (0xFFFF)); diff -r 3f20ddf2949d -r 13397c9919be xen/arch/ia64/xen/dom0_ops.c --- a/xen/arch/ia64/xen/dom0_ops.c Tue Nov 07 15:06:39 2006 +0900 +++ b/xen/arch/ia64/xen/dom0_ops.c Fri Nov 10 14:26:32 2006 +0900 @@ -24,7 +24,6 @@ #include #include -void build_physmap_table(struct domain *d); #define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) extern unsigned long total_pages; @@ -117,7 +116,6 @@ long arch_do_domctl(xen_domctl_t *op, XE vmx_setup_platform(d); } else { - build_physmap_table(d); dom_fw_setup(d, ds->bp, ds->maxmem); if (ds->xsi_va) d->arch.shared_info_va = ds->xsi_va; diff -r 3f20ddf2949d -r 13397c9919be xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.c Tue Nov 07 15:06:39 2006 +0900 +++ b/xen/arch/ia64/xen/dom_fw.c Fri Nov 10 14:26:32 2006 +0900 @@ -55,9 +55,9 @@ extern unsigned long running_on_sim; tables->func_ptrs[pfn++] = 0; \ } while (0) -// allocate a page for fw -// build_physmap_table() which is called by new_thread() -// does for domU. +/* allocate a page for fw + * guest_setup() @ libxc/xc_linux_build.c does for domU + */ static inline void assign_new_domain_page_if_dom0(struct domain *d, unsigned long mpaddr) { @@ -634,9 +634,10 @@ complete_dom0_memmap(struct domain *d, sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL); - // dom0 doesn't need build_physmap_table() - // see arch_set_info_guest() - // instead we allocate pages manually. + /* setup_guest() @ libxc/xc_linux_build() arranges memory for domU. + * however no one arranges memory for dom0, + * instead we allocate pages manually. + */ for (i = 0; i < num_mds; i++) { md = &tables->efi_memmap[i]; if (md->phys_addr > maxmem) diff -r 3f20ddf2949d -r 13397c9919be xen/arch/ia64/xen/domain.c --- a/xen/arch/ia64/xen/domain.c Tue Nov 07 15:06:39 2006 +0900 +++ b/xen/arch/ia64/xen/domain.c Fri Nov 10 14:26:32 2006 +0900 @@ -629,21 +629,6 @@ void domain_relinquish_resources(struct xfree(d->arch.sal_data); } -void build_physmap_table(struct domain *d) -{ - struct list_head *list_ent = d->page_list.next; - unsigned long mfn, i = 0; - - while(list_ent != &d->page_list) { - mfn = page_to_mfn(list_entry( - list_ent, struct page_info, list)); - assign_domain_page(d, i << PAGE_SHIFT, mfn << PAGE_SHIFT); - - i++; - list_ent = mfn_to_page(mfn)->list.next; - } -} - unsigned long domain_set_shared_info_va (unsigned long va) {