ia64/xen-unstable
changeset 13124:42babffffba5
[IA64] Clean up VTi memory initialization logic
This patch makes the logic in setup_guest() more clear.
domain_translate_gpfn_list() is now gone, so we can make
memory initializtion code simple.
Xend passes memory size which is a sum of normal memory
size and GFW memory to QEMU and Libxc. This patch fixes
this issue.
Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
This patch makes the logic in setup_guest() more clear.
domain_translate_gpfn_list() is now gone, so we can make
memory initializtion code simple.
Xend passes memory size which is a sum of normal memory
size and GFW memory to QEMU and Libxc. This patch fixes
this issue.
Signed-off-by: Zhang Xin <xing.z.zhang@intel.com>
author | awilliam@xenbuild2.aw |
---|---|
date | Wed Jan 10 08:00:50 2007 -0700 (2007-01-10) |
parents | 90db0f68b121 |
children | 58633caeece9 |
files | tools/ioemu/vl.c tools/libxc/ia64/xc_ia64_hvm_build.c tools/python/xen/xend/image.py |
line diff
1.1 --- a/tools/ioemu/vl.c Thu Jan 04 23:21:30 2007 -0700 1.2 +++ b/tools/ioemu/vl.c Wed Jan 10 08:00:50 2007 -0700 1.3 @@ -6464,10 +6464,6 @@ 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
2.1 --- a/tools/libxc/ia64/xc_ia64_hvm_build.c Thu Jan 04 23:21:30 2007 -0700 2.2 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c Wed Jan 10 08:00:50 2007 -0700 2.3 @@ -569,18 +569,13 @@ setup_guest(int xc_handle, uint32_t dom, 2.4 xen_pfn_t *pfn_list; 2.5 shared_iopage_t *sp; 2.6 void *ioreq_buffer_page; 2.7 - // memsize equal to normal memory size(in configure file) + 16M 2.8 - // dom_memsize will pass to xc_ia64_build_hob(), so must be subbed 16M 2.9 - unsigned long dom_memsize = ((memsize - 16) << 20); 2.10 - unsigned long nr_pages = (unsigned long)memsize << (20 - PAGE_SHIFT); 2.11 - unsigned long normal_pages = nr_pages - GFW_PAGES; 2.12 + unsigned long dom_memsize = memsize << 20; 2.13 + unsigned long nr_pages = memsize << (20 - PAGE_SHIFT); 2.14 unsigned long vcpus; 2.15 int rc; 2.16 - long i, j; 2.17 + long i; 2.18 DECLARE_DOMCTL; 2.19 2.20 - // ROM size for guest firmware, ioreq page and xenstore page 2.21 - nr_pages += 3; 2.22 2.23 if ((image_size > 12 * MEM_M) || (image_size & (PAGE_SIZE - 1))) { 2.24 PERROR("Guest firmware size is incorrect [%ld]?", image_size); 2.25 @@ -598,20 +593,20 @@ setup_guest(int xc_handle, uint32_t dom, 2.26 pfn_list[i] = i; 2.27 2.28 // If normal memory > 3G. Reserve 3G ~ 4G for MMIO, GFW and others. 2.29 - for (j = (MMIO_START >> PAGE_SHIFT); j < (dom_memsize >> PAGE_SHIFT); j++) 2.30 - pfn_list[j] += ((1 * MEM_G) >> PAGE_SHIFT); 2.31 + for (i = (MMIO_START >> PAGE_SHIFT); i < (dom_memsize >> PAGE_SHIFT); i++) 2.32 + pfn_list[i] += ((1 * MEM_G) >> PAGE_SHIFT); 2.33 2.34 // Allocate memory for VTI guest, up to VGA hole from 0xA0000-0xC0000. 2.35 rc = xc_domain_memory_populate_physmap(xc_handle, dom, 2.36 - (normal_pages > VGA_START_PAGE) ? 2.37 - VGA_START_PAGE : normal_pages, 2.38 + (nr_pages > VGA_START_PAGE) ? 2.39 + VGA_START_PAGE : nr_pages, 2.40 0, 0, &pfn_list[0]); 2.41 2.42 // We're not likely to attempt to create a domain with less than 2.43 // 640k of memory, but test for completeness 2.44 if (rc == 0 && nr_pages > VGA_END_PAGE) 2.45 rc = xc_domain_memory_populate_physmap(xc_handle, dom, 2.46 - normal_pages - VGA_END_PAGE, 2.47 + nr_pages - VGA_END_PAGE, 2.48 0, 0, &pfn_list[VGA_END_PAGE]); 2.49 if (rc != 0) { 2.50 PERROR("Could not allocate normal memory for Vti guest.\n"); 2.51 @@ -621,24 +616,22 @@ setup_guest(int xc_handle, uint32_t dom, 2.52 // We allocate additional pfn for GFW and other three pages, so 2.53 // the pfn_list is not contiguous. Due to this we must support 2.54 // old interface xc_ia64_get_pfn_list(). 2.55 - // Here i = (dom_memsize >> PAGE_SHIFT) 2.56 - for (j = 0; i < nr_pages - 3; i++, j++) 2.57 - pfn_list[i] = (GFW_START >> PAGE_SHIFT) + j; 2.58 + for (i = 0; i < GFW_PAGES; i++) 2.59 + pfn_list[i] = (GFW_START >> PAGE_SHIFT) + i; 2.60 2.61 rc = xc_domain_memory_populate_physmap(xc_handle, dom, GFW_PAGES, 2.62 - 0, 0, &pfn_list[normal_pages]); 2.63 + 0, 0, &pfn_list[0]); 2.64 if (rc != 0) { 2.65 PERROR("Could not allocate GFW memory for Vti guest.\n"); 2.66 goto error_out; 2.67 } 2.68 2.69 - // Here i = (dom_memsize >> PAGE_SHIFT) + GFW_PAGES 2.70 - pfn_list[i] = IO_PAGE_START >> PAGE_SHIFT; 2.71 - pfn_list[i+1] = STORE_PAGE_START >> PAGE_SHIFT; 2.72 - pfn_list[i+2] = BUFFER_IO_PAGE_START >> PAGE_SHIFT; 2.73 + pfn_list[0] = IO_PAGE_START >> PAGE_SHIFT; 2.74 + pfn_list[1] = STORE_PAGE_START >> PAGE_SHIFT; 2.75 + pfn_list[2] = BUFFER_IO_PAGE_START >> PAGE_SHIFT; 2.76 2.77 rc = xc_domain_memory_populate_physmap(xc_handle, dom, 3, 2.78 - 0, 0, &pfn_list[nr_pages - 3]); 2.79 + 0, 0, &pfn_list[0]); 2.80 if (rc != 0) { 2.81 PERROR("Could not allocate IO page or store page or buffer io page.\n"); 2.82 goto error_out; 2.83 @@ -675,13 +668,12 @@ setup_guest(int xc_handle, uint32_t dom, 2.84 goto error_out; 2.85 } 2.86 2.87 - xc_set_hvm_param(xc_handle, dom, 2.88 - HVM_PARAM_STORE_PFN, pfn_list[nr_pages - 2]); 2.89 + xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, pfn_list[1]); 2.90 2.91 // Retrieve special pages like io, xenstore, etc. 2.92 sp = (shared_iopage_t *)xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 2.93 PROT_READ | PROT_WRITE, 2.94 - pfn_list[nr_pages - 3]); 2.95 + pfn_list[0]); 2.96 if (sp == 0) 2.97 goto error_out; 2.98 2.99 @@ -689,7 +681,7 @@ setup_guest(int xc_handle, uint32_t dom, 2.100 munmap(sp, PAGE_SIZE); 2.101 ioreq_buffer_page = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, 2.102 PROT_READ | PROT_WRITE, 2.103 - pfn_list[nr_pages - 1]); 2.104 + pfn_list[2]); 2.105 memset(ioreq_buffer_page,0,PAGE_SIZE); 2.106 munmap(ioreq_buffer_page, PAGE_SIZE); 2.107 free(pfn_list);
3.1 --- a/tools/python/xen/xend/image.py Thu Jan 04 23:21:30 2007 -0700 3.2 +++ b/tools/python/xen/xend/image.py Wed Jan 10 08:00:50 2007 -0700 3.3 @@ -591,6 +591,9 @@ class IA64_HVM_ImageHandler(HVMImageHand 3.4 extra_pages = 1024 + 3 3.5 return mem_kb + extra_pages * page_kb 3.6 3.7 + def getRequiredInitialReservation(self): 3.8 + return self.vm.getMemoryTarget() 3.9 + 3.10 def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb): 3.11 # Explicit shadow memory is not a concept 3.12 return 0