[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-ia64-devel] [patch] make Xen assign meta-physical memory in spaces that match real hardware
Hi, This is an initial patch to make Xen start assigning meta physical memory in the physical ranges that match the hardware it is running upon. More work needs to be done in this area, but it is crucial we assign memory correctly, in particular for dom0. Cheers, Jes Currently Xen assigns memory to a dom by filling up the holes counting from physical address zero. This is inherently broken as the dom needs to map physical memory chunks it receives onto the physical nodes of the system. I'd like to suggest the following interim patch as a step in this direction, by making Xen assign memory in the zones that map the hardware. On the longer term we need to keep track of what physical memory is really assigned to what dom so the NUMA mapping matches reality. We should also come up with a scheme so one can tell a dom to behave like a virtual DIG box by forcing memory to start from address zero in order to be able to run those underpriviledged operating systems that cannot handle modern computers (a certain thing that nobody likes to talk about comes to mind here). Signed-off-by: Jes Sorensen <jes@xxxxxxx> diff -r 665284c4a8e7 xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.c Tue Dec 19 12:41:21 2006 +0100 +++ b/xen/arch/ia64/xen/dom_fw.c Thu Dec 21 15:31:57 2006 +0100 @@ -507,6 +507,12 @@ struct fw_tables { #define FW_FIELD_MPA(field) \ FW_TABLES_BASE_PADDR + offsetof(struct fw_tables, field) +/* + * This should be a boot line option, or even better, handled as a per + * dom property. + */ +int force_domU_lowmem; + /* Complete the dom0 memmap. */ static int complete_dom0_memmap(struct domain *d, @@ -515,7 +521,7 @@ complete_dom0_memmap(struct domain *d, int num_mds) { efi_memory_desc_t *md; - u64 addr; + u64 addr, mem_assigned, chunk_size; int j; void *efi_map_start, *efi_map_end, *p; u64 efi_desc_size; @@ -526,6 +532,8 @@ complete_dom0_memmap(struct domain *d, efi_map_start = __va(ia64_boot_param->efi_memmap); efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size; efi_desc_size = ia64_boot_param->efi_memdesc_size; + + mem_assigned = 0; for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) { const efi_memory_desc_t *md = p; @@ -561,7 +569,6 @@ complete_dom0_memmap(struct domain *d, num_mds++; break; - case EFI_CONVENTIONAL_MEMORY: case EFI_LOADER_CODE: case EFI_LOADER_DATA: case EFI_BOOT_SERVICES_CODE: @@ -588,6 +595,33 @@ complete_dom0_memmap(struct domain *d, num_mds++; break; + case EFI_CONVENTIONAL_MEMORY: + if (mem_assigned >= maxmem) + break; + + if (d != dom0 && force_domU_lowmem) + break; + + chunk_size = end - start; + /* + * Eventually this needs to be made more + * intelligent so it keeps track of what + * memory was assigned to which dom so + * NUMA information provided to the dom + * is correct. + */ + if ((mem_assigned + chunk_size) > maxmem) + chunk_size = maxmem - mem_assigned; + dom_md->type = EFI_CONVENTIONAL_MEMORY; + dom_md->phys_addr = start; + dom_md->virt_addr = 0; + dom_md->num_pages = chunk_size >> EFI_PAGE_SHIFT; + dom_md->attribute = EFI_MEMORY_WB; + dom_md->pad = 0; + mem_assigned += chunk_size; + num_mds++; + break; + case EFI_UNUSABLE_MEMORY: case EFI_PAL_CODE: /* Discard. */ @@ -606,49 +642,50 @@ complete_dom0_memmap(struct domain *d, /* find gaps and fill them with conventional memory */ i = num_mds; - for (j = 0; j < num_mds; j++) { - unsigned long end; - unsigned long next_start; - - md = &tables->efi_memmap[j]; - end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); - - if (j + 1 < num_mds) { - efi_memory_desc_t* next_md; - next_md = &tables->efi_memmap[j + 1]; - next_start = next_md->phys_addr; - - /* Have just been sorted. */ - BUG_ON(end > next_start); - - /* No room for memory! */ - if (end == next_start) + if (d != dom0 && force_domU_lowmem) { + for (j = 0; j < num_mds; j++) { + unsigned long end; + unsigned long next_start; + + md = &tables->efi_memmap[j]; + end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); + + if (j + 1 < num_mds) { + efi_memory_desc_t* next_md; + next_md = &tables->efi_memmap[j + 1]; + next_start = next_md->phys_addr; + + /* Have just been sorted. */ + BUG_ON(end > next_start); + + /* No room for memory! */ + if (end == next_start) + continue; + + if (next_start > maxmem) + next_start = maxmem; + } else + next_start = maxmem; + + /* Avoid "legacy" low memory addresses + and the HYPERCALL area. */ + if (end < ONE_MB) + end = ONE_MB; + + /* clip the range and align to PAGE_SIZE */ + next_start = next_start & PAGE_MASK; + end = PAGE_ALIGN(end); + + /* No room for memory. */ + if (end >= next_start) continue; - - if (next_start > maxmem) - next_start = maxmem; + + MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, + end, next_start); + + if (next_start >= maxmem) + break; } - else - next_start = maxmem; - - /* Avoid "legacy" low memory addresses - and the HYPERCALL area. */ - if (end < ONE_MB) - end = ONE_MB; - - // clip the range and align to PAGE_SIZE - next_start = next_start & PAGE_MASK; - end = PAGE_ALIGN(end); - - /* No room for memory. */ - if (end >= next_start) - continue; - - MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, - end, next_start); - - if (next_start >= maxmem) - break; } num_mds = i; BUG_ON(num_mds > NUM_MEM_DESCS); _______________________________________________ Xen-ia64-devel mailing list Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-ia64-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |